mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Disallow extended encoding for non-witness transactions
This commit is contained in:
parent
899690be2f
commit
e11c6f5580
1 changed files with 8 additions and 0 deletions
|
|
@ -351,6 +351,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
|
|||
const_cast<CTxWitness*>(&tx.witness)->vtxinwit.resize(tx.vin.size());
|
||||
const_cast<CTxWitness*>(&tx.witness)->vtxoutwit.resize(tx.vout.size());
|
||||
s >> tx.witness;
|
||||
if (!tx.HasWitness()) {
|
||||
/* It's illegal to encode witnesses when all witness stacks are empty. */
|
||||
throw std::ios_base::failure("Superfluous witness record");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
|
||||
|
|
@ -381,6 +385,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
|
|||
s >> tx.witness.vtxinwit[i].m_pegin_witness.stack;
|
||||
}
|
||||
}
|
||||
if (!tx.HasWitness()) {
|
||||
/* It's illegal to encode witnesses when all witness stacks are empty. */
|
||||
throw std::ios_base::failure("Superfluous witness record");
|
||||
}
|
||||
}
|
||||
s >> tx.nLockTime;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue