Skip to content

Commit 52d4ebf

Browse files
committed
test: correct weight calculation in wallet_send
Remove 1 byte buffers and count of witnesses from weight calculation.
1 parent ac19235 commit 52d4ebf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: test/functional/wallet_send.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,14 @@ def run_test(self):
543543
break
544544
psbt_in = dec["inputs"][input_idx]
545545
# Calculate the input weight
546-
# (prevout + sequence + length of scriptSig + scriptsig + 1 byte buffer) * WITNESS_SCALE_FACTOR + num scriptWitness stack items + (length of stack item + stack item) * N stack items + 1 byte buffer
546+
# ((prevout + sequence + length of scriptSig + scriptsig) * WITNESS_SCALE_FACTOR) + ((length of stack item + stack item) * N stack items)
547547
len_scriptsig = len(psbt_in["final_scriptSig"]["hex"]) // 2 if "final_scriptSig" in psbt_in else 0
548-
len_scriptsig += len(ser_compact_size(len_scriptsig)) + 1
549-
len_scriptwitness = (sum([(len(x) // 2) + len(ser_compact_size(len(x) // 2)) for x in psbt_in["final_scriptwitness"]]) + len(psbt_in["final_scriptwitness"]) + 1) if "final_scriptwitness" in psbt_in else 0
550-
input_weight = ((40 + len_scriptsig) * WITNESS_SCALE_FACTOR) + len_scriptwitness
548+
len_scriptsig += len(ser_compact_size(len_scriptsig))
549+
len_scriptwitness = (sum([(len(x) // 2) + len(ser_compact_size(len(x) // 2)) for x in psbt_in["final_scriptwitness"]])) if "final_scriptwitness" in psbt_in else 0
550+
len_txid = 32
551+
len_out_index = 4
552+
len_sequence = 4
553+
input_weight = ((len_txid + len_out_index + len_sequence + len_scriptsig) * WITNESS_SCALE_FACTOR) + len_scriptwitness
551554

552555
# Input weight error conditions
553556
assert_raises_rpc_error(

0 commit comments

Comments
 (0)