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);

View File

@@ -173,6 +173,9 @@ const char *version(void)
/* Generated stub for wallet_blocks_heights */
void wallet_blocks_heights(struct wallet *w UNNEEDED, u32 def UNNEEDED, u32 *min UNNEEDED, u32 *max UNNEEDED)
{ fprintf(stderr, "wallet_blocks_heights called!\n"); abort(); }
/* Generated stub for wallet_clean_utxos */
void wallet_clean_utxos(struct wallet *w UNNEEDED, struct bitcoind *bitcoind UNNEEDED)
{ fprintf(stderr, "wallet_clean_utxos called!\n"); abort(); }
/* Generated stub for wallet_network_check */
bool wallet_network_check(struct wallet *w UNNEEDED,
const struct chainparams *chainparams UNNEEDED)