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

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

Pull request description:

  Backport from upstream https://github.com/bitcoin/bitcoin/pull/14039

Tree-SHA512: a91810e0afe4d631e2e08cd1bc919e83e3dbdac050f1a66ddc0c6210b222e5813f5b36b27111976e83a4c7683507e4ed06ef475467e1c0e572ccb3d0abc631e4
This commit is contained in:
Gregory Sanders 2019-03-25 10:46:59 -04:00
commit aaee9dde6f
No known key found for this signature in database
GPG key ID: F3F68E2D86A48FDB

View file

@ -655,6 +655,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
const_cast<CTxWitness*>(&tx.wit)->vtxinwit.resize(tx.vin.size());
const_cast<CTxWitness*>(&tx.wit)->vtxoutwit.resize(tx.vout.size());
s >> tx.wit;
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 */