Skip to content

Commit

Permalink
inflight: Add ability to delete an inflight
Browse files Browse the repository at this point in the history
  • Loading branch information
ddustin authored and cdecker committed Feb 11, 2024
1 parent e102234 commit bee4654
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,24 @@ void wallet_inflight_add(struct wallet *w, struct channel_inflight *inflight)
tal_free(stmt);
}

void wallet_inflight_del(struct wallet *w, struct channel *chan,
struct channel_inflight *inflight)
{
struct db_stmt *stmt;

/* Remove inflight from the channel */
stmt = db_prepare_v2(w->db, SQL("DELETE FROM channel_funding_inflights"
" WHERE channel_id = ?"
" AND funding_tx_id = ?"
" AND funding_tx_outnum = ?"));
db_bind_u64(stmt, chan->dbid);
db_bind_txid(stmt, &inflight->funding->outpoint.txid);
db_bind_int(stmt, inflight->funding->outpoint.n);
db_exec_prepared_v2(take(stmt));

tal_free(inflight);
}

void wallet_inflight_save(struct wallet *w,
struct channel_inflight *inflight)
{
Expand Down
6 changes: 6 additions & 0 deletions wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ void wallet_channel_insert(struct wallet *w, struct channel *chan);
*/
void wallet_inflight_add(struct wallet *w, struct channel_inflight *inflight);

/**
* Delete an inflight transaction for a channel
*/
void wallet_inflight_del(struct wallet *w, struct channel *chan,
struct channel_inflight *inflight);

/**
* Update an existing inflight channel transaction
*/
Expand Down

0 comments on commit bee4654

Please sign in to comment.