bkpr: remove redundant account_onchain_fees
What changed, and why it matters
This commit removes an unused duplicate function from the bookkeeping plugin and switches the only test that used it to an equivalent existing function. There is no security-relevant change: the removed code and its replacement read the same database table with the same columns; the only difference was the sort order of results, which does not affect correctness here.
No security action required. This is a routine code-cleanup/refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes account_onchain_fees() from plugins/bkpr/onchain_fee.c and its header declaration. The function was a near-duplicate of account_get_chain_fees() (defined elsewhere) minus an ORDER BY clause, and was only referenced in plugins/bkpr/test/run-recorder.c. The test now calls account_get_chain_fees() instead. No query logic, permissions, input handling, or data flows changed in a security-relevant way.
Changed components
plugins/bkpr/onchain_fee.cplugins/bkpr/onchain_fee.hplugins/bkpr/test/run-recorder.cInspect captured patch +3 / −28
diff --git a/plugins/bkpr/onchain_fee.c b/plugins/bkpr/onchain_fee.c
index 158b90ab..32669b18 100644
--- a/plugins/bkpr/onchain_fee.c
+++ b/plugins/bkpr/onchain_fee.c
@@ -141,26 +141,6 @@ struct onchain_fee **list_chain_fees(const tal_t *ctx, struct db *db)
return list_chain_fees_timebox(ctx, db, 0, SQLITE_MAX_UINT);
}
-struct onchain_fee **account_onchain_fees(const tal_t *ctx,
- struct db *db,
- struct account *acct)
-{
- struct db_stmt *stmt;
-
- stmt = db_prepare_v2(db, SQL("SELECT"
- " of.account_name"
- ", of.txid"
- ", of.credit"
- ", of.debit"
- ", of.timestamp"
- ", of.update_count"
- " FROM onchain_fees of"
- " WHERE of.account_name = ?;"));
-
- db_bind_text(stmt, acct->name);
- return find_onchain_fees(ctx, take(stmt));
-}
-
static void insert_chain_fees_diff(struct db *db,
const char *acct_name,
struct bitcoin_txid *txid,
diff --git a/plugins/bkpr/onchain_fee.h b/plugins/bkpr/onchain_fee.h
index 093195c2..56fe2e75 100644
--- a/plugins/bkpr/onchain_fee.h
+++ b/plugins/bkpr/onchain_fee.h
@@ -33,11 +33,6 @@ struct onchain_fee {
void json_add_onchain_fee(struct json_stream *out,
struct onchain_fee *fee);
-/* Get all onchain fee records for this account */
-struct onchain_fee **account_onchain_fees(const tal_t *ctx,
- struct db *db,
- struct account *acct);
-
/* List all chain fees, for all accounts */
struct onchain_fee **list_chain_fees(const tal_t *ctx, struct db *db);
diff --git a/plugins/bkpr/test/run-recorder.c b/plugins/bkpr/test/run-recorder.c
index 3151163d..0a94d8ad 100644
--- a/plugins/bkpr/test/run-recorder.c
+++ b/plugins/bkpr/test/run-recorder.c
@@ -510,7 +510,7 @@ static bool test_onchain_fee_chan_close(const tal_t *ctx)
/* Expect: 1 onchain fee records, all for chan-1 */
db_begin_transaction(db);
ofs = list_chain_fees(ctx, db);
- ofs1 = account_onchain_fees(ctx, db, acct);
+ ofs1 = account_get_chain_fees(ctx, db, acct);
db_commit_transaction(db);
CHECK(tal_count(ofs) == tal_count(ofs1));
@@ -568,7 +568,7 @@ static bool test_onchain_fee_chan_close(const tal_t *ctx)
/* Expect: onchain fee records for tx except channel close */
db_begin_transaction(db);
ofs = list_chain_fees(ctx, db);
- ofs1 = account_onchain_fees(ctx, db, acct);
+ ofs1 = account_get_chain_fees(ctx, db, acct);
db_commit_transaction(db);
CHECK(tal_count(ofs) == tal_count(ofs1));
@@ -581,7 +581,7 @@ static bool test_onchain_fee_chan_close(const tal_t *ctx)
CHECK(acct->onchain_resolved_block == blockheight + 2);
err = update_channel_onchain_fees(ctx, db, acct);
CHECK_MSG(!err, err);
- ofs = account_onchain_fees(ctx, db, acct);
+ ofs = account_get_chain_fees(ctx, db, acct);
db_commit_transaction(db);
/* Expect: fees as follows
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.