lnwallet/chancloser: add state transitions for new protofsm rbf closer

In this commit, we add the state transitions for the new protofsm based
RBF chan closer. The underlying protocol is a new asymmetric co-op close
process, wherein either side can initiate a chan closer, and use their
settled funds to pay for fees within the channel.
This commit is contained in:
Olaoluwa Osuntokun 2024-01-31 19:23:19 -08:00
parent f6525c9e7d
commit e47a632745
No known key found for this signature in database
GPG Key ID: 90525F7DEEE0AD86
4 changed files with 1057 additions and 12 deletions

View File

@ -539,8 +539,8 @@ func (c *ChanCloser) AuxOutputs() fn.Option[AuxCloseOutputs] {
// upfront script is set, we check whether it matches the script provided by
// our peer. If they do not match, we use the disconnect function provided to
// disconnect from the peer.
func validateShutdownScript(disconnect func() error, upfrontScript,
peerScript lnwire.DeliveryAddress, netParams *chaincfg.Params) error {
func validateShutdownScript(upfrontScript, peerScript lnwire.DeliveryAddress,
netParams *chaincfg.Params) error {
// Either way, we'll make sure that the script passed meets our
// standards. The upfrontScript should have already been checked at an
@ -568,12 +568,6 @@ func validateShutdownScript(disconnect func() error, upfrontScript,
chancloserLog.Warnf("peer's script: %x does not match upfront "+
"shutdown script: %x", peerScript, upfrontScript)
// Disconnect from the peer because they have violated option upfront
// shutdown.
if err := disconnect(); err != nil {
return err
}
return ErrUpfrontShutdownScriptMismatch
}
@ -630,7 +624,6 @@ func (c *ChanCloser) ReceiveShutdown(msg lnwire.Shutdown) (
// If the remote node opened the channel with option upfront
// shutdown script, check that the script they provided matches.
if err := validateShutdownScript(
c.cfg.Disconnect,
c.cfg.Channel.RemoteUpfrontShutdownScript(),
msg.Address, c.cfg.ChainParams,
); err != nil {
@ -681,7 +674,6 @@ func (c *ChanCloser) ReceiveShutdown(msg lnwire.Shutdown) (
// If the remote node opened the channel with option upfront
// shutdown script, check that the script they provided matches.
if err := validateShutdownScript(
c.cfg.Disconnect,
c.cfg.Channel.RemoteUpfrontShutdownScript(),
msg.Address, c.cfg.ChainParams,
); err != nil {

View File

@ -129,8 +129,8 @@ func TestMaybeMatchScript(t *testing.T) {
t.Parallel()
err := validateShutdownScript(
func() error { return nil }, test.upfrontScript,
test.shutdownScript, &chaincfg.SimNetParams,
test.upfrontScript, test.shutdownScript,
&chaincfg.SimNetParams,
)
if err != test.expectedErr {

View File

@ -250,6 +250,11 @@ type ChanStateObserver interface {
// new outgoing add messages.
DisableOutgoingAdds() error
// DisableChannel attempts to disable a channel (marking it ineligible
// to forward), and also sends out a network update to disable the
// channel.
DisableChannel() error
// MarkCoopBroadcasted persistently marks that the channel close
// transaction has been broadcast.
MarkCoopBroadcasted(*wire.MsgTx, bool) error

File diff suppressed because it is too large Load Diff