-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[3/5]: multi: add new AuxFundingController for custom external funding flows #8622
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e5e5da3
log+protofsm: add new abstract message router
Roasbeef 371e014
peer: update readHandler to dispatch to msgRouter if set
Roasbeef 5866287
multi: make MsgRouter available in the ImplementationCfg
Roasbeef 8ba3f3a
funding: add new type alias for PendingChanID = [32]byte
Roasbeef dd357fb
funding: use atomic.Uint64 for chanIDNonce
Roasbeef f2c2a82
lnwallet: add new AuxFundingDesc struct
Roasbeef 54bbc25
lnwallet: use AuxFundingDesc to populate all custom chan info
Roasbeef 2f6e7ef
funding: create new AuxFundingController interface
Roasbeef bb71c49
config+serer: add AuxFundingController as top level cfg option
Roasbeef a841a9b
lnwallet: add TaprootInternalKey method to ShimIntent
Roasbeef 28cb488
lnwallet: for PsbtIntent return the internal key in the POutput
Roasbeef 26ab758
funding+lnwallet: only blind tapscript root early in funding flow
Roasbeef bf307d3
funding+lnwallet: finish hook up new aux funding flow
Roasbeef 6b78499
multi: add tapscript root to gossip message
guggero a350ccd
funding: inform aux controller about channel ready/finalize
guggero 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package funding | ||
|
|
||
| import ( | ||
| "github.com/btcsuite/btcd/chaincfg/chainhash" | ||
| "github.com/lightningnetwork/lnd/channeldb" | ||
| "github.com/lightningnetwork/lnd/fn" | ||
| "github.com/lightningnetwork/lnd/lnwallet" | ||
| "github.com/lightningnetwork/lnd/protofsm" | ||
| ) | ||
|
|
||
| // AuxFundingController permits the implementation of the funding of custom | ||
| // channels types. The controller serves as a MsgEndpoint which allows it to | ||
| // intercept custom messages, or even the regular funding messages. The | ||
| // controller might also pass along an aux funding desc based on an existing | ||
| // pending channel ID. | ||
| type AuxFundingController interface { | ||
| // MsgEndpoint is the embedded interface that signals that the funding | ||
| // controller is also a message endpoint. This'll allow it to handle | ||
| // custom messages specific to the funding type. | ||
| protofsm.MsgEndpoint | ||
|
|
||
| // DescFromPendingChanID takes a pending channel ID, that may already be | ||
| // known due to prior custom channel messages, and maybe returns an aux | ||
| // funding desc which can be used to modify how a channel is funded. | ||
| DescFromPendingChanID(pid PendingChanID, | ||
| openChan *channeldb.OpenChannel, | ||
| localKeyRing, remoteKeyRing lnwallet.CommitmentKeyRing, | ||
| initiator bool) (fn.Option[lnwallet.AuxFundingDesc], error) | ||
|
|
||
| // DeriveTapscriptRoot takes a pending channel ID and maybe returns a | ||
| // tapscript root that should be used when creating any MuSig2 sessions | ||
| // for a channel. | ||
| DeriveTapscriptRoot(PendingChanID) (fn.Option[chainhash.Hash], error) | ||
|
|
||
| // ChannelReady is called when a channel has been fully opened (multiple | ||
| // confirmations) and is ready to be used. This can be used to perform | ||
| // any final setup or cleanup. | ||
| ChannelReady(openChan *channeldb.OpenChannel) error | ||
|
|
||
| // ChannelFinalized is called when a channel has been fully finalized. | ||
| // In this state, we've received the commitment sig from the remote | ||
| // party, so we are safe to broadcast the funding transaction. | ||
| ChannelFinalized(PendingChanID) error | ||
| } | ||
|
|
||
| // descFromPendingChanID takes a pending channel ID, that may already be known | ||
| // due to prior custom channel messages, and maybe returns an aux funding desc | ||
| // which can be used to modify how a channel is funded. | ||
| func descFromPendingChanID(controller fn.Option[AuxFundingController], | ||
| chanID PendingChanID, openChan *channeldb.OpenChannel, | ||
| localKeyRing, remoteKeyRing lnwallet.CommitmentKeyRing, | ||
| initiator bool) (fn.Option[lnwallet.AuxFundingDesc], error) { | ||
|
|
||
| var result fn.Option[lnwallet.AuxFundingDesc] | ||
| mapErr := fn.MapOptionZ(controller, func(c AuxFundingController) error { | ||
| var err error | ||
| result, err = c.DescFromPendingChanID( | ||
| chanID, openChan, localKeyRing, remoteKeyRing, | ||
| initiator, | ||
| ) | ||
|
|
||
| return err | ||
| }) | ||
|
|
||
| return result, mapErr | ||
| } | ||
|
|
||
| // deriveTapscriptRoot takes a pending channel ID and maybe returns a | ||
| // tapscript root that should be used when creating any MuSig2 sessions for a | ||
| // channel. | ||
| func deriveTapscriptRoot(controller fn.Option[AuxFundingController], | ||
| chanID PendingChanID) (fn.Option[chainhash.Hash], error) { | ||
|
|
||
| var result fn.Option[chainhash.Hash] | ||
| mapErr := fn.MapOptionZ(controller, func(c AuxFundingController) error { | ||
| var err error | ||
| result, err = c.DeriveTapscriptRoot(chanID) | ||
| return err | ||
| }) | ||
|
|
||
| return result, mapErr | ||
| } |
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.
for other nodes in the network what purpose does this field have?
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.
For being able to verify the
pkScriptof the channel. Without the tapscript root the validation nodes would assume 2-of-2 MuSig2 with BIP-0086 tweak.