Skip to content

Commit

Permalink
Merge ElementsProject#525: [0.17] Disallow extended encoding for non-…
Browse files Browse the repository at this point in the history
…witness transactions

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

Pull request description:

  backport of ElementsProject#402 which is a backport of upstream

Tree-SHA512: 01cccbc0d54a9f039ed16c88f1d9ec7ebac3a936fb4a77e664c9103e06bb142741a743ac980887ec16570429ccc0f9614e5b3076084b1c949190b3169844ed7d
  • Loading branch information
instagibbs committed Mar 21, 2019
2 parents 406580e + e11c6f5 commit 3c8206a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 3c8206a

Please sign in to comment.