-
Couldn't load subscription status.
- Fork 2.2k
Aux Closer: Move coop-close aux finalization to chain watcher #10289
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
GeorgeTsagk
wants to merge
3
commits into
lightningnetwork:master
Choose a base branch
from
GeorgeTsagk:move-aux-closer
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.
+215
−27
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
| "github.com/lightningnetwork/lnd/lnutils" | ||
| "github.com/lightningnetwork/lnd/lnwallet" | ||
| "github.com/lightningnetwork/lnd/lnwire" | ||
| "github.com/lightningnetwork/lnd/tlv" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -37,6 +38,77 @@ const ( | |
| maxCommitPointPollTimeout = 10 * time.Minute | ||
| ) | ||
|
|
||
| // CloseOutput represents an output that should be included in the close | ||
| // transaction. | ||
| type CloseOutput struct { | ||
| // Amt is the amount of the output. | ||
| Amt btcutil.Amount | ||
|
|
||
| // DustLimit is the dust limit for the local node. | ||
| DustLimit btcutil.Amount | ||
|
|
||
| // PkScript is the script that should be used to pay to the output. | ||
| PkScript []byte | ||
|
|
||
| // ShutdownRecords is the set of custom records that may result in | ||
| // extra close outputs being added. | ||
| ShutdownRecords lnwire.CustomRecords | ||
| } | ||
|
|
||
| // AuxShutdownReq is used to request a set of extra custom records to include | ||
| // in the shutdown message. | ||
| type AuxShutdownReq struct { | ||
| // ChanPoint is the channel point of the channel that is being shut | ||
| // down. | ||
| ChanPoint wire.OutPoint | ||
|
|
||
| // ShortChanID is the short channel ID of the channel that is being | ||
| // closed. | ||
| ShortChanID lnwire.ShortChannelID | ||
|
|
||
| // Initiator is true if the local node is the initiator of the channel. | ||
| Initiator bool | ||
|
|
||
| // InternalKey is the internal key for the shutdown addr. This will | ||
| // only be set for taproot shutdown addrs. | ||
| InternalKey fn.Option[btcec.PublicKey] | ||
|
|
||
| // CommitBlob is the blob that was included in the last commitment. | ||
| CommitBlob fn.Option[tlv.Blob] | ||
|
|
||
| // FundingBlob is the blob that was included in the funding state. | ||
| FundingBlob fn.Option[tlv.Blob] | ||
| } | ||
|
|
||
| // AuxCloseDesc is used to describe the channel close that is being performed. | ||
| type AuxCloseDesc struct { | ||
|
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. These types are duplicated from |
||
| AuxShutdownReq | ||
|
|
||
| // CloseFee is the closing fee to be paid for this state. | ||
| CloseFee btcutil.Amount | ||
|
|
||
| // CommitFee is the fee that was paid for the last commitment. | ||
| CommitFee btcutil.Amount | ||
|
|
||
| // LocalCloseOutput is the output that the local node should be paid | ||
| // to. This is None if the local party will not have an output on the | ||
| // co-op close transaction. | ||
| LocalCloseOutput fn.Option[CloseOutput] | ||
|
|
||
| // RemoteCloseOutput is the output that the remote node should be paid | ||
| // to. This will be None if the remote party will not have an output on | ||
| // the co-op close transaction. | ||
| RemoteCloseOutput fn.Option[CloseOutput] | ||
| } | ||
|
|
||
| // AuxChanCloser is used to allow an external caller to finalize a cooperative | ||
| // channel close. | ||
| type AuxChanCloser interface { | ||
| // FinalizeClose is called after the close transaction has been agreed | ||
| // upon and confirmed. | ||
| FinalizeClose(desc AuxCloseDesc, closeTx *wire.MsgTx) error | ||
| } | ||
|
|
||
| // LocalUnilateralCloseInfo encapsulates all the information we need to act on | ||
| // a local force close that gets confirmed. | ||
| type LocalUnilateralCloseInfo struct { | ||
|
|
@@ -229,6 +301,9 @@ type chainWatcherConfig struct { | |
|
|
||
| // auxResolver is used to supplement contract resolution. | ||
| auxResolver fn.Option[lnwallet.AuxContractResolver] | ||
|
|
||
| // auxCloser is used to finalize cooperative closes. | ||
| auxCloser fn.Option[AuxChanCloser] | ||
| } | ||
|
|
||
| // chainWatcher is a system that's assigned to every active channel. The duty | ||
|
|
||
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.
Consider refactoring these types into a shared package. e.g:
lnwallet/chantypesThis would avoid the duplication and the circular dependency. 🦅 🦅 🪨💨