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

Function test_addpsbtoutput

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

Source from the content-addressed store, hash-verified

775
776@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
777def test_addpsbtoutput(node_factory, bitcoind, chainparams):
778 amount1 = 1000000
779 amount2 = 3333333
780 locktime = 111
781 l1 = node_factory.get_node()
782
783 result = l1.rpc.addpsbtoutput(amount1, locktime=locktime)
784 assert result['outnum'] == 0
785
786 psbt_info = bitcoind.rpc.decodepsbt(l1.rpc.setpsbtversion(result['psbt'], 0)['psbt'])
787
788 assert len(psbt_info['tx']['vout']) == 1
789 assert psbt_info['tx']['vout'][0]['n'] == result['outnum']
790 assert psbt_info['tx']['vout'][0]['value'] * 100000000 == amount1
791 assert psbt_info['tx']['locktime'] == locktime
792
793 result = l1.rpc.addpsbtoutput(amount2, result['psbt'])
794 n = result['outnum']
795
796 psbt_info = bitcoind.rpc.decodepsbt(l1.rpc.setpsbtversion(result['psbt'], 0)['psbt'])
797
798 assert len(psbt_info['tx']['vout']) == 2
799 assert psbt_info['tx']['vout'][n]['value'] * 100000000 == amount2
800 assert psbt_info['tx']['vout'][n]['n'] == result['outnum']
801
802 dest = l1.rpc.newaddr('p2tr')['p2tr']
803 result = l1.rpc.addpsbtoutput(amount2, result['psbt'], destination=dest)
804 n = result['outnum']
805
806 psbt_info = bitcoind.rpc.decodepsbt(l1.rpc.setpsbtversion(result['psbt'], 0)['psbt'])
807
808 assert len(psbt_info['tx']['vout']) == 3
809 assert psbt_info['tx']['vout'][n]['value'] * 100000000 == amount2
810 assert psbt_info['tx']['vout'][n]['n'] == result['outnum']
811 assert psbt_info['tx']['vout'][n]['scriptPubKey']['address'] == dest
812
813
814def test_utxopsbt(node_factory, bitcoind, chainparams):

Callers

nothing calls this directly

Calls 3

addpsbtoutputMethod · 0.80
get_nodeMethod · 0.45
newaddrMethod · 0.45

Tested by

no test coverage detected