mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
wallet: Forget channels that are irrevocably settled on-chain
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
f03dbde354
commit
9588c961bb
@ -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");
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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…
Reference in New Issue
Block a user