mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 22:50:58 +02:00
lnwallet: thread thru input.AuxTapleaf to all relevant areas
In this commit, we start to thread thru the new aux tap leaf structures to all relevant areas. This includes: commitment outputs, resolution creation, breach handling, and also HTLC scripts.
This commit is contained in:
@@ -426,15 +426,36 @@ func (c *chainWatcher) handleUnknownLocalState(
|
||||
&c.cfg.chanState.LocalChanCfg, &c.cfg.chanState.RemoteChanCfg,
|
||||
)
|
||||
|
||||
auxResult, err := fn.MapOptionZ(
|
||||
c.cfg.auxLeafStore,
|
||||
//nolint:lll
|
||||
func(s lnwallet.AuxLeafStore) fn.Result[lnwallet.CommitDiffAuxResult] {
|
||||
return s.FetchLeavesFromCommit(
|
||||
lnwallet.NewAuxChanState(c.cfg.chanState),
|
||||
c.cfg.chanState.LocalCommitment, *commitKeyRing,
|
||||
)
|
||||
},
|
||||
).Unpack()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("unable to fetch aux leaves: %w", err)
|
||||
}
|
||||
|
||||
// With the keys derived, we'll construct the remote script that'll be
|
||||
// present if they have a non-dust balance on the commitment.
|
||||
var leaseExpiry uint32
|
||||
if c.cfg.chanState.ChanType.HasLeaseExpiration() {
|
||||
leaseExpiry = c.cfg.chanState.ThawHeight
|
||||
}
|
||||
|
||||
remoteAuxLeaf := fn.ChainOption(
|
||||
func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf {
|
||||
return l.RemoteAuxLeaf
|
||||
},
|
||||
)(auxResult.AuxLeaves)
|
||||
remoteScript, _, err := lnwallet.CommitScriptToRemote(
|
||||
c.cfg.chanState.ChanType, c.cfg.chanState.IsInitiator,
|
||||
commitKeyRing.ToRemoteKey, leaseExpiry, input.NoneTapLeaf(),
|
||||
commitKeyRing.ToRemoteKey, leaseExpiry,
|
||||
remoteAuxLeaf,
|
||||
)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -443,11 +464,16 @@ func (c *chainWatcher) handleUnknownLocalState(
|
||||
// Next, we'll derive our script that includes the revocation base for
|
||||
// the remote party allowing them to claim this output before the CSV
|
||||
// delay if we breach.
|
||||
localAuxLeaf := fn.ChainOption(
|
||||
func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf {
|
||||
return l.LocalAuxLeaf
|
||||
},
|
||||
)(auxResult.AuxLeaves)
|
||||
localScript, err := lnwallet.CommitScriptToSelf(
|
||||
c.cfg.chanState.ChanType, c.cfg.chanState.IsInitiator,
|
||||
commitKeyRing.ToLocalKey, commitKeyRing.RevocationKey,
|
||||
uint32(c.cfg.chanState.LocalChanCfg.CsvDelay), leaseExpiry,
|
||||
input.NoneTapLeaf(),
|
||||
localAuxLeaf,
|
||||
)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
Reference in New Issue
Block a user