Skip to content

Commit 25b0786

Browse files
committed
Fix missing input template by making minimal tx
1 parent c65c77c commit 25b0786

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

test/functional/data/invalid_txs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ class InputMissing(BadTxTemplate):
7171
reject_reason = "bad-txns-vin-empty"
7272
expect_disconnect = False
7373

74+
# We use a blank transaction here to make sure
75+
# it is interpreted as a non-witness transaction.
76+
# Otherwise the transaction will fail the
77+
# "surpufluous witness" check during deserialization
78+
# rather than the input count check.
7479
def get_tx(self):
7580
tx = CTransaction()
76-
tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE] * 100)))
7781
tx.calc_sha256()
7882
return tx
7983

test/functional/feature_block.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,6 @@ def run_test(self):
146146
badtx = template.get_tx()
147147
if TxTemplate != invalid_txs.InputMissing:
148148
self.sign_tx(badtx, attempt_spend_tx)
149-
else:
150-
# Segwit is active in regtest at this point, so to deserialize a
151-
# transaction without any inputs correctly, we set the outputs
152-
# to an empty list. This is a hack, as the serialization of an
153-
# empty list of outputs is deserialized as flags==0 and thus
154-
# deserialization of the outputs is skipped.
155-
# A policy check requires "loose" txs to be of a minimum size,
156-
# so vtx is not set to be empty in the TxTemplate class and we
157-
# only apply the workaround where txs are not "loose", i.e. in
158-
# blocks.
159-
#
160-
# The workaround has the purpose that both sides calculate
161-
# the same tx hash in the merkle tree
162-
badtx.vout = []
163149
badtx.rehash()
164150
badblock = self.update_block(blockname, [badtx])
165151
self.send_blocks(

0 commit comments

Comments
 (0)