From 9075c74e3d4f40cc6903a45b829e76a50cd8ac5b Mon Sep 17 00:00:00 2001 From: niftynei Date: Tue, 22 Feb 2022 14:00:00 -0600 Subject: [PATCH] balance_snapshot: don't count unconfirmed utxos This was causing journal_entries to show up in the accountant plugin, since we don't emit events for unconfirmed events until they're actually confirmed onchain. --- lightningd/coin_mvts.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lightningd/coin_mvts.c b/lightningd/coin_mvts.c index 098d2ee82..4ba2d9e58 100644 --- a/lightningd/coin_mvts.c +++ b/lightningd/coin_mvts.c @@ -107,6 +107,9 @@ void send_account_balance_snapshot(struct lightningd *ld, u32 blockheight) for (size_t i = 0; i < ARRAY_SIZE(utxo_states); i++) { utxos = wallet_get_utxos(NULL, ld->wallet, utxo_states[i]); for (size_t j = 0; j < tal_count(utxos); j++) { + /* Don't count unconfirmed utxos! */ + if (!utxos[j]->spendheight && !utxos[j]->blockheight) + continue; if (!amount_msat_add_sat(&bal->balance, bal->balance, utxos[j]->amount)) fatal("Overflow adding node balance");