mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
bkpr: once we get channel_opens, we might need to update the fee records
Also note that we might have ignored/missed fees for the channel closed's spending txid, so we attempt to update those as well. Backfilling for missed events is a beast.
This commit is contained in:
parent
8827423556
commit
fea33221d4
1 changed files with 26 additions and 0 deletions
|
@ -242,6 +242,24 @@ struct new_account_info {
|
||||||
char *currency;
|
char *currency;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void try_update_open_fees(struct command *cmd,
|
||||||
|
struct account *acct)
|
||||||
|
{
|
||||||
|
struct chain_event *ev;
|
||||||
|
char *err;
|
||||||
|
|
||||||
|
assert(acct->closed_event_db_id);
|
||||||
|
ev = find_chain_event_by_id(cmd, db, *acct->closed_event_db_id);
|
||||||
|
assert(ev);
|
||||||
|
|
||||||
|
err = maybe_update_onchain_fees(cmd, db, ev->spending_txid);
|
||||||
|
if (err)
|
||||||
|
plugin_err(cmd->plugin,
|
||||||
|
"failure updating chain fees:"
|
||||||
|
" %s", err);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static bool new_missed_channel_account(struct command *cmd,
|
static bool new_missed_channel_account(struct command *cmd,
|
||||||
const char *buf,
|
const char *buf,
|
||||||
const jsmntok_t *result,
|
const jsmntok_t *result,
|
||||||
|
@ -333,6 +351,14 @@ static bool new_missed_channel_account(struct command *cmd,
|
||||||
db_begin_transaction(db);
|
db_begin_transaction(db);
|
||||||
log_chain_event(db, acct, chain_ev);
|
log_chain_event(db, acct, chain_ev);
|
||||||
maybe_update_account(db, acct, chain_ev, tags);
|
maybe_update_account(db, acct, chain_ev, tags);
|
||||||
|
maybe_update_onchain_fees(cmd, db, &opt.txid);
|
||||||
|
|
||||||
|
/* We won't count the close's fees if we're
|
||||||
|
* *not* the opener, which we didn't know
|
||||||
|
* until now, so now try to update the
|
||||||
|
* fees for the close tx's spending_txid..*/
|
||||||
|
if (acct->closed_event_db_id)
|
||||||
|
try_update_open_fees(cmd, acct);
|
||||||
|
|
||||||
/* We log a channel event for the push amt */
|
/* We log a channel event for the push amt */
|
||||||
if (!amount_msat_zero(push_amt)) {
|
if (!amount_msat_zero(push_amt)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue