Reproduces issue #4258, invalid output encoding for txprepare.
(node_factory, bitcoind)
| 1434 | TEST_NETWORK == 'liquid-regtest', |
| 1435 | 'Blinded elementsd addresses are not recognized') |
| 1436 | def test_repro_4258(node_factory, bitcoind): |
| 1437 | """Reproduces issue #4258, invalid output encoding for txprepare. |
| 1438 | """ |
| 1439 | l1 = node_factory.get_node() |
| 1440 | addr = l1.rpc.newaddr()['bech32'] |
| 1441 | bitcoind.rpc.sendtoaddress(addr, 1) |
| 1442 | bitcoind.generate_block(1) |
| 1443 | |
| 1444 | wait_for(lambda: l1.rpc.listfunds()['outputs'] != []) |
| 1445 | out = l1.rpc.listfunds()['outputs'][0] |
| 1446 | |
| 1447 | addr = bitcoind.rpc.getnewaddress() |
| 1448 | |
| 1449 | # These violate the request schema! |
| 1450 | l1.rpc.check_request_schemas = False |
| 1451 | |
| 1452 | # Missing array parentheses for outputs |
| 1453 | with pytest.raises(RpcError, match=r"Expected an array of outputs"): |
| 1454 | l1.rpc.txprepare( |
| 1455 | outputs="{addr}:all".format(addr=addr), |
| 1456 | feerate="slow", |
| 1457 | minconf=1, |
| 1458 | utxos=["{txid}:{output}".format(**out)] |
| 1459 | ) |
| 1460 | |
| 1461 | # Missing parentheses on the utxos array |
| 1462 | with pytest.raises(RpcError, match=r"Could not decode the outpoint array for utxos"): |
| 1463 | l1.rpc.txprepare( |
| 1464 | outputs=[{addr: "all"}], |
| 1465 | feerate="slow", |
| 1466 | minconf=1, |
| 1467 | utxos="{txid}:{output}".format(**out) |
| 1468 | ) |
| 1469 | |
| 1470 | l1.rpc.check_request_schemas = True |
| 1471 | |
| 1472 | tx = l1.rpc.txprepare( |
| 1473 | outputs=[{addr: "all"}], |
| 1474 | feerate="slow", |
| 1475 | minconf=1, |
| 1476 | utxos=["{txid}:{output}".format(**out)] |
| 1477 | ) |
| 1478 | |
| 1479 | tx = bitcoind.rpc.decoderawtransaction(tx['unsigned_tx']) |
| 1480 | |
| 1481 | assert(len(tx['vout']) == 1) |
| 1482 | o0 = tx['vout'][0] |
| 1483 | assert(scriptpubkey_addr(o0['scriptPubKey']) == addr) |
| 1484 | |
| 1485 | assert(len(tx['vin']) == 1) |
| 1486 | i0 = tx['vin'][0] |
| 1487 | assert([i0['txid'], i0['vout']] == [out['txid'], out['output']]) |
| 1488 | |
| 1489 | |
| 1490 | @unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "Uses regtest addresses") |
nothing calls this directly
no test coverage detected