Skip to content

Commit 01a98ec

Browse files
committed
removed brainfart
1 parent ce07640 commit 01a98ec

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/primitives/transaction.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
298298
tx.vin.clear();
299299
tx.vout.clear();
300300
tx.witness.SetNull();
301-
const_cast<CTxWitness*>(&tx.witness)->vtxinwit.resize(tx.vin.size());
302-
const_cast<CTxWitness*>(&tx.witness)->vtxoutwit.resize(tx.vout.size());
303301
/* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
304302
s >> tx.vin;
305303
if (tx.vin.size() == 0 && fAllowWitness) {
@@ -321,12 +319,16 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
321319
if ((flags & 1) && fAllowWitness) {
322320
/* The witness flag is present. */
323321
flags ^= 1;
322+
const_cast<CTxWitness*>(&tx.witness)->vtxinwit.resize(tx.vin.size());
323+
const_cast<CTxWitness*>(&tx.witness)->vtxoutwit.resize(tx.vout.size());
324324
s >> tx.witness;
325325
}
326326
} else {
327327
if ((flags & 1) && fAllowWitness) {
328328
/* The witness flag is present. */
329329
flags ^= 1;
330+
const_cast<CTxWitness*>(&tx.witness)->vtxinwit.resize(tx.vin.size());
331+
const_cast<CTxWitness*>(&tx.witness)->vtxoutwit.resize(tx.vout.size());
330332
for (size_t i = 0; i < tx.vin.size(); i++) {
331333
s >> tx.witness.vtxinwit[i].scriptWitness.stack;
332334
// ELEMENTS:

0 commit comments

Comments
 (0)