mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopout: log in-flight htlc status
This commit is contained in:
parent
4039ba9b69
commit
710ae77750
2 changed files with 30 additions and 6 deletions
|
|
@ -34,10 +34,22 @@ type RouterClient interface {
|
|||
|
||||
// PaymentStatus describe the state of a payment.
|
||||
type PaymentStatus struct {
|
||||
State lnrpc.Payment_PaymentStatus
|
||||
Preimage lntypes.Preimage
|
||||
Fee lnwire.MilliSatoshi
|
||||
Value lnwire.MilliSatoshi
|
||||
State lnrpc.Payment_PaymentStatus
|
||||
Preimage lntypes.Preimage
|
||||
Fee lnwire.MilliSatoshi
|
||||
Value lnwire.MilliSatoshi
|
||||
InFlightAmt lnwire.MilliSatoshi
|
||||
InFlightHtlcs int
|
||||
}
|
||||
|
||||
func (p PaymentStatus) String() string {
|
||||
text := fmt.Sprintf("state=%v", p.State)
|
||||
if p.State == lnrpc.Payment_IN_FLIGHT {
|
||||
text += fmt.Sprintf(", inflight_htlcs=%v, inflight_amt=%v",
|
||||
p.InFlightHtlcs, p.InFlightAmt)
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
// SendPaymentRequest defines the payment parameters for a new payment.
|
||||
|
|
@ -227,6 +239,19 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
|
|||
status.Value = lnwire.MilliSatoshi(rpcPayment.ValueMsat)
|
||||
}
|
||||
|
||||
for _, htlc := range rpcPayment.Htlcs {
|
||||
if htlc.Status != lnrpc.HTLCAttempt_IN_FLIGHT {
|
||||
continue
|
||||
}
|
||||
|
||||
status.InFlightHtlcs++
|
||||
|
||||
lastHop := htlc.Route.Hops[len(htlc.Route.Hops)-1]
|
||||
status.InFlightAmt += lnwire.MilliSatoshi(
|
||||
lastHop.AmtToForwardMsat,
|
||||
)
|
||||
}
|
||||
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -469,8 +469,7 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
|
|||
select {
|
||||
// Payment advanced to the next state.
|
||||
case payState := <-payStatusChan:
|
||||
s.log.Infof("Payment %v: state=%v",
|
||||
hash, payState.State)
|
||||
s.log.Infof("Payment %v: %v", hash, payState)
|
||||
|
||||
switch payState.State {
|
||||
case lnrpc.Payment_SUCCEEDED:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue