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

@@ -736,6 +736,10 @@ int main(int argc, char *argv[])
else if (max_blockheight != UINT32_MAX)
max_blockheight -= ld->config.rescan;
/*~ Tell the wallet to start figuring out what to do for any reserved
* unspent outputs we may have crashed with. */
wallet_clean_utxos(ld->wallet, ld->topology->bitcoind);
/*~ That's all of the wallet db operations for now. */
db_commit_transaction(ld->wallet->db);