loopout: log in-flight htlc status

pull/178/head
Joost Jager 4 years ago
parent 4039ba9b69
commit 710ae77750
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -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…
Cancel
Save