diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index 3dd70247d..a3f4ff9a9 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -170,6 +170,18 @@ type ChannelUpdateHandler interface { // will only ever be called once. If no CommitSig is owed in the // argument's LinkDirection, then we will call this hook immediately. OnCommitOnce(LinkDirection, func()) + + // InitStfu allows us to initiate quiescence on this link. It returns + // a receive only channel that will block until quiescence has been + // achieved, or definitively fails. The return value is the + // ChannelParty who holds the role of initiator or Err if the operation + // fails. + // + // This operation has been added to allow channels to be quiesced via + // RPC. It may be removed or reworked in the future as RPC initiated + // quiescence is a holdover until we have downstream protocols that use + // it. + InitStfu() <-chan fn.Result[lntypes.ChannelParty] } // CommitHookID is a value that is used to uniquely identify hooks in the diff --git a/htlcswitch/link.go b/htlcswitch/link.go index cf9ba8ba9..442522de1 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -737,6 +737,22 @@ func (l *channelLink) OnCommitOnce(direction LinkDirection, hook func()) { } } +// InitStfu allows us to initiate quiescence on this link. It returns a receive +// only channel that will block until quiescence has been achieved, or +// definitively fails. +// +// This operation has been added to allow channels to be quiesced via RPC. It +// may be removed or reworked in the future as RPC initiated quiescence is a +// holdover until we have downstream protocols that use it. +func (l *channelLink) InitStfu() <-chan fn.Result[lntypes.ChannelParty] { + // TODO(proofofkeags): Implement + c := make(chan fn.Result[lntypes.ChannelParty], 1) + + c <- fn.Errf[lntypes.ChannelParty]("InitStfu not yet implemented") + + return c +} + // isReestablished returns true if the link has successfully completed the // channel reestablishment dance. func (l *channelLink) isReestablished() bool { diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 6de60b38a..37bf4c6ef 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -950,6 +950,14 @@ func (f *mockChannelLink) OnFlushedOnce(func()) { func (f *mockChannelLink) OnCommitOnce(LinkDirection, func()) { // TODO(proofofkeags): Implement } +func (f *mockChannelLink) InitStfu() <-chan fn.Result[lntypes.ChannelParty] { + // TODO(proofofkeags): Implement + c := make(chan fn.Result[lntypes.ChannelParty], 1) + + c <- fn.Errf[lntypes.ChannelParty]("InitStfu not implemented") + + return c +} func (f *mockChannelLink) FundingCustomBlob() fn.Option[tlv.Blob] { return fn.None[tlv.Blob]() diff --git a/peer/test_utils.go b/peer/test_utils.go index 1a6235590..9034bb5a9 100644 --- a/peer/test_utils.go +++ b/peer/test_utils.go @@ -24,6 +24,7 @@ import ( "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lntest/channels" "github.com/lightningnetwork/lnd/lntest/mock" + "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" @@ -477,6 +478,14 @@ func (m *mockUpdateHandler) OnCommitOnce( hook() } +func (m *mockUpdateHandler) InitStfu() <-chan fn.Result[lntypes.ChannelParty] { + // TODO(proofofkeags): Implement + c := make(chan fn.Result[lntypes.ChannelParty], 1) + + c <- fn.Errf[lntypes.ChannelParty]("InitStfu not yet implemented") + + return c +} func newMockConn(t *testing.T, expectedMessages int) *mockMessageConn { return &mockMessageConn{