mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 13:27:56 +01:00
peer: refactor createChanCloser to use ChannelParty
This commit is contained in:
parent
0996e4f163
commit
1d65f5bd12
@ -1070,7 +1070,7 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
||||
|
||||
chanCloser, err := p.createChanCloser(
|
||||
lnChan, info.DeliveryScript.Val, feePerKw, nil,
|
||||
info.LocalInitiator.Val,
|
||||
info.Closer(),
|
||||
)
|
||||
if err != nil {
|
||||
shutdownInfoErr = fmt.Errorf("unable to "+
|
||||
@ -2733,7 +2733,7 @@ func (p *Brontide) fetchActiveChanCloser(chanID lnwire.ChannelID) (
|
||||
}
|
||||
|
||||
chanCloser, err = p.createChanCloser(
|
||||
channel, deliveryScript, feePerKw, nil, false,
|
||||
channel, deliveryScript, feePerKw, nil, lntypes.Remote,
|
||||
)
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to create chan closer: %v", err)
|
||||
@ -2970,12 +2970,13 @@ func (p *Brontide) restartCoopClose(lnChan *lnwallet.LightningChannel) (
|
||||
|
||||
// Determine whether we or the peer are the initiator of the coop
|
||||
// close attempt by looking at the channel's status.
|
||||
locallyInitiated := c.HasChanStatus(
|
||||
channeldb.ChanStatusLocalCloseInitiator,
|
||||
)
|
||||
closingParty := lntypes.Remote
|
||||
if c.HasChanStatus(channeldb.ChanStatusLocalCloseInitiator) {
|
||||
closingParty = lntypes.Local
|
||||
}
|
||||
|
||||
chanCloser, err := p.createChanCloser(
|
||||
lnChan, deliveryScript, feePerKw, nil, locallyInitiated,
|
||||
lnChan, deliveryScript, feePerKw, nil, closingParty,
|
||||
)
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to create chan closer: %v", err)
|
||||
@ -3004,7 +3005,7 @@ func (p *Brontide) restartCoopClose(lnChan *lnwallet.LightningChannel) (
|
||||
func (p *Brontide) createChanCloser(channel *lnwallet.LightningChannel,
|
||||
deliveryScript lnwire.DeliveryAddress, fee chainfee.SatPerKWeight,
|
||||
req *htlcswitch.ChanClose,
|
||||
locallyInitiated bool) (*chancloser.ChanCloser, error) {
|
||||
closer lntypes.ChannelParty) (*chancloser.ChanCloser, error) {
|
||||
|
||||
_, startingHeight, err := p.cfg.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
@ -3018,10 +3019,6 @@ func (p *Brontide) createChanCloser(channel *lnwallet.LightningChannel,
|
||||
maxFee = req.MaxFee
|
||||
}
|
||||
|
||||
closer := lntypes.Remote
|
||||
if locallyInitiated {
|
||||
closer = lntypes.Local
|
||||
}
|
||||
chanCloser := chancloser.NewChanCloser(
|
||||
chancloser.ChanCloseCfg{
|
||||
Channel: channel,
|
||||
@ -3101,7 +3098,8 @@ func (p *Brontide) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
||||
}
|
||||
|
||||
chanCloser, err := p.createChanCloser(
|
||||
channel, deliveryScript, req.TargetFeePerKw, req, true,
|
||||
channel, deliveryScript, req.TargetFeePerKw, req,
|
||||
lntypes.Local,
|
||||
)
|
||||
if err != nil {
|
||||
p.log.Errorf(err.Error())
|
||||
|
Loading…
Reference in New Issue
Block a user