MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_txprepare_feerate

Function test_txprepare_feerate

tests/test_wallet.py:529–555  ·  view source on GitHub ↗
(node_factory, bitcoind, chainparams)

Source from the content-addressed store, hash-verified

527
528
529def 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"])

Callers

nothing calls this directly

Calls 10

wait_forFunction · 0.90
MillisatoshiClass · 0.90
did_short_sigFunction · 0.90
feerate_from_psbtFunction · 0.85
get_nodesMethod · 0.80
generate_blockMethod · 0.80
txprepareMethod · 0.80
txdiscardMethod · 0.80
newaddrMethod · 0.45
listfundsMethod · 0.45

Tested by

no test coverage detected