Skip to content

Commit 0c9dc4c

Browse files
committed
bkpr: remove unused "account_exits" parameter to account_get_balance().
Only used in tests. Signed-off-by: Rusty Russell <[email protected]>
1 parent b0231a5 commit 0c9dc4c

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

plugins/bkpr/bookkeeper.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,7 @@ static struct command_result *json_list_balances(struct command *cmd,
573573
err = account_get_balance(cmd, db,
574574
accts[i]->name,
575575
true,
576-
&balances,
577-
NULL);
576+
&balances);
578577

579578
if (err)
580579
plugin_err(cmd->plugin,
@@ -968,7 +967,7 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd,
968967

969968
db_begin_transaction(db);
970969
err = account_get_balance(tmpctx, db, info->acct->name,
971-
false, &balances, NULL);
970+
false, &balances);
972971
db_commit_transaction(db);
973972

974973
if (err)
@@ -1105,8 +1104,7 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
11051104
err = account_get_balance(cmd, db, acct_name,
11061105
/* Don't error if negative */
11071106
false,
1108-
&balances,
1109-
NULL);
1107+
&balances);
11101108

11111109
if (err)
11121110
plugin_err(cmd->plugin,
@@ -1410,7 +1408,7 @@ listpeerchannels_done(struct command *cmd,
14101408
info->ev->timestamp)) {
14111409
db_begin_transaction(db);
14121410
err = account_get_balance(tmpctx, db, info->acct->name,
1413-
false, &balances, NULL);
1411+
false, &balances);
14141412
db_commit_transaction(db);
14151413

14161414
if (err)

plugins/bkpr/recorder.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,7 @@ char *account_get_balance(const tal_t *ctx,
921921
struct db *db,
922922
const char *acct_name,
923923
bool calc_sum,
924-
struct acct_balance ***balances,
925-
bool *account_exists)
924+
struct acct_balance ***balances)
926925
{
927926
struct db_stmt *stmt;
928927

@@ -939,8 +938,6 @@ char *account_get_balance(const tal_t *ctx,
939938
db_bind_text(stmt, acct_name);
940939
db_query_prepared(stmt);
941940
*balances = tal_arr(ctx, struct acct_balance *, 0);
942-
if (account_exists)
943-
*account_exists = false;
944941

945942
while (db_step(stmt)) {
946943
struct acct_balance *bal;
@@ -951,9 +948,6 @@ char *account_get_balance(const tal_t *ctx,
951948
bal->credit = db_col_amount_msat(stmt, "credit");
952949
bal->debit = db_col_amount_msat(stmt, "debit");
953950
tal_arr_expand(balances, bal);
954-
955-
if (account_exists)
956-
*account_exists = true;
957951
}
958952
tal_free(stmt);
959953

plugins/bkpr/recorder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ char *account_get_balance(const tal_t *ctx,
124124
struct db *db,
125125
const char *acct_name,
126126
bool calc_sum,
127-
struct acct_balance ***balances,
128-
bool *account_exists);
127+
struct acct_balance ***balances);
129128

130129
/* Get chain fees for account */
131130
struct onchain_fee **account_get_chain_fees(const tal_t *ctx, struct db *db,

plugins/bkpr/test/run-recorder.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,6 @@ static bool test_account_balances(const tal_t *ctx, struct plugin *p)
11921192
struct account *acct, *acct2;
11931193
struct chain_event *ev1;
11941194
struct acct_balance **balances;
1195-
bool exists;
11961195
char *err;
11971196

11981197
memset(&peer_id, 3, sizeof(struct node_id));
@@ -1203,10 +1202,9 @@ static bool test_account_balances(const tal_t *ctx, struct plugin *p)
12031202
db_begin_transaction(db);
12041203
/* Check that account does not exist yet */
12051204
err = account_get_balance(ctx, db, acct->name, true,
1206-
&balances, &exists);
1205+
&balances);
12071206

12081207
CHECK(!err);
1209-
CHECK_MSG(!exists, "expected account not to exist");
12101208

12111209
account_add(db, acct);
12121210
account_add(db, acct2);
@@ -1253,7 +1251,7 @@ static bool test_account_balances(const tal_t *ctx, struct plugin *p)
12531251
log_chain_event(db, acct2, ev1);
12541252

12551253
err = account_get_balance(ctx, db, acct->name, true,
1256-
&balances, NULL);
1254+
&balances);
12571255
CHECK_MSG(!err, err);
12581256
db_commit_transaction(db);
12591257

@@ -1275,13 +1273,12 @@ static bool test_account_balances(const tal_t *ctx, struct plugin *p)
12751273
log_chain_event(db, acct, ev1);
12761274

12771275
err = account_get_balance(ctx, db, acct->name, true,
1278-
&balances, &exists);
1276+
&balances);
12791277
CHECK_MSG(err != NULL, "Expected err message");
12801278
CHECK(streq(err, "chf channel balance is negative? 5000msat - 5001msat"));
1281-
CHECK_MSG(exists, "expected account to exist");
12821279

12831280
err = account_get_balance(ctx, db, acct->name, false,
1284-
&balances, NULL);
1281+
&balances);
12851282
CHECK_MSG(!err, err);
12861283
db_commit_transaction(db);
12871284

0 commit comments

Comments
 (0)