@@ -111,6 +111,7 @@ def run_test(self):
111111
112112 self .run_rbf_opt_in_test ()
113113 self .run_externally_generated_address_test ()
114+ self .run_coinjoin_test ()
114115 self .run_invalid_parameters_test ()
115116 self .test_op_return ()
116117
@@ -282,6 +283,35 @@ def normalize_list(txs):
282283 assert_equal (['pizza2' ], self .nodes [0 ].getaddressinfo (addr2 )['labels' ])
283284 assert_equal (['pizza3' ], self .nodes [0 ].getaddressinfo (addr3 )['labels' ])
284285
286+ def run_coinjoin_test (self ):
287+ self .log .info ('Check "coin-join" transaction' )
288+ input_0 = next (i for i in self .nodes [0 ].listunspent (query_options = {"minimumAmount" : 0.2 }, include_unsafe = False ))
289+ input_1 = next (i for i in self .nodes [1 ].listunspent (query_options = {"minimumAmount" : 0.2 }, include_unsafe = False ))
290+ raw_hex = self .nodes [0 ].createrawtransaction (
291+ inputs = [
292+ {
293+ "txid" : input_0 ["txid" ],
294+ "vout" : input_0 ["vout" ],
295+ },
296+ {
297+ "txid" : input_1 ["txid" ],
298+ "vout" : input_1 ["vout" ],
299+ },
300+ ],
301+ outputs = [
302+ {self .nodes [0 ].getnewaddress (): 0.123 },
303+ {self .nodes [1 ].getnewaddress (): 0.123 },
304+ {"fee" : input_0 ["amount" ] + input_1 ["amount" ] - Decimal ("0.246" )},
305+ ],
306+ )
307+ raw_hex = self .nodes [0 ].signrawtransactionwithwallet (raw_hex )["hex" ]
308+ raw_hex = self .nodes [1 ].signrawtransactionwithwallet (raw_hex )["hex" ]
309+ txid_join = self .nodes [0 ].sendrawtransaction (hexstring = raw_hex , maxfeerate = 0 )
310+ fee_join = self .nodes [0 ].getmempoolentry (txid_join )["fees" ]["base" ]
311+ # Fee should be correct: assert_equal(fee_join, self.nodes[0].gettransaction(txid_join)['fee'])
312+ # But it is not, see for example https://github.com/bitcoin/bitcoin/issues/14136:
313+ assert fee_join != self .nodes [0 ].gettransaction (txid_join )["fee" ]
314+
285315 def run_invalid_parameters_test (self ):
286316 self .log .info ("Test listtransactions RPC parameter validity" )
287317 assert_raises_rpc_error (- 8 , 'Label argument must be a valid label name or "*".' , self .nodes [0 ].listtransactions , label = "" )
0 commit comments