Skip to content
Browse files

Merge #14039: Disallow extended encoding for non-witness transactions

bb530ef Disallow extended encoding for non-witness transactions (Pieter Wuille)

Pull request description:

  BIP144 specifies that transactions without witness should use the legacy encoding, which is currently not enforced.

  This rule was present in the original SegWit implementation (#8149), but was subsequently dropped (#8589).

  As all hashes, txids, and weights are always computed over a reserialized version of a transaction, it is mostly harmless to permit extended encoding for non-segwit transactions, but I'd rather strictly follow the BIP.

ACKs for commit bb530e:
    utACK bb530ef
    utACK bb530ef

Tree-SHA512: 1aeccd6a555f43784fefb076ce2e8ad2f5ba7be49840544a50050d0390f82373f87201bf56cf8bb30841b4f9cd893b382261a080da875d4e11ab7051f8640dbe
  • Loading branch information...
MarcoFalke committed Apr 25, 2019
2 parents 8cca1fb + bb530ef commit c65c77c721b69f1782509145d62978d31c9a1d78
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/primitives/transaction.h
@@ -222,6 +222,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
for (size_t i = 0; i <; i++) {
s >>[i].scriptWitness.stack;
if (!tx.HasWitness()) {
/* It's illegal to encode witnesses when all witness stacks are empty. */
throw std::ios_base::failure("Superfluous witness record");
if (flags) {
/* Unknown flag in the serialization */

0 comments on commit c65c77c

Please sign in to comment.
You can’t perform that action at this time.