lnwallet: check commitment sanity within createCommitmentTx

In this commit, we move the check to CheckTransactionSanity into
createCommitmentTx. We do this as within wallet.go (during the funding
process) we actually end up calling this helper function twice, and also
moving it up until right when we create the fully commitment transaction
ensures we making our assertion against the final version.
This commit is contained in:
Olaoluwa Osuntokun 2018-05-21 16:47:01 -07:00
parent 6a2a049df1
commit 0570e80fd2
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -2338,6 +2338,12 @@ func (lc *LightningChannel) createCommitmentTx(c *commitment,
// instead we'll just send signatures.
txsort.InPlaceSort(commitTx)
// Next, we'll ensure that we don't accidentally create a commitment
// transaction which would be invalid by consensus.
uTx := btcutil.NewTx(commitTx)
if err := blockchain.CheckTransactionSanity(uTx); err != nil {
return err
}
c.txn = commitTx
c.fee = commitFee
c.ourBalance = ourBalance
@ -5795,13 +5801,6 @@ func CreateCommitTx(fundingOutput wire.TxIn,
})
}
// Finally, we'll ensure that we don't accidentally create a commitment
// transaction which would be invalid by consensus.
uTx := btcutil.NewTx(commitTx)
if err := blockchain.CheckTransactionSanity(uTx); err != nil {
return nil, err
}
return commitTx, nil
}