@@ -134,11 +134,13 @@ def send_tx(node, utxo, feerate):
134
134
"""Broadcast a 1in-1out transaction with a specific input and feerate (sat/vb)."""
135
135
tx = CTransaction ()
136
136
tx .vin = [CTxIn (COutPoint (int (utxo ["txid" ], 16 ), utxo ["vout" ]), REDEEM_SCRIPT )]
137
- tx .vout = [CTxOut (int (utxo ["amount" ] * COIN ), P2SH )]
137
+ tx .vout = [CTxOut (int (utxo ["amount" ] * COIN ), P2SH ), CTxOut ( int ( utxo [ "amount" ] * COIN )) ]
138
138
139
139
# vbytes == bytes as we are using legacy transactions
140
140
fee = tx .get_vsize () * feerate
141
- tx .vout [0 ].nValue -= fee
141
+ amount = tx .vout [0 ].nValue .getAmount ()
142
+ tx .vout [0 ].nValue .setToAmount (amount - fee )
143
+ tx .vout [1 ].nValue .setToAmount (fee )
142
144
143
145
return node .sendrawtransaction (tx .serialize ().hex ())
144
146
@@ -208,7 +210,7 @@ def transact_and_mine(self, numblocks, mining_node):
208
210
209
211
def initial_split (self , node ):
210
212
"""Split two coinbase UTxOs into many small coins"""
211
- utxo_count = 2048
213
+ utxo_count = 1450 # ELEMENTS reduced to fit into max tx weight
212
214
self .confutxo = []
213
215
splitted_amount = Decimal ("0.04" )
214
216
fee = Decimal ("0.1" )
@@ -220,6 +222,7 @@ def initial_split(self, node):
220
222
]
221
223
tx .vout = [CTxOut (int (splitted_amount * COIN ), P2SH ) for _ in range (utxo_count )]
222
224
tx .vout .append (CTxOut (int (change * COIN ), P2SH ))
225
+ tx .vout .append (CTxOut (int (fee * COIN )))
223
226
txhex = node .signrawtransactionwithwallet (tx .serialize ().hex ())["hex" ]
224
227
txid = node .sendrawtransaction (txhex )
225
228
self .confutxo = [
0 commit comments