(node_factory, bitcoind, chainparams)
| 1251 | |
| 1252 | @unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "BIP86 random_hsm not compatible with liquid-regtest bech32") |
| 1253 | def test_txsend(node_factory, bitcoind, chainparams): |
| 1254 | amount = 1000000 |
| 1255 | l1 = node_factory.get_node(random_hsm=True) |
| 1256 | addr = chainparams['example_addr'] |
| 1257 | |
| 1258 | # Add some funds to withdraw later |
| 1259 | for i in range(10): |
| 1260 | bitcoind.rpc.sendtoaddress(l1.rpc.newaddr(good_addrtype())[good_addrtype()], |
| 1261 | amount / 10**8) |
| 1262 | bitcoind.generate_block(1) |
| 1263 | wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10) |
| 1264 | |
| 1265 | prep = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 1000)}]) |
| 1266 | out = l1.rpc.txsend(prep['txid']) |
| 1267 | |
| 1268 | # Cannot discard after send! |
| 1269 | with pytest.raises(RpcError, match=r'not an unreleased txid'): |
| 1270 | l1.rpc.txdiscard(prep['txid']) |
| 1271 | |
| 1272 | wait_for(lambda: prep['txid'] in bitcoind.rpc.getrawmempool()) |
| 1273 | |
| 1274 | # Signed tx should have same txid |
| 1275 | decode = bitcoind.rpc.decoderawtransaction(out['tx']) |
| 1276 | assert decode['txid'] == prep['txid'] |
| 1277 | |
| 1278 | bitcoind.generate_block(1) |
| 1279 | |
| 1280 | # Change output should appear. |
| 1281 | if decode['vout'][0]['value'] == Decimal(amount * 3) / 10**8: |
| 1282 | changenum = 1 |
| 1283 | elif decode['vout'][1]['value'] == Decimal(amount * 3) / 10**8: |
| 1284 | changenum = 0 |
| 1285 | else: |
| 1286 | assert False |
| 1287 | |
| 1288 | # Those spent outputs are gone, but change output has arrived. |
| 1289 | wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10 - len(decode['vin']) + 1) |
| 1290 | |
| 1291 | # Change address should appear in listfunds() |
| 1292 | assert scriptpubkey_addr(decode['vout'][changenum]['scriptPubKey']) in [f['address'] for f in l1.rpc.listfunds()['outputs']] |
| 1293 | |
| 1294 | |
| 1295 | def write_all(fd, bytestr): |
nothing calls this directly
no test coverage detected