lnwallet: use AuxFundingDesc to populate all custom chan info
With this commit, we'll now populate all the custom channel information within the OpenChannel and ChannelCommitment structs.
This commit is contained in:
1 parent
116a6430f0
commit
72beb7955d
1 file changed
+51
-6
+51
-6
@@ -239,9 +239,8 @@ type InitFundingReserveMsg struct {
|
|||||||
// channel that will be useful to our future selves.
|
// channel that will be useful to our future selves.
|
||||||
Memo []byte
|
Memo []byte
|
||||||
|
|
||||||
// TapscriptRoot is the root of the tapscript tree that will be used to
|
// TapscriptRoot is an optional tapscript root that if provided, will
|
||||||
// create the funding output. This is an optional field that should
|
// be used to create the combined key for musig2 based channels.
|
||||||
// only be set for taproot channels.
|
|
||||||
TapscriptRoot fn.Option[chainhash.Hash]
|
TapscriptRoot fn.Option[chainhash.Hash]
|
||||||
|
|
||||||
// err is a channel in which all errors will be sent across. Will be
|
// err is a channel in which all errors will be sent across. Will be
|
||||||
@@ -292,6 +291,10 @@ type addContributionMsg struct {
|
|||||||
type continueContributionMsg struct {
|
type continueContributionMsg struct {
|
||||||
pendingFundingID uint64
|
pendingFundingID uint64
|
||||||
|
|
||||||
|
// auxFundingDesc is an optional descriptor that contains information
|
||||||
|
// about the custom channel funding flow.
|
||||||
|
auxFundingDesc fn.Option[AuxFundingDesc]
|
||||||
|
|
||||||
// NOTE: In order to avoid deadlocks, this channel MUST be buffered.
|
// NOTE: In order to avoid deadlocks, this channel MUST be buffered.
|
||||||
err chan error
|
err chan error
|
||||||
}
|
}
|
||||||
@@ -347,6 +350,10 @@ type addCounterPartySigsMsg struct {
|
|||||||
type addSingleFunderSigsMsg struct {
|
type addSingleFunderSigsMsg struct {
|
||||||
pendingFundingID uint64
|
pendingFundingID uint64
|
||||||
|
|
||||||
|
// auxFundingDesc is an optional descriptor that contains information
|
||||||
|
// about the custom channel funding flow.
|
||||||
|
auxFundingDesc fn.Option[AuxFundingDesc]
|
||||||
|
|
||||||
// fundingOutpoint is the outpoint of the completed funding
|
// fundingOutpoint is the outpoint of the completed funding
|
||||||
// transaction as assembled by the workflow initiator.
|
// transaction as assembled by the workflow initiator.
|
||||||
fundingOutpoint *wire.OutPoint
|
fundingOutpoint *wire.OutPoint
|
||||||
@@ -1501,7 +1508,8 @@ func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMs
|
|||||||
// createCommitOpts is a struct that holds the options for creating a new
|
// createCommitOpts is a struct that holds the options for creating a new
|
||||||
// commitment transaction.
|
// commitment transaction.
|
||||||
type createCommitOpts struct {
|
type createCommitOpts struct {
|
||||||
auxLeaves fn.Option[CommitAuxLeaves]
|
localAuxLeaves fn.Option[CommitAuxLeaves]
|
||||||
|
remoteAuxLeaves fn.Option[CommitAuxLeaves]
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultCommitOpts returns a new createCommitOpts with default values.
|
// defaultCommitOpts returns a new createCommitOpts with default values.
|
||||||
@@ -1509,6 +1517,17 @@ func defaultCommitOpts() createCommitOpts {
|
|||||||
return createCommitOpts{}
|
return createCommitOpts{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithAuxLeaves is a functional option that can be used to set the aux leaves
|
||||||
|
// for a new commitment transaction.
|
||||||
|
func WithAuxLeaves(localLeaves,
|
||||||
|
remoteLeaves fn.Option[CommitAuxLeaves]) CreateCommitOpt {
|
||||||
|
|
||||||
|
return func(o *createCommitOpts) {
|
||||||
|
o.localAuxLeaves = localLeaves
|
||||||
|
o.remoteAuxLeaves = remoteLeaves
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CreateCommitOpt is a functional option that can be used to modify the way a
|
// CreateCommitOpt is a functional option that can be used to modify the way a
|
||||||
// new commitment transaction is created.
|
// new commitment transaction is created.
|
||||||
type CreateCommitOpt func(*createCommitOpts)
|
type CreateCommitOpt func(*createCommitOpts)
|
||||||
@@ -1542,7 +1561,7 @@ func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
|
|||||||
ourCommitTx, err := CreateCommitTx(
|
ourCommitTx, err := CreateCommitTx(
|
||||||
chanType, fundingTxIn, localCommitmentKeys, ourChanCfg,
|
chanType, fundingTxIn, localCommitmentKeys, ourChanCfg,
|
||||||
theirChanCfg, localBalance, remoteBalance, 0, initiator,
|
theirChanCfg, localBalance, remoteBalance, 0, initiator,
|
||||||
leaseExpiry, options.auxLeaves,
|
leaseExpiry, options.localAuxLeaves,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -1556,7 +1575,7 @@ func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
|
|||||||
theirCommitTx, err := CreateCommitTx(
|
theirCommitTx, err := CreateCommitTx(
|
||||||
chanType, fundingTxIn, remoteCommitmentKeys, theirChanCfg,
|
chanType, fundingTxIn, remoteCommitmentKeys, theirChanCfg,
|
||||||
ourChanCfg, remoteBalance, localBalance, 0, !initiator,
|
ourChanCfg, remoteBalance, localBalance, 0, !initiator,
|
||||||
leaseExpiry, options.auxLeaves,
|
leaseExpiry, options.remoteAuxLeaves,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -1899,6 +1918,18 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
|
|||||||
if pendingReservation.partialState.ChanType.HasLeaseExpiration() {
|
if pendingReservation.partialState.ChanType.HasLeaseExpiration() {
|
||||||
leaseExpiry = pendingReservation.partialState.ThawHeight
|
leaseExpiry = pendingReservation.partialState.ThawHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localAuxLeaves := fn.MapOption(
|
||||||
|
func(desc AuxFundingDesc) CommitAuxLeaves {
|
||||||
|
return desc.LocalInitAuxLeaves
|
||||||
|
},
|
||||||
|
)(req.auxFundingDesc)
|
||||||
|
remoteAuxLeaves := fn.MapOption(
|
||||||
|
func(desc AuxFundingDesc) CommitAuxLeaves {
|
||||||
|
return desc.RemoteInitAuxLeaves
|
||||||
|
},
|
||||||
|
)(req.auxFundingDesc)
|
||||||
|
|
||||||
ourCommitTx, theirCommitTx, err := CreateCommitmentTxns(
|
ourCommitTx, theirCommitTx, err := CreateCommitmentTxns(
|
||||||
localBalance, remoteBalance, ourContribution.ChannelConfig,
|
localBalance, remoteBalance, ourContribution.ChannelConfig,
|
||||||
theirContribution.ChannelConfig,
|
theirContribution.ChannelConfig,
|
||||||
@@ -1906,6 +1937,7 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
|
|||||||
theirContribution.FirstCommitmentPoint, fundingTxIn,
|
theirContribution.FirstCommitmentPoint, fundingTxIn,
|
||||||
pendingReservation.partialState.ChanType,
|
pendingReservation.partialState.ChanType,
|
||||||
pendingReservation.partialState.IsInitiator, leaseExpiry,
|
pendingReservation.partialState.IsInitiator, leaseExpiry,
|
||||||
|
WithAuxLeaves(localAuxLeaves, remoteAuxLeaves),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.err <- err
|
req.err <- err
|
||||||
@@ -2332,6 +2364,18 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
|
|||||||
if pendingReservation.partialState.ChanType.HasLeaseExpiration() {
|
if pendingReservation.partialState.ChanType.HasLeaseExpiration() {
|
||||||
leaseExpiry = pendingReservation.partialState.ThawHeight
|
leaseExpiry = pendingReservation.partialState.ThawHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localAuxLeaves := fn.MapOption(
|
||||||
|
func(desc AuxFundingDesc) CommitAuxLeaves {
|
||||||
|
return desc.LocalInitAuxLeaves
|
||||||
|
},
|
||||||
|
)(req.auxFundingDesc)
|
||||||
|
remoteAuxLeaves := fn.MapOption(
|
||||||
|
func(desc AuxFundingDesc) CommitAuxLeaves {
|
||||||
|
return desc.RemoteInitAuxLeaves
|
||||||
|
},
|
||||||
|
)(req.auxFundingDesc)
|
||||||
|
|
||||||
ourCommitTx, theirCommitTx, err := CreateCommitmentTxns(
|
ourCommitTx, theirCommitTx, err := CreateCommitmentTxns(
|
||||||
localBalance, remoteBalance,
|
localBalance, remoteBalance,
|
||||||
pendingReservation.ourContribution.ChannelConfig,
|
pendingReservation.ourContribution.ChannelConfig,
|
||||||
@@ -2340,6 +2384,7 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
|
|||||||
pendingReservation.theirContribution.FirstCommitmentPoint,
|
pendingReservation.theirContribution.FirstCommitmentPoint,
|
||||||
*fundingTxIn, chanType,
|
*fundingTxIn, chanType,
|
||||||
pendingReservation.partialState.IsInitiator, leaseExpiry,
|
pendingReservation.partialState.IsInitiator, leaseExpiry,
|
||||||
|
WithAuxLeaves(localAuxLeaves, remoteAuxLeaves),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.err <- err
|
req.err <- err
|
||||||
|
|||||||
Reference in new issue
Block a user