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. // PaymentStatus describe the state of a payment.
type PaymentStatus struct { type PaymentStatus struct {
State lnrpc.Payment_PaymentStatus State lnrpc.Payment_PaymentStatus
Preimage lntypes.Preimage Preimage lntypes.Preimage
Fee lnwire.MilliSatoshi Fee lnwire.MilliSatoshi
Value 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. // SendPaymentRequest defines the payment parameters for a new payment.
@ -227,6 +239,19 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
status.Value = lnwire.MilliSatoshi(rpcPayment.ValueMsat) 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 return &status, nil
} }

@ -469,8 +469,7 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
select { select {
// Payment advanced to the next state. // Payment advanced to the next state.
case payState := <-payStatusChan: case payState := <-payStatusChan:
s.log.Infof("Payment %v: state=%v", s.log.Infof("Payment %v: %v", hash, payState)
hash, payState.State)
switch payState.State { switch payState.State {
case lnrpc.Payment_SUCCEEDED: case lnrpc.Payment_SUCCEEDED:

Loading…
Cancel
Save