mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-12 07:08:24 +01:00
htlcswitch: handle update_fee message received from peer.
This commit makes the channellink update a channel's fee if an update_fee message is received from the peer.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
ebe05f6568
commit
f4db249cb8
@@ -638,6 +638,15 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
||||
}
|
||||
}
|
||||
}()
|
||||
case *lnwire.UpdateFee:
|
||||
// We received fee update from peer. If we are the initator we will fail the
|
||||
// channel, if not we will apply the update.
|
||||
fee := msg.FeePerKw
|
||||
if err := l.channel.ReceiveUpdateFee(fee); err != nil {
|
||||
log.Errorf("error receiving fee update: %v", err)
|
||||
l.cfg.Peer.Disconnect()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,6 +819,19 @@ func (l *channelLink) HandleChannelUpdate(message lnwire.Message) {
|
||||
}
|
||||
}
|
||||
|
||||
// updateChannelFee updates the commitment fee-per-kw on this channel by
|
||||
// committing to an update_fee message.
|
||||
func (l *channelLink) updateChannelFee(feePerKw btcutil.Amount) error {
|
||||
// Update local fee.
|
||||
if err := l.channel.UpdateFee(feePerKw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Send fee update to remote.
|
||||
msg := lnwire.NewUpdateFee(l.ChanID(), feePerKw)
|
||||
return l.cfg.Peer.SendMessage(msg)
|
||||
}
|
||||
|
||||
// processLockedInHtlcs serially processes each of the log updates which have
|
||||
// been "locked-in". An HTLC is considered locked-in once it has been fully
|
||||
// committed to in both the remote and local commitment state. Once a channel
|
||||
|
||||
Reference in New Issue
Block a user