-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add aux channel closer support to RBF cooperative close flow #10817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
haanhvu
wants to merge
4
commits into
lightningnetwork:master
Choose a base branch
from
haanhvu:issue9663-3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+677
−15
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
533e5ab
chancloser, peer: plumb aux close outputs and shutdown custom records…
haanhvu 32260fb
config, lncfg: allow injecting mock AuxChanCloser in dev builds
haanhvu 42b82f4
itest: add RBF coop close test coverage for aux close outputs
haanhvu d8c7961
docs: add release note
haanhvu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,13 @@ package lncfg | |
| import ( | ||
| "time" | ||
|
|
||
| "github.com/btcsuite/btcd/wire" | ||
| "github.com/lightningnetwork/lnd/fn/v2" | ||
| "github.com/lightningnetwork/lnd/lnwallet" | ||
| "github.com/lightningnetwork/lnd/lnwallet/chancloser" | ||
| "github.com/lightningnetwork/lnd/lnwallet/chanfunding" | ||
| "github.com/lightningnetwork/lnd/lnwallet/types" | ||
| "github.com/lightningnetwork/lnd/lnwire" | ||
| ) | ||
|
|
||
| // IsDevBuild returns a bool to indicate whether we are in a development | ||
|
|
@@ -30,6 +35,63 @@ type DevConfig struct { | |
| UnsafeConnect bool `long:"unsafeconnect" description:"Allow the rpcserver to connect to a peer even if there's already a connection."` | ||
| ForceChannelCloseConfs uint32 `long:"force-channel-close-confs" description:"Force a specific number of confirmations for channel closes (dev/test only)"` | ||
| MinFwdHistoryAge time.Duration `long:"min-fwd-history-age" description:"Minimum age of forwarding events before they can be deleted via DeleteForwardingHistory (dev/test only, default: 1h)"` | ||
| MockAuxChanCloser bool `long:"mock-aux-chan-closer" description:"Set the mock AuxChanCloser for tests."` | ||
| } | ||
|
|
||
| // NeedMockAuxChanCloser returns the config value for MockAuxChanCloser, | ||
| // indicating whether the integration test needs a mock AuxChanCloser. | ||
| func (d *DevConfig) NeedMockAuxChanCloser() bool { | ||
| return d.MockAuxChanCloser | ||
| } | ||
|
|
||
| // GetMockAuxChanCloserValueForTest returns the mock AuxChanCloser value | ||
| // that can be used in integration tests. | ||
| // | ||
| //nolint:ll | ||
| func (d *DevConfig) GetMockAuxChanCloserValueForTest() fn.Option[chancloser.AuxChanCloser] { | ||
| return fn.Some[chancloser.AuxChanCloser](&mockAuxChanCloser{}) | ||
| } | ||
|
|
||
| // Mock implementation for AuxChanCloser. | ||
| type mockAuxChanCloser struct{} | ||
|
|
||
| func (m *mockAuxChanCloser) ShutdownBlob( | ||
| req types.AuxShutdownReq, | ||
| ) (fn.Option[lnwire.CustomRecords], error) { | ||
|
|
||
| return fn.None[lnwire.CustomRecords](), nil | ||
| } | ||
|
|
||
| func (m *mockAuxChanCloser) AuxCloseOutputs( | ||
| desc types.AuxCloseDesc, | ||
| ) (fn.Option[chancloser.AuxCloseOutputs], error) { | ||
|
|
||
| return fn.Some[chancloser.AuxCloseOutputs]( | ||
| chancloser.AuxCloseOutputs{ | ||
| ExtraCloseOutputs: []lnwallet.CloseOutput{ | ||
| { | ||
| TxOut: wire.TxOut{ | ||
| Value: 50_000, | ||
| PkScript: []byte{ | ||
| 0x00, 0x14, 0x11, 0x11, | ||
| 0x11, 0x11, 0x11, 0x11, | ||
| 0x11, 0x11, 0x11, 0x11, | ||
| 0x11, 0x11, 0x11, 0x11, | ||
| 0x11, 0x11, 0x11, 0x11, | ||
| 0x11, 0x11, | ||
| }, | ||
| }, | ||
|
Comment on lines
+73
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| IsLocal: desc.Initiator, | ||
| }, | ||
| }, | ||
| }, | ||
| ), nil | ||
| } | ||
|
|
||
| func (m *mockAuxChanCloser) FinalizeClose(desc types.AuxCloseDesc, | ||
| closeTx *wire.MsgTx) error { | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // ChannelReadyWait returns the config value `ProcessChannelReadyWait`. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
ifblock is a duplicate of the one on lines 1959-1962. To improve maintainability, you could refactorImplementationConfigto avoid this code repetition. One way is to declareimplCfgbefore the mainif/elseblock, initialize it within each branch, and then have a single block to setAuxChanCloserbefore returning.