wallet: clean reserved inputs on startup.

We reserve inputs when we're going to send a transaction, but we don't
unreserve them if we crash.  This is most graphically demonstrated by
the txprepare case, which makes it easier to trigger.

Instead, we should query bitcoind to see whether the tx made it out or
not, as we would do manually with dev-rescan-outputs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-06-05 16:30:05 +09:30
parent 65505adbab
commit e1dbc0b12b
5 changed files with 60 additions and 1 deletions

View File

@@ -323,7 +323,6 @@ def test_txsend(node_factory, bitcoind):
assert decode['vout'][changenum]['scriptPubKey']['addresses'][0] in [f['address'] for f in l1.rpc.listfunds()['outputs']]
@pytest.mark.xfail(strict=True)
def test_txprepare_restart(node_factory, bitcoind):
amount = 1000000
l1 = node_factory.get_node(may_fail=True)
@@ -367,6 +366,10 @@ def test_txprepare_restart(node_factory, bitcoind):
# It goes backwards in blockchain just in case there was a reorg. Wait.
wait_for(lambda: [o['status'] for o in l1.rpc.listfunds()['outputs']] == ['confirmed'] * 10)
# It should have logged this for each output.
for i in decode['vin']:
assert l1.daemon.is_in_log('wallet: reserved output {}/{} reset to available'.format(i['txid'], i['vout']))
prep = l1.rpc.txprepare('bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg',
'all')
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])