lnwallet: coalesce different supported output scripts into single method

This commit is contained in:
Wilmer Paulino
2021-07-14 17:06:13 -07:00
committed by Olaoluwa Osuntokun
parent 652f841738
commit 01e9bb2bff
4 changed files with 88 additions and 70 deletions

View File

@@ -372,19 +372,14 @@ 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.
localScript, err := input.CommitScriptToSelf(
uint32(c.cfg.chanState.LocalChanCfg.CsvDelay),
localScript, err := lnwallet.CommitScriptToSelf(
commitKeyRing.ToLocalKey, commitKeyRing.RevocationKey,
uint32(c.cfg.chanState.LocalChanCfg.CsvDelay),
)
if err != nil {
return false, err
}
localPkScript, err := input.WitnessScriptHash(localScript)
if err != nil {
return false, err
}
// With all our scripts assembled, we'll examine the outputs of the
// commitment transaction to determine if this is a local force close
// or not.
@@ -393,7 +388,7 @@ func (c *chainWatcher) handleUnknownLocalState(
pkScript := output.PkScript
switch {
case bytes.Equal(localPkScript, pkScript):
case bytes.Equal(localScript.PkScript, pkScript):
ourCommit = true
case bytes.Equal(remoteScript.PkScript, pkScript):