7
7
# Test fee estimation code
8
8
#
9
9
10
+ from collections import OrderedDict
10
11
from test_framework .test_framework import BitcoinTestFramework
11
12
from test_framework .util import *
12
13
22
23
def small_txpuzzle_randfee (from_node , conflist , unconflist , amount , min_fee , fee_increment ):
23
24
'''
24
25
Create and send a transaction with a random fee.
25
- The transaction pays to a trival P2SH script, and assumes that its inputs
26
+ The transaction pays to a trivial P2SH script, and assumes that its inputs
26
27
are of the same form.
27
28
The function takes a list of confirmed outputs and unconfirmed outputs
28
29
and attempts to use the confirmed list first for its inputs.
@@ -49,10 +50,10 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee
49
50
if total_in <= amount + fee :
50
51
raise RuntimeError ("Insufficient funds: need %d, have %d" % (amount + fee , total_in ))
51
52
outputs = {}
52
- outputs [ P2SH_1 ] = total_in - amount - fee
53
- outputs [ P2SH_2 ] = amount
53
+ outputs = OrderedDict ([( P2SH_1 , total_in - amount - fee ),
54
+ ( P2SH_2 , amount )])
54
55
rawtx = from_node .createrawtransaction (inputs , outputs )
55
- # Createrawtransaction constructions a transaction that is ready to be signed
56
+ # createrawtransaction constructs a transaction that is ready to be signed.
56
57
# These transactions don't need to be signed, but we still have to insert the ScriptSig
57
58
# that will satisfy the ScriptPubKey.
58
59
completetx = rawtx [0 :10 ]
@@ -78,12 +79,10 @@ def split_inputs(from_node, txins, txouts, initial_split = False):
78
79
'''
79
80
prevtxout = txins .pop ()
80
81
inputs = []
81
- outputs = {}
82
82
inputs .append ({ "txid" : prevtxout ["txid" ], "vout" : prevtxout ["vout" ] })
83
83
half_change = satoshi_round (prevtxout ["amount" ]/ 2 )
84
84
rem_change = prevtxout ["amount" ] - half_change - Decimal ("0.00001000" )
85
- outputs [P2SH_1 ] = half_change
86
- outputs [P2SH_2 ] = rem_change
85
+ outputs = OrderedDict ([(P2SH_1 , half_change ), (P2SH_2 , rem_change )])
87
86
rawtx = from_node .createrawtransaction (inputs , outputs )
88
87
# If this is the initial split we actually need to sign the transaction
89
88
# Otherwise we just need to insert the property ScriptSig
@@ -224,7 +223,7 @@ def transact_and_mine(self, numblocks, mining_node):
224
223
sync_mempools (self .nodes [0 :3 ],.1 )
225
224
mined = mining_node .getblock (mining_node .generate (1 )[0 ],True )["tx" ]
226
225
sync_blocks (self .nodes [0 :3 ],.1 )
227
- #update which txouts are confirmed
226
+ # update which txouts are confirmed
228
227
newmem = []
229
228
for utx in self .memutxo :
230
229
if utx ["txid" ] in mined :
0 commit comments