7
7
from test_framework .test_framework import BitcoinTestFramework
8
8
from test_framework .util import (
9
9
assert_equal ,
10
+ find_vout_for_address
10
11
)
11
12
from test_framework .messages import (
12
13
COIN ,
@@ -33,6 +34,13 @@ def setup_network(self):
33
34
super ().setup_network ()
34
35
self .disconnect_nodes (1 , 2 )
35
36
37
+ def spend_txid (self , txid , vout , outputs ):
38
+ inputs = [{"txid" : txid , "vout" : vout }]
39
+ tx = self .nodes [0 ].createrawtransaction (inputs , outputs )
40
+ tx = self .nodes [0 ].fundrawtransaction (tx )
41
+ tx = self .nodes [0 ].signrawtransactionwithwallet (tx ['hex' ])
42
+ return self .nodes [0 ].sendrawtransaction (tx ['hex' ])
43
+
36
44
def run_test (self ):
37
45
if self .options .segwit :
38
46
output_type = "p2sh-segwit"
@@ -49,6 +57,7 @@ def run_test(self):
49
57
node0_address1 = self .nodes [0 ].getnewaddress (address_type = output_type )
50
58
node0_txid1 = self .nodes [0 ].sendtoaddress (node0_address1 , 1219 )
51
59
node0_tx1 = self .nodes [0 ].gettransaction (node0_txid1 )
60
+ self .nodes [0 ].lockunspent (False , [{"txid" :node0_txid1 , "vout" : find_vout_for_address (self .nodes [0 ], node0_txid1 , node0_address1 )}])
52
61
53
62
node0_address2 = self .nodes [0 ].getnewaddress (address_type = output_type )
54
63
node0_txid2 = self .nodes [0 ].sendtoaddress (node0_address2 , 29 )
@@ -61,8 +70,8 @@ def run_test(self):
61
70
node1_address = self .nodes [1 ].getnewaddress ()
62
71
63
72
# Send tx1, and another transaction tx2 that won't be cloned
64
- txid1 = self .nodes [0 ]. sendtoaddress ( node1_address , 40 )
65
- txid2 = self .nodes [0 ]. sendtoaddress ( node1_address , 20 )
73
+ txid1 = self .spend_txid ( node0_txid1 , find_vout_for_address ( self . nodes [0 ], node0_txid1 , node0_address1 ), { node1_address : 40 } )
74
+ txid2 = self .spend_txid ( node0_txid2 , find_vout_for_address ( self . nodes [0 ], node0_txid2 , node0_address2 ), { node1_address : 20 } )
66
75
67
76
# Construct a clone of tx1, to be malleated
68
77
rawtx1 = self .nodes [0 ].getrawtransaction (txid1 , 1 )
0 commit comments