From d60dbba43bf2dd69360aa9b98bddcee3952ab984 Mon Sep 17 00:00:00 2001 From: niftynei Date: Mon, 17 Oct 2022 13:10:12 -0500 Subject: [PATCH] tests: test for coinbase wallet spend. Attempt to spend a coinbase transaction, expected to fail. --- tests/test_opening.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_opening.py b/tests/test_opening.py index fa0282571..64a3ab593 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -1907,3 +1907,22 @@ def test_zeroreserve_alldust(node_factory): # Now try with just a bit more l1.connect(l2) l1.rpc.fundchannel(l2.info['id'], minfunding + 1) + + +@pytest.mark.xfail +def test_coinbase_unspendable(node_factory, bitcoind): + """ A node should not be able to spend a coinbase output + before it's mature """ + + [l1] = node_factory.get_nodes(1) + + addr = l1.rpc.newaddr()["bech32"] + bitcoind.rpc.generatetoaddress(1, addr) + + addr2 = l1.rpc.newaddr()["bech32"] + + # Wait til money in wallet + wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1) + l1.rpc.withdraw(addr2, "all") + # Nothing sent to the mempool! + assert len(bitcoind.rpc.getrawmempool()) == 0