chancloser: always set close output

We always need to set the close output in order for us to be able
to calculate the closing keys. Especially if there is only a dust
balance in BTC terms but perhaps a valuable amount in custom channel
funds.
This commit is contained in:
Oliver Gugger
2024-06-07 15:38:12 +02:00
parent 53dbd1ee66
commit d6e1d19fa1

View File

@ -432,17 +432,16 @@ func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) {
return nil, err return nil, err
} }
// If the local balance isn't dust, then we'll track that we have an // We'll track our local close output, even if it's dust in BTC terms,
// active close output. // it might still carry value in custom channel terms.
if isDust, dustAmt := c.cfg.Channel.LocalBalanceDust(); !isDust { _, dustAmt := c.cfg.Channel.LocalBalanceDust()
localBalance, _ := c.cfg.Channel.CommitBalances() localBalance, _ := c.cfg.Channel.CommitBalances()
c.localCloseOutput = fn.Some(CloseOutput{ c.localCloseOutput = fn.Some(CloseOutput{
Amt: localBalance, Amt: localBalance,
DustLimit: dustAmt, DustLimit: dustAmt,
PkScript: c.localDeliveryScript, PkScript: c.localDeliveryScript,
ShutdownRecords: shutdown.CustomRecords, ShutdownRecords: shutdown.CustomRecords,
}) })
}
return shutdown, nil return shutdown, nil
} }
@ -587,17 +586,16 @@ func (c *ChanCloser) ReceiveShutdown(msg lnwire.Shutdown) (
noShutdown := fn.None[lnwire.Shutdown]() noShutdown := fn.None[lnwire.Shutdown]()
// If the remote balance isn't dust, then we'll track that they have an // We'll track their remote close output, even if it's dust in BTC
// active close output. // terms, it might still carry value in custom channel terms.
if isDust, dustAmt := c.cfg.Channel.RemoteBalanceDust(); !isDust { _, dustAmt := c.cfg.Channel.RemoteBalanceDust()
_, remoteBalance := c.cfg.Channel.CommitBalances() _, remoteBalance := c.cfg.Channel.CommitBalances()
c.remoteCloseOutput = fn.Some(CloseOutput{ c.remoteCloseOutput = fn.Some(CloseOutput{
Amt: remoteBalance, Amt: remoteBalance,
DustLimit: dustAmt, DustLimit: dustAmt,
PkScript: msg.Address, PkScript: msg.Address,
ShutdownRecords: msg.CustomRecords, ShutdownRecords: msg.CustomRecords,
}) })
}
switch c.state { switch c.state {
// If we're in the close idle state, and we're receiving a channel // If we're in the close idle state, and we're receiving a channel