lnrpc: report total fees paid
Fixes a bug where only the fees of the last route where reported.
This commit is contained in:
parent
06f73c0a66
commit
e61ff2202d
@ -1095,20 +1095,17 @@ func marshallChannelUpdate(update *lnwire.ChannelUpdate) *lnrpc.ChannelUpdate {
|
|||||||
func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
||||||
*lnrpc.Payment, error) {
|
*lnrpc.Payment, error) {
|
||||||
|
|
||||||
// Fetch the payment's route and preimage. If no HTLC was
|
// Fetch the payment's preimage and the total paid in fees.
|
||||||
// successful, an empty route and preimage will be used.
|
|
||||||
var (
|
var (
|
||||||
route route.Route
|
fee lnwire.MilliSatoshi
|
||||||
preimage lntypes.Preimage
|
preimage lntypes.Preimage
|
||||||
)
|
)
|
||||||
for _, htlc := range payment.HTLCs {
|
for _, htlc := range payment.HTLCs {
|
||||||
// Display the last route attempted.
|
|
||||||
route = htlc.Route
|
|
||||||
|
|
||||||
// If any of the htlcs have settled, extract a valid
|
// If any of the htlcs have settled, extract a valid
|
||||||
// preimage.
|
// preimage.
|
||||||
if htlc.Settle != nil {
|
if htlc.Settle != nil {
|
||||||
preimage = htlc.Settle.Preimage
|
preimage = htlc.Settle.Preimage
|
||||||
|
fee += htlc.Route.TotalFees()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,9 +1144,9 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
|||||||
ValueSat: satValue,
|
ValueSat: satValue,
|
||||||
CreationDate: payment.Info.CreationTime.Unix(),
|
CreationDate: payment.Info.CreationTime.Unix(),
|
||||||
CreationTimeNs: creationTimeNS,
|
CreationTimeNs: creationTimeNS,
|
||||||
Fee: int64(route.TotalFees().ToSatoshis()),
|
Fee: int64(fee.ToSatoshis()),
|
||||||
FeeSat: int64(route.TotalFees().ToSatoshis()),
|
FeeSat: int64(fee.ToSatoshis()),
|
||||||
FeeMsat: int64(route.TotalFees()),
|
FeeMsat: int64(fee),
|
||||||
PaymentPreimage: hex.EncodeToString(preimage[:]),
|
PaymentPreimage: hex.EncodeToString(preimage[:]),
|
||||||
PaymentRequest: string(payment.Info.PaymentRequest),
|
PaymentRequest: string(payment.Info.PaymentRequest),
|
||||||
Status: status,
|
Status: status,
|
||||||
|
Loading…
Reference in New Issue
Block a user