mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 02:02:10 +02:00
multi: Inbound fees are retained when not provided
Fixes the problem that inbound base fee and fee rate are overwritten with 0 if they are not specified in PolicyUpdateRequest. This ensures backward compatibility with older rpc clients that do not yet support the inbound feature.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/discovery"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -105,6 +106,14 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
|
||||
Edge: edge,
|
||||
})
|
||||
|
||||
// Extract inbound fees from the ExtraOpaqueData.
|
||||
var inboundWireFee lnwire.Fee
|
||||
_, err = edge.ExtraOpaqueData.ExtractRecords(&inboundWireFee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inboundFee := models.NewInboundFeeFromWire(inboundWireFee)
|
||||
|
||||
// Add updated policy to list of policies to send to switch.
|
||||
policiesToUpdate[info.ChannelPoint] = models.ForwardingPolicy{
|
||||
BaseFee: edge.FeeBaseMSat,
|
||||
@@ -112,7 +121,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
|
||||
TimeLockDelta: uint32(edge.TimeLockDelta),
|
||||
MinHTLCOut: edge.MinHTLC,
|
||||
MaxHTLC: edge.MaxHTLC,
|
||||
InboundFee: newSchema.InboundFee,
|
||||
InboundFee: inboundFee,
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -182,8 +191,15 @@ func (r *Manager) updateEdge(tx kvdb.RTx, chanPoint wire.OutPoint,
|
||||
newSchema.FeeRate,
|
||||
)
|
||||
|
||||
inboundFee := newSchema.InboundFee.ToWire()
|
||||
if err := edge.ExtraOpaqueData.PackRecords(&inboundFee); err != nil {
|
||||
// If inbound fees are set, we update the edge with them.
|
||||
err := fn.MapOptionZ(newSchema.InboundFee,
|
||||
func(f models.InboundFee) error {
|
||||
inboundWireFee := f.ToWire()
|
||||
return edge.ExtraOpaqueData.PackRecords(
|
||||
&inboundWireFee,
|
||||
)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user