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

Function feerate_from_psbt

tests/test_wallet.py:325–339  ·  view source on GitHub ↗
(chainparams, bitcoind, node, psbt)

Source from the content-addressed store, hash-verified

323
324
325def feerate_from_psbt(chainparams, bitcoind, node, psbt):
326 # signpsbt insists they are reserved!
327 node.rpc.reserveinputs(psbt, exclusive=False)
328 final = node.rpc.dev_finalizepsbt(node.rpc.signpsbt(psbt)['signed_psbt'])
329 node.rpc.unreserveinputs(psbt)
330 if chainparams['elements']:
331 # Already v1
332 psbt = final['psbt']
333 else:
334 psbt = node.rpc.setpsbtversion(final['psbt'], 0)['psbt']
335 # analyzepsbt gives a vsize, but not a weight!
336 # e.g. 'estimated_vsize': 356, 'estimated_feerate': Decimal('0.00030042'), 'fee': Decimal('0.00010695')
337 fee = int(bitcoind.rpc.analyzepsbt(psbt)['fee'] * 100_000_000)
338 weight = bitcoind.rpc.decoderawtransaction(final['tx'])['weight']
339 return fee / weight * 1000
340
341
342@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "BIP86 random_hsm not compatible with liquid-regtest bech32")

Callers 2

test_txprepareFunction · 0.85
test_txprepare_feerateFunction · 0.85

Calls 3

reserveinputsMethod · 0.80
signpsbtMethod · 0.80
unreserveinputsMethod · 0.80

Tested by

no test coverage detected