Skip to content

Commit

Permalink
pytest: test onchain wallet descriptor import on bitcoind
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
  • Loading branch information
darosior authored and niftynei committed Nov 10, 2020
1 parent a561360 commit fc964ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,36 @@ def test_hsmtool_secret_decryption(node_factory):
assert node_id == l1.rpc.getinfo()["id"]


@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', '')
def test_hsmtool_dump_descriptors(node_factory, bitcoind):
l1 = node_factory.get_node()
l1.fundwallet(10**6)

# Get a tpub descriptor of lightningd's wallet
hsm_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "hsm_secret")
cmd_line = ["tools/hsmtool", "dumponchaindescriptors", hsm_path, "",
"testnet"]
out = subprocess.check_output(cmd_line).decode("utf8").split("\n")
descriptor = [l for l in out if l.startswith("wpkh(tpub")][0]

# Import the descriptor to bitcoind
# FIXME: if we update the testsuite to use the upcoming 0.21 we could use
# importdescriptors instead.
bitcoind.rpc.importmulti([{
"desc": descriptor,
# No need to rescan, we'll transact afterward
"timestamp": "now",
# The default
"range": [0, 99]
}])

# Funds sent to lightningd can be retrieved by bitcoind
addr = l1.rpc.newaddr()["bech32"]
txid = l1.rpc.withdraw(addr, 10**3)["txid"]
bitcoind.generate_block(1, txid)
assert len(bitcoind.rpc.listunspent(1, 1, [addr])) == 1


# this test does a 'listtransactions' on a yet unconfirmed channel
def test_fundchannel_listtransaction(node_factory, bitcoind):
l1, l2 = node_factory.get_nodes(2)
Expand Down

0 comments on commit fc964ed

Please sign in to comment.