(node_factory, bitcoind, chainparams)
| 527 | |
| 528 | |
| 529 | def test_txprepare_feerate(node_factory, bitcoind, chainparams): |
| 530 | # Make sure it works at different feerates! |
| 531 | l1, l2 = node_factory.get_nodes(2, opts={'dev-warn-on-overgrind': None, |
| 532 | 'broken_log': 'overgrind: short signature length'}) |
| 533 | |
| 534 | # Add some funds to withdraw later |
| 535 | for i in range(20): |
| 536 | bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('bech32')['bech32'], |
| 537 | 1000 / 10**8) |
| 538 | |
| 539 | bitcoind.generate_block(1) |
| 540 | out_addrs = l2.rpc.newaddr('all') |
| 541 | wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 20) |
| 542 | |
| 543 | for addrtype in ('bech32', 'p2tr'): |
| 544 | for feerate in range(255, 1000, 250): |
| 545 | prep = l1.rpc.txprepare([{out_addrs[addrtype]: Millisatoshi(9000)}], f"{feerate}perkw") |
| 546 | actual_feerate = feerate_from_psbt(chainparams, bitcoind, l1, prep['psbt']) |
| 547 | assert feerate - 2 < actual_feerate |
| 548 | # Feerate can be larger, if it chose not to give change output. |
| 549 | if chainparams['elements']: |
| 550 | fee_output = 1 |
| 551 | else: |
| 552 | fee_output = 0 |
| 553 | if len(bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])['vout']) == 1 + 1 + fee_output and not did_short_sig(l1): |
| 554 | assert actual_feerate < feerate + 2 |
| 555 | l1.rpc.txdiscard(prep['txid']) |
| 556 | |
| 557 | |
| 558 | @pytest.mark.parametrize("addrtype", ["bech32", "p2tr"]) |
nothing calls this directly
no test coverage detected