File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
351351 const_cast <CTxWitness*>(&tx.witness )->vtxinwit .resize (tx.vin .size ());
352352 const_cast <CTxWitness*>(&tx.witness )->vtxoutwit .resize (tx.vout .size ());
353353 s >> tx.witness ;
354+ if (!tx.HasWitness ()) {
355+ /* It's illegal to encode witnesses when all witness stacks are empty. */
356+ throw std::ios_base::failure (" Superfluous witness record" );
357+ }
354358 }
355359 } else {
356360 const bool fAllowWitness = !(s.GetVersion () & SERIALIZE_TRANSACTION_NO_WITNESS);
@@ -381,6 +385,10 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
381385 s >> tx.witness .vtxinwit [i].m_pegin_witness .stack ;
382386 }
383387 }
388+ if (!tx.HasWitness ()) {
389+ /* It's illegal to encode witnesses when all witness stacks are empty. */
390+ throw std::ios_base::failure (" Superfluous witness record" );
391+ }
384392 }
385393 s >> tx.nLockTime ;
386394 }
You can’t perform that action at this time.
0 commit comments