(chainparams, bitcoind, node, psbt)
| 323 | |
| 324 | |
| 325 | def 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") |
no test coverage detected