Browse Source

wallet: provide better comments on wallet_first_blocknum.

ZmnSCPxj queried the unilateral close case, so make that clearer.
Christian raise concerns about existing channels, so make it clear
what we're doing there too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
37373f2c16
  1. 10
      wallet/wallet.c

10
wallet/wallet.c

@ -677,8 +677,7 @@ static bool wallet_ever_used(struct wallet *w)
if (db_get_intvar(w->db, "bip32_max_index", 0) != 0) if (db_get_intvar(w->db, "bip32_max_index", 0) != 0)
return true; return true;
/* Or we could have had a channel terminate unilaterally, /* Or if they do a unilateral close, the output to us provides a UTXO. */
* providing a UTXO. */
stmt = db_query(__func__, w->db, stmt = db_query(__func__, w->db,
"SELECT COUNT(*) FROM outputs WHERE commitment_point IS NOT NULL;"); "SELECT COUNT(*) FROM outputs WHERE commitment_point IS NOT NULL;");
sqlite3_step(stmt); sqlite3_step(stmt);
@ -688,6 +687,13 @@ static bool wallet_ever_used(struct wallet *w)
return channel_utxos; return channel_utxos;
} }
/* We want the earlier of either:
* 1. The first channel we're still watching (it might have closed),
* 2. The last block we scanned for UTXO (might have new incoming payments)
*
* chaintopology actually subtracts another 100 blocks to make sure we
* catch chain forks.
*/
u32 wallet_first_blocknum(struct wallet *w, u32 first_possible) u32 wallet_first_blocknum(struct wallet *w, u32 first_possible)
{ {
int err; int err;

Loading…
Cancel
Save