mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
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:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user