@@ -34,10 +34,22 @@ type RouterClient interface {
3434
3535// PaymentStatus describe the state of a payment.
3636type PaymentStatus struct {
37- State lnrpc.Payment_PaymentStatus
38- Preimage lntypes.Preimage
39- Fee lnwire.MilliSatoshi
40- Value lnwire.MilliSatoshi
37+ State lnrpc.Payment_PaymentStatus
38+ Preimage lntypes.Preimage
39+ Fee lnwire.MilliSatoshi
40+ Value lnwire.MilliSatoshi
41+ InFlightAmt lnwire.MilliSatoshi
42+ InFlightHtlcs int
43+ }
44+
45+ func (p PaymentStatus ) String () string {
46+ text := fmt .Sprintf ("state=%v" , p .State )
47+ if p .State == lnrpc .Payment_IN_FLIGHT {
48+ text += fmt .Sprintf (", inflight_htlcs=%v, inflight_amt=%v" ,
49+ p .InFlightHtlcs , p .InFlightAmt )
50+ }
51+
52+ return text
4153}
4254
4355// SendPaymentRequest defines the payment parameters for a new payment.
@@ -227,6 +239,19 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
227239 status .Value = lnwire .MilliSatoshi (rpcPayment .ValueMsat )
228240 }
229241
242+ for _ , htlc := range rpcPayment .Htlcs {
243+ if htlc .Status != lnrpc .HTLCAttempt_IN_FLIGHT {
244+ continue
245+ }
246+
247+ status .InFlightHtlcs ++
248+
249+ lastHop := htlc .Route .Hops [len (htlc .Route .Hops )- 1 ]
250+ status .InFlightAmt += lnwire .MilliSatoshi (
251+ lastHop .AmtToForwardMsat ,
252+ )
253+ }
254+
230255 return & status , nil
231256}
232257
0 commit comments