From e61ff2202da92da9fd0ad99a60667033b152d872 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 9 Apr 2020 16:30:21 +0200 Subject: [PATCH] lnrpc: report total fees paid Fixes a bug where only the fees of the last route where reported. --- lnrpc/routerrpc/router_backend.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index e8493871..2d2be75b 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -1095,20 +1095,17 @@ func marshallChannelUpdate(update *lnwire.ChannelUpdate) *lnrpc.ChannelUpdate { func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) ( *lnrpc.Payment, error) { - // Fetch the payment's route and preimage. If no HTLC was - // successful, an empty route and preimage will be used. + // Fetch the payment's preimage and the total paid in fees. var ( - route route.Route + fee lnwire.MilliSatoshi preimage lntypes.Preimage ) for _, htlc := range payment.HTLCs { - // Display the last route attempted. - route = htlc.Route - // If any of the htlcs have settled, extract a valid // preimage. if htlc.Settle != nil { preimage = htlc.Settle.Preimage + fee += htlc.Route.TotalFees() } } @@ -1147,9 +1144,9 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) ( ValueSat: satValue, CreationDate: payment.Info.CreationTime.Unix(), CreationTimeNs: creationTimeNS, - Fee: int64(route.TotalFees().ToSatoshis()), - FeeSat: int64(route.TotalFees().ToSatoshis()), - FeeMsat: int64(route.TotalFees()), + Fee: int64(fee.ToSatoshis()), + FeeSat: int64(fee.ToSatoshis()), + FeeMsat: int64(fee), PaymentPreimage: hex.EncodeToString(preimage[:]), PaymentRequest: string(payment.Info.PaymentRequest), Status: status,