wallet: save block height when we first create channel.

This gives us a lower bound on where funding tx could be.

In theory, it could be lower than this if we get a reorganization, but
in practice this is already a 1-block buffer (since we can't get into
current block, only the next one).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-01-03 15:56:43 +10:30
committed by Christian Decker
parent af0ed9e5cf
commit 93c589efe8
5 changed files with 25 additions and 18 deletions

View File

@@ -300,7 +300,7 @@ void peer_set_condition(struct peer *peer, enum peer_state old_state,
if (peer_persists(peer)) {
assert(peer->channel != NULL);
/* TODO(cdecker) Selectively save updated fields to DB */
wallet_channel_save(peer->ld->wallet, peer->channel);
wallet_channel_save(peer->ld->wallet, peer->channel, 0);
}
}
@@ -494,7 +494,7 @@ static struct wallet_channel *peer_channel_new(struct wallet *w,
wallet_peer_by_nodeid(w, &peer->id, peer);
wc->id = 0;
wallet_channel_save(w, wc);
wallet_channel_save(w, wc, get_block_height(peer->ld->topology));
return wc;
}
@@ -1707,7 +1707,7 @@ static void peer_got_shutdown(struct peer *peer, const u8 *msg)
}
/* TODO(cdecker) Selectively save updated fields to DB */
wallet_channel_save(peer->ld->wallet, peer->channel);
wallet_channel_save(peer->ld->wallet, peer->channel, 0);
}
void peer_last_tx(struct peer *peer, struct bitcoin_tx *tx,
@@ -1767,7 +1767,7 @@ static void peer_received_closing_signature(struct peer *peer, const u8 *msg)
/* FIXME: Make sure signature is correct! */
if (better_closing_fee(peer, tx)) {
/* TODO(cdecker) Selectively save updated fields to DB */
wallet_channel_save(peer->ld->wallet, peer->channel);
wallet_channel_save(peer->ld->wallet, peer->channel, 0);
peer_last_tx(peer, tx, &sig);
}