Fix issue where a coinbase tx should have it's sigscript hashed
to avoid duplicate txids, as discussed in BIP34 and BIP30.
This commit is contained in:
parent
2481bab2b8
commit
90a9019387
|
@ -234,13 +234,16 @@ void CTransaction::UpdateTxid() const
|
||||||
// Create a deep copy of this transaction
|
// Create a deep copy of this transaction
|
||||||
CMutableTransaction tx(*this);
|
CMutableTransaction tx(*this);
|
||||||
|
|
||||||
// Clear sigscript from all transaction inputs.
|
// We keep the sigscript for coinbase txs to avoid duplicate txids (BIP34 and BIP30)
|
||||||
for (CTxIn & txIn : tx.vin) {
|
if (!IsCoinBase()) {
|
||||||
txIn.scriptSig.clear();
|
// Clear sigscript from all transaction inputs.
|
||||||
}
|
for (CTxIn & txIn : tx.vin) {
|
||||||
|
txIn.scriptSig.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Clear joinSplitSig by filling the buffer with zero
|
// Clear joinSplitSig by filling the buffer with zero
|
||||||
tx.joinSplitSig.assign(0);
|
tx.joinSplitSig.assign(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Return double SHA256 hash
|
// Return double SHA256 hash
|
||||||
*const_cast<uint256*>(&txid) = tx.GetSerializeHash();
|
*const_cast<uint256*>(&txid) = tx.GetSerializeHash();
|
||||||
|
|
Loading…
Reference in New Issue