lnwallet: support transactions and scripts for new commitment type

This commit modifies the channel state machine to be able to derive the
proper commitment and second-level HTLC output scripts required by the
new script-enforced leased channel commitment type.
This commit is contained in:
Wilmer Paulino
2021-07-14 17:16:13 -07:00
committed by Olaoluwa Osuntokun
parent 01e9bb2bff
commit 8cfb53f64a
11 changed files with 230 additions and 98 deletions

View File

@@ -362,8 +362,13 @@ func (c *chainWatcher) handleUnknownLocalState(
// 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
}
remoteScript, _, err := lnwallet.CommitScriptToRemote(
c.cfg.chanState.ChanType, commitKeyRing.ToRemoteKey,
c.cfg.chanState.ChanType, c.cfg.chanState.IsInitiator,
commitKeyRing.ToRemoteKey, leaseExpiry,
)
if err != nil {
return false, err
@@ -373,8 +378,9 @@ func (c *chainWatcher) handleUnknownLocalState(
// the remote party allowing them to claim this output before the CSV
// delay if we breach.
localScript, err := lnwallet.CommitScriptToSelf(
c.cfg.chanState.ChanType, c.cfg.chanState.IsInitiator,
commitKeyRing.ToLocalKey, commitKeyRing.RevocationKey,
uint32(c.cfg.chanState.LocalChanCfg.CsvDelay),
uint32(c.cfg.chanState.LocalChanCfg.CsvDelay), leaseExpiry,
)
if err != nil {
return false, err