@@ -80,12 +80,6 @@ def get_address(self, confidential, node_num, addr_mode=None):
8080 def to_unconf_addr (self , node_num , addr ):
8181 return self .nodes [node_num ].getaddressinfo (addr )['unconfidential' ]
8282
83- def find_output_in_tx (self , tx , amount ):
84- for i in range (len (tx ["vout" ])):
85- if tx ["vout" ][i ]["value" ] == amount :
86- return i
87- raise RuntimeError ("find_output tx %s : %s not found" % (tx , str (amount )))
88-
8983 def run_basic_tests (self , confidential ):
9084 # Create and fund a raw tx for sending 10 BTC
9185 psbtx1 = self .nodes [0 ].walletcreatefundedpsbt ([], {self .get_address (confidential , 2 ):10 })['psbt' ]
@@ -121,8 +115,10 @@ def run_basic_tests(self, confidential):
121115 # fund those addresses
122116 rawtx = self .nodes [0 ].createrawtransaction ([], {p2sh :10 , p2wsh :10 , p2wpkh :10 , p2sh_p2wsh :10 , p2sh_p2wpkh :10 , p2pkh :10 })
123117 rawtx = self .nodes [0 ].fundrawtransaction (rawtx , {"changePosition" :3 })
124- signed_tx = self .nodes [0 ].signrawtransactionwithwallet (rawtx ['hex' ])['hex' ]
118+ rawtx = self .nodes [0 ].blindrawtransaction (rawtx ['hex' ])
119+ signed_tx = self .nodes [0 ].signrawtransactionwithwallet (rawtx )['hex' ]
125120 txid = self .nodes [0 ].sendrawtransaction (signed_tx )
121+
126122 self .nodes [0 ].generate (6 )
127123 self .sync_all ()
128124
@@ -198,23 +194,37 @@ def run_basic_tests(self, confidential):
198194 # Create outputs to nodes 1 and 2
199195 # We do a whole song-and-dance here (instead of calling sendtoaddress) to get access to the unblinded transaction data to find our outputs
200196 node1_addr = self .get_address (confidential , 1 )
197+ node1_unconf_addr = self .to_unconf_addr (1 , node1_addr )
201198 node2_addr = self .get_address (confidential , 2 )
199+ node2_unconf_addr = self .to_unconf_addr (2 , node2_addr )
202200 rt1 = self .nodes [0 ].createrawtransaction ([], {node1_addr :13 })
203201 rt1 = self .nodes [0 ].fundrawtransaction (rt1 )
204- rt1 = self .nodes [0 ].signrawtransactionwithwallet (rt1 ['hex' ])
202+ rt1 = self .nodes [0 ].blindrawtransaction (rt1 ['hex' ])
203+ rt1 = self .nodes [0 ].signrawtransactionwithwallet (rt1 )
205204 txid1 = self .nodes [0 ].sendrawtransaction (rt1 ['hex' ])
206205 rt1 = self .nodes [0 ].decoderawtransaction (rt1 ['hex' ])
207206
208207 rt2 = self .nodes [0 ].createrawtransaction ([], {node2_addr :13 })
209208 rt2 = self .nodes [0 ].fundrawtransaction (rt2 )
210- rt2 = self .nodes [0 ].signrawtransactionwithwallet (rt2 ['hex' ])
209+ rt2 = self .nodes [0 ].blindrawtransaction (rt2 ['hex' ])
210+ rt2 = self .nodes [0 ].signrawtransactionwithwallet (rt2 )
211211 txid2 = self .nodes [0 ].sendrawtransaction (rt2 ['hex' ])
212212 rt2 = self .nodes [0 ].decoderawtransaction (rt2 ['hex' ])
213213
214214 self .nodes [0 ].generate (6 )
215215 self .sync_all ()
216- vout1 = self .find_output_in_tx (rt1 , 13 )
217- vout2 = self .find_output_in_tx (rt2 , 13 )
216+
217+ for out in rt1 ['vout' ]:
218+ if out ['scriptPubKey' ]['type' ] == "fee" :
219+ next
220+ elif out ['scriptPubKey' ]['addresses' ][0 ] == node1_unconf_addr :
221+ vout1 = out ['n' ]
222+
223+ for out in rt2 ['vout' ]:
224+ if out ['scriptPubKey' ]['type' ] == "fee" :
225+ next
226+ elif out ['scriptPubKey' ]['addresses' ][0 ] == node2_unconf_addr :
227+ vout2 = out ['n' ]
218228
219229 # This test doesn't work with Confidential Assets yet.
220230 if not confidential :
@@ -350,7 +360,8 @@ def run_ca_tests(self):
350360 unconf_addr_4 = self .get_address (False , 0 )
351361 rawtx = self .nodes [0 ].createrawtransaction ([], {unconf_addr_0 :50 , unconf_addr_1 :50 , unconf_addr_4 :50 })
352362 rawtx = self .nodes [0 ].fundrawtransaction (rawtx , {"changePosition" :3 }) # our outputs will be 0, 1, 2
353- signed_tx = self .nodes [0 ].signrawtransactionwithwallet (rawtx ['hex' ])['hex' ]
363+ rawtx = self .nodes [0 ].blindrawtransaction (rawtx ['hex' ])
364+ signed_tx = self .nodes [0 ].signrawtransactionwithwallet (rawtx )['hex' ]
354365 txid_nonconf = self .nodes [0 ].sendrawtransaction (signed_tx )
355366 self .nodes [0 ].generate (1 )
356367 self .sync_all ()
0 commit comments