Skip to content

Commit bb530ef

Browse files
committed
Disallow extended encoding for non-witness transactions
1 parent 540bf8a commit bb530ef

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
@@ -220,6 +220,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
220220
for (size_t i = 0; i < tx.vin.size(); i++) {
221221
s >> tx.vin[i].scriptWitness.stack;
222222
}
223+
if (!tx.HasWitness()) {
224+
/* It's illegal to encode witnesses when all witness stacks are empty. */
225+
throw std::ios_base::failure("Superfluous witness record");
226+
}
223227
}
224228
if (flags) {
225229
/* Unknown flag in the serialization */

0 commit comments

Comments
 (0)