mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
multi: thread through the new max fee field for co-op close
In this commit, we parse the new max fee field, and pass it through the switch, all the way to the peer where it's ultimately passed into the chan closer state machine.
This commit is contained in:
parent
c791b18cc0
commit
1e556aa189
@ -106,6 +106,12 @@ type ChanClose struct {
|
|||||||
// process for the cooperative closure transaction kicks off.
|
// process for the cooperative closure transaction kicks off.
|
||||||
TargetFeePerKw chainfee.SatPerKWeight
|
TargetFeePerKw chainfee.SatPerKWeight
|
||||||
|
|
||||||
|
// MaxFee is the highest fee the caller is willing to pay.
|
||||||
|
//
|
||||||
|
// NOTE: This field is only respected if the caller is the initiator of
|
||||||
|
// the channel.
|
||||||
|
MaxFee chainfee.SatPerKWeight
|
||||||
|
|
||||||
// DeliveryScript is an optional delivery script to pay funds out to.
|
// DeliveryScript is an optional delivery script to pay funds out to.
|
||||||
DeliveryScript lnwire.DeliveryAddress
|
DeliveryScript lnwire.DeliveryAddress
|
||||||
|
|
||||||
@ -1656,7 +1662,7 @@ func (s *Switch) teardownCircuit(pkt *htlcPacket) error {
|
|||||||
// optional parameter which sets a user specified script to close out to.
|
// optional parameter which sets a user specified script to close out to.
|
||||||
func (s *Switch) CloseLink(chanPoint *wire.OutPoint,
|
func (s *Switch) CloseLink(chanPoint *wire.OutPoint,
|
||||||
closeType contractcourt.ChannelCloseType,
|
closeType contractcourt.ChannelCloseType,
|
||||||
targetFeePerKw chainfee.SatPerKWeight,
|
targetFeePerKw, maxFee chainfee.SatPerKWeight,
|
||||||
deliveryScript lnwire.DeliveryAddress) (chan interface{}, chan error) {
|
deliveryScript lnwire.DeliveryAddress) (chan interface{}, chan error) {
|
||||||
|
|
||||||
// TODO(roasbeef) abstract out the close updates.
|
// TODO(roasbeef) abstract out the close updates.
|
||||||
@ -1668,6 +1674,7 @@ func (s *Switch) CloseLink(chanPoint *wire.OutPoint,
|
|||||||
ChanPoint: chanPoint,
|
ChanPoint: chanPoint,
|
||||||
Updates: updateChan,
|
Updates: updateChan,
|
||||||
TargetFeePerKw: targetFeePerKw,
|
TargetFeePerKw: targetFeePerKw,
|
||||||
|
MaxFee: maxFee,
|
||||||
DeliveryScript: deliveryScript,
|
DeliveryScript: deliveryScript,
|
||||||
Err: errChan,
|
Err: errChan,
|
||||||
}
|
}
|
||||||
|
@ -2697,6 +2697,12 @@ func (p *Brontide) createChanCloser(channel *lnwallet.LightningChannel,
|
|||||||
return nil, fmt.Errorf("cannot obtain best block")
|
return nil, fmt.Errorf("cannot obtain best block")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The req will only be set if we initaited the co-op closing flow.
|
||||||
|
var maxFee chainfee.SatPerKWeight
|
||||||
|
if req != nil {
|
||||||
|
maxFee = req.MaxFee
|
||||||
|
}
|
||||||
|
|
||||||
chanCloser := chancloser.NewChanCloser(
|
chanCloser := chancloser.NewChanCloser(
|
||||||
chancloser.ChanCloseCfg{
|
chancloser.ChanCloseCfg{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
@ -2706,6 +2712,7 @@ func (p *Brontide) createChanCloser(channel *lnwallet.LightningChannel,
|
|||||||
op, false,
|
op, false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
MaxFee: maxFee,
|
||||||
Disconnect: func() error {
|
Disconnect: func() error {
|
||||||
return p.cfg.DisconnectPeer(p.IdentityKey())
|
return p.cfg.DisconnectPeer(p.IdentityKey())
|
||||||
},
|
},
|
||||||
|
@ -2508,9 +2508,12 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxFee := chainfee.SatPerKVByte(
|
||||||
|
in.MaxFeePerVbyte * 1000,
|
||||||
|
).FeePerKWeight()
|
||||||
updateChan, errChan = r.server.htlcSwitch.CloseLink(
|
updateChan, errChan = r.server.htlcSwitch.CloseLink(
|
||||||
chanPoint, contractcourt.CloseRegular, feeRate,
|
chanPoint, contractcourt.CloseRegular, feeRate,
|
||||||
deliveryScript,
|
maxFee, deliveryScript,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
@ -1034,7 +1034,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
// Instruct the switch to close the channel. Provide no close out
|
// Instruct the switch to close the channel. Provide no close out
|
||||||
// delivery script or target fee per kw because user input is not
|
// delivery script or target fee per kw because user input is not
|
||||||
// available when the remote peer closes the channel.
|
// available when the remote peer closes the channel.
|
||||||
s.htlcSwitch.CloseLink(chanPoint, closureType, 0, nil)
|
s.htlcSwitch.CloseLink(chanPoint, closureType, 0, 0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We will use the following channel to reliably hand off contract
|
// We will use the following channel to reliably hand off contract
|
||||||
|
Loading…
Reference in New Issue
Block a user