Browse Source

wallet: Forget channels that are irrevocably settled on-chain

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
9588c961bb
  1. 2
      lightningd/peer_control.c
  2. 8
      wallet/wallet.c
  3. 5
      wallet/wallet.h

2
lightningd/peer_control.c

@ -1244,8 +1244,8 @@ static void handle_irrevocably_resolved(struct peer *peer, const u8 *msg)
/* FIXME: Implement check_htlcs to ensure no dangling hout->in ptrs! */
free_htlcs(peer->ld, peer);
/* FIXME: Remove peer from db. */
log_info(peer->log, "onchaind complete, forgetting peer");
wallet_channel_delete(peer->ld->wallet, peer->channel->id);
/* This will also free onchaind. */
free_peer(peer, "onchaind complete, forgetting peer");

8
wallet/wallet.c

@ -836,6 +836,14 @@ void wallet_channel_save(struct wallet *w, struct wallet_channel *chan,
tal_free(tmpctx);
}
void wallet_channel_delete(struct wallet *w, u64 wallet_id)
{
sqlite3_stmt *stmt;
stmt = db_prepare(w->db, "DELETE FROM channels WHERE id=?");
sqlite3_bind_int64(stmt, 1, wallet_id);
db_exec_prepared(w->db, stmt);
}
int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx,
u64 *total_satoshi)
{

5
wallet/wallet.h

@ -215,6 +215,11 @@ bool wallet_shachain_load(struct wallet *wallet, u64 id,
void wallet_channel_save(struct wallet *w, struct wallet_channel *chan,
u32 current_block_height);
/**
* wallet_channel_delete -- After resolving a channel, forget about it
*/
void wallet_channel_delete(struct wallet *w, u64 wallet_id);
/**
* wallet_channel_config_save -- Upsert a channel_config into the database
*/

Loading…
Cancel
Save