Skip to content

Commit 8719c94

Browse files
sipaapoelstra
authored andcommitted
Disallow extended encoding for non-witness transactions
1 parent 929be38 commit 8719c94

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/primitives/transaction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
654654
const_cast<CTxWitness*>(&tx.wit)->vtxinwit.resize(tx.vin.size());
655655
const_cast<CTxWitness*>(&tx.wit)->vtxoutwit.resize(tx.vout.size());
656656
s >> tx.wit;
657+
if (!tx.HasWitness()) {
658+
/* It's illegal to encode witnesses when all witness stacks are empty. */
659+
throw std::ios_base::failure("Superfluous witness record");
660+
}
657661
}
658662
if (flags) {
659663
/* Unknown flag in the serialization */

0 commit comments

Comments
 (0)