@@ -134,11 +134,13 @@ def send_tx(node, utxo, feerate):
134134 """Broadcast a 1in-1out transaction with a specific input and feerate (sat/vb)."""
135135 tx = CTransaction ()
136136 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 )) ]
138138
139139 # vbytes == bytes as we are using legacy transactions
140140 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 )
142144
143145 return node .sendrawtransaction (tx .serialize ().hex ())
144146
@@ -208,7 +210,7 @@ def transact_and_mine(self, numblocks, mining_node):
208210
209211 def initial_split (self , node ):
210212 """Split two coinbase UTxOs into many small coins"""
211- utxo_count = 2048
213+ utxo_count = 1450 # ELEMENTS reduced to fit into max tx weight
212214 self .confutxo = []
213215 splitted_amount = Decimal ("0.04" )
214216 fee = Decimal ("0.1" )
@@ -220,6 +222,7 @@ def initial_split(self, node):
220222 ]
221223 tx .vout = [CTxOut (int (splitted_amount * COIN ), P2SH ) for _ in range (utxo_count )]
222224 tx .vout .append (CTxOut (int (change * COIN ), P2SH ))
225+ tx .vout .append (CTxOut (int (fee * COIN )))
223226 txhex = node .signrawtransactionwithwallet (tx .serialize ().hex ())["hex" ]
224227 txid = node .sendrawtransaction (txhex )
225228 self .confutxo = [
0 commit comments