Skip to content

Commit b1fa2ef

Browse files
committed
bkpr: remove different currency support.
We still output the fields, they're just always the currency of the node. Signed-off-by: Rusty Russell <[email protected]> Changelog-Changed: Plugins: `bookkeeper` now explicitly assumes every transaction is in the same currency as the node (true unless you added manually)
1 parent 47c2735 commit b1fa2ef

File tree

15 files changed

+34
-138
lines changed

15 files changed

+34
-138
lines changed

onchaind/test/run-grind_feerate-bug.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ struct chain_coin_mvt *new_coin_external_spend(const tal_t *ctx UNNEEDED,
134134
struct mvt_tags tags)
135135

136136
{ fprintf(stderr, "new_coin_external_spend called!\n"); abort(); }
137-
/* Generated stub for new_coin_wallet_deposit */
138-
struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED,
139-
const struct bitcoin_outpoint *outpoint UNNEEDED,
140-
u32 blockheight UNNEEDED,
141-
struct amount_sat amount UNNEEDED,
142-
struct mvt_tags tags)
143-
144-
{ fprintf(stderr, "new_coin_wallet_deposit called!\n"); abort(); }
145137
/* Generated stub for new_onchain_htlc_deposit */
146138
struct chain_coin_mvt *new_onchain_htlc_deposit(const tal_t *ctx UNNEEDED,
147139
const struct bitcoin_outpoint *outpoint UNNEEDED,

onchaind/test/run-grind_feerate.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,6 @@ struct chain_coin_mvt *new_coin_external_spend(const tal_t *ctx UNNEEDED,
184184
struct mvt_tags tags)
185185

186186
{ fprintf(stderr, "new_coin_external_spend called!\n"); abort(); }
187-
/* Generated stub for new_coin_wallet_deposit */
188-
struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED,
189-
const struct bitcoin_outpoint *outpoint UNNEEDED,
190-
u32 blockheight UNNEEDED,
191-
struct amount_sat amount UNNEEDED,
192-
struct mvt_tags tags)
193-
194-
{ fprintf(stderr, "new_coin_wallet_deposit called!\n"); abort(); }
195187
/* Generated stub for new_onchain_htlc_deposit */
196188
struct chain_coin_mvt *new_onchain_htlc_deposit(const tal_t *ctx UNNEEDED,
197189
const struct bitcoin_outpoint *outpoint UNNEEDED,

plugins/bkpr/bookkeeper.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ static struct command_result *json_inspect(struct command *cmd,
316316
ev->output_value);
317317
json_add_amount_msat(res, "credit_msat",
318318
ev->credit);
319-
json_add_string(res, "currency", ev->currency);
319+
json_add_string(res, "currency",
320+
chainparams->lightning_hrp);
320321
if (ev->origin_acct)
321322
json_add_string(res, "originating_account",
322323
ev->origin_acct);
@@ -333,7 +334,7 @@ static struct command_result *json_inspect(struct command *cmd,
333334
"output_value_msat",
334335
ev->output_value);
335336
json_add_string(res, "currency",
336-
ev->currency);
337+
chainparams->lightning_hrp);
337338
}
338339
json_add_string(res, "spend_tag", ev->tag);
339340
json_add_txid(res, "spending_txid",
@@ -628,7 +629,6 @@ struct new_account_info {
628629
struct account *acct;
629630
struct amount_msat curr_bal;
630631
u32 timestamp;
631-
char *currency;
632632
};
633633

634634
static void try_update_open_fees(struct command *cmd,
@@ -709,7 +709,6 @@ static bool new_missed_channel_account(struct command *cmd,
709709
const char *buf,
710710
const jsmntok_t *result,
711711
struct account *acct,
712-
const char *currency,
713712
u64 timestamp)
714713
{
715714
struct chain_event *chain_ev;
@@ -762,7 +761,6 @@ static bool new_missed_channel_account(struct command *cmd,
762761
ok = amount_msat_add(&chain_ev->output_value,
763762
amt, remote_amt);
764763
assert(ok);
765-
chain_ev->currency = tal_strdup(chain_ev, currency);
766764
chain_ev->origin_acct = NULL;
767765
/* 2s before the channel opened, minimum */
768766
chain_ev->timestamp = timestamp - 2;
@@ -821,7 +819,6 @@ static bool new_missed_channel_account(struct command *cmd,
821819
push_credit,
822820
push_debit,
823821
AMOUNT_MSAT(0),
824-
currency,
825822
NULL, 0,
826823
timestamp - 1);
827824
log_channel_event(db, acct, chan_ev);
@@ -905,7 +902,6 @@ static char *msat_find_diff(struct amount_msat balance,
905902
}
906903

907904
static void log_journal_entry(struct account *acct,
908-
const char *currency,
909905
u64 timestamp,
910906
struct amount_msat credit_diff,
911907
struct amount_msat debit_diff)
@@ -923,7 +919,6 @@ static void log_journal_entry(struct account *acct,
923919
credit_diff,
924920
debit_diff,
925921
AMOUNT_MSAT(0),
926-
currency,
927922
NULL, 0,
928923
timestamp);
929924
db_begin_transaction(db);
@@ -959,7 +954,6 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd,
959954

960955
if (!new_missed_channel_account(cmd, buf, result,
961956
info->acct,
962-
info->currency,
963957
info->timestamp)) {
964958
plugin_log(cmd->plugin, LOG_BROKEN,
965959
"Unable to find account %s in listpeerchannels",
@@ -981,7 +975,6 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd,
981975
plugin_err(cmd->plugin, "%s", err);
982976

983977
log_journal_entry(info->acct,
984-
info->currency,
985978
info->timestamp - 1,
986979
credit_diff, debit_diff);
987980
}
@@ -1068,17 +1061,14 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
10681061
json_for_each_arr(i, acct_tok, accounts_tok) {
10691062
struct account *acct;
10701063
struct amount_msat snap_balance, credit, debit, credit_diff, debit_diff;
1071-
char *acct_name, *currency;
1064+
char *acct_name;
10721065
bool existed;
10731066

10741067
err = json_scan(cmd, buf, acct_tok,
10751068
"{account_id:%"
1076-
",balance_msat:%"
1077-
",coin_type:%}",
1069+
",balance_msat:%}",
10781070
JSON_SCAN_TAL(tmpctx, json_strdup, &acct_name),
1079-
JSON_SCAN(json_to_msat, &snap_balance),
1080-
JSON_SCAN_TAL(tmpctx, json_strdup,
1081-
&currency));
1071+
JSON_SCAN(json_to_msat, &snap_balance));
10821072
if (err)
10831073
plugin_err(cmd->plugin,
10841074
"`balance_snapshot` payload did not"
@@ -1129,8 +1119,6 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
11291119
info->acct = tal_steal(info, acct);
11301120
info->curr_bal = snap_balance;
11311121
info->timestamp = timestamp_now;
1132-
info->currency =
1133-
tal_strdup(info, currency);
11341122

11351123
tal_arr_expand(&new_accts, info);
11361124
continue;
@@ -1155,7 +1143,6 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
11551143
credit_diff,
11561144
debit_diff,
11571145
AMOUNT_MSAT(0),
1158-
currency,
11591146
NULL, 0,
11601147
timestamp);
11611148

@@ -1372,7 +1359,6 @@ listpeerchannels_done(struct command *cmd,
13721359

13731360
if (new_missed_channel_account(cmd, buf, result,
13741361
info->acct,
1375-
info->ev->currency,
13761362
info->ev->timestamp)) {
13771363
db_begin_transaction(db);
13781364
account_get_credit_debit(cmd->plugin, db, info->acct->name,
@@ -1389,7 +1375,6 @@ listpeerchannels_done(struct command *cmd,
13891375
plugin_err(cmd->plugin, "%s", err);
13901376

13911377
log_journal_entry(info->acct,
1392-
info->ev->currency,
13931378
info->ev->timestamp - 1,
13941379
credit_diff, debit_diff);
13951380
} else
@@ -1509,7 +1494,6 @@ parse_and_log_chain_move(struct command *cmd,
15091494

15101495
e->credit = credit;
15111496
e->debit = debit;
1512-
e->currency = tal_steal(e, coin_type);
15131497
e->timestamp = timestamp;
15141498
e->tag = mvt_tag_str(tags[0]);
15151499
e->desc = tal_steal(e, desc);
@@ -1671,7 +1655,6 @@ parse_and_log_channel_move(struct command *cmd,
16711655

16721656
e->credit = credit;
16731657
e->debit = debit;
1674-
e->currency = tal_steal(e, coin_type);
16751658
e->timestamp = timestamp;
16761659
e->tag = mvt_tag_str(tags[0]);
16771660
e->desc = tal_steal(e, desc);
@@ -1747,15 +1730,13 @@ static struct command_result *json_utxo_deposit(struct command *cmd, const char
17471730
",transfer_from:%"
17481731
",outpoint:%"
17491732
",amount_msat:%"
1750-
",coin_type:%"
17511733
",timestamp:%"
17521734
",blockheight:%"
17531735
"}}}",
17541736
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->acct_name),
17551737
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->origin_acct),
17561738
JSON_SCAN(json_to_outpoint, &ev->outpoint),
17571739
JSON_SCAN(json_to_msat, &ev->credit),
1758-
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->currency),
17591740
JSON_SCAN(json_to_u64, &ev->timestamp),
17601741
JSON_SCAN(json_to_u32, &ev->blockheight));
17611742

@@ -1824,15 +1805,13 @@ static struct command_result *json_utxo_spend(struct command *cmd, const char *b
18241805
",outpoint:%"
18251806
",spending_txid:%"
18261807
",amount_msat:%"
1827-
",coin_type:%"
18281808
",timestamp:%"
18291809
",blockheight:%"
18301810
"}}}",
18311811
JSON_SCAN_TAL(tmpctx, json_strdup, &acct_name),
18321812
JSON_SCAN(json_to_outpoint, &ev->outpoint),
18331813
JSON_SCAN(json_to_txid, ev->spending_txid),
18341814
JSON_SCAN(json_to_msat, &ev->debit),
1835-
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->currency),
18361815
JSON_SCAN(json_to_u64, &ev->timestamp),
18371816
JSON_SCAN(json_to_u32, &ev->blockheight));
18381817

plugins/bkpr/chain_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void json_add_chain_event(struct json_stream *out, struct chain_event *ev)
1313
json_add_string(out, "tag", ev->tag);
1414
json_add_amount_msat(out, "credit_msat", ev->credit);
1515
json_add_amount_msat(out, "debit_msat", ev->debit);
16-
json_add_string(out, "currency", ev->currency);
16+
json_add_string(out, "currency", chainparams->lightning_hrp);
1717
json_add_outpoint(out, "outpoint", &ev->outpoint);
1818

1919
if (ev->spending_txid)

plugins/bkpr/chain_event.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ struct chain_event {
4747
/* Total 'amount' of output on this chain event */
4848
struct amount_msat output_value;
4949

50-
/* What token are the credit/debits? */
51-
const char *currency;
52-
5350
/* What time did the event happen */
5451
u64 timestamp;
5552

plugins/bkpr/channel_event.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "config.h"
22

3+
#include <bitcoin/chainparams.h>
34
#include <ccan/crypto/sha256/sha256.h>
45
#include <ccan/tal/str/str.h>
56
#include <common/amount.h>
@@ -11,7 +12,6 @@ struct channel_event *new_channel_event(const tal_t *ctx,
1112
struct amount_msat credit,
1213
struct amount_msat debit,
1314
struct amount_msat fees,
14-
const char *currency,
1515
struct sha256 *payment_id STEALS,
1616
u32 part_id,
1717
u64 timestamp)
@@ -22,7 +22,6 @@ struct channel_event *new_channel_event(const tal_t *ctx,
2222
ev->credit = credit;
2323
ev->debit = debit;
2424
ev->fees = fees;
25-
ev->currency = tal_strdup(ev, currency);
2625
ev->payment_id = tal_steal(ev, payment_id);
2726
ev->part_id = part_id;
2827
ev->timestamp = timestamp;
@@ -43,7 +42,7 @@ void json_add_channel_event(struct json_stream *out,
4342
json_add_amount_msat(out, "debit_msat", ev->debit);
4443
if (!amount_msat_is_zero(ev->fees))
4544
json_add_amount_msat(out, "fees_msat", ev->fees);
46-
json_add_string(out, "currency", ev->currency);
45+
json_add_string(out, "currency", chainparams->lightning_hrp);
4746
if (ev->payment_id) {
4847
json_add_sha256(out, "payment_id", ev->payment_id);
4948
json_add_u32(out, "part_id", ev->part_id);

plugins/bkpr/channel_event.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ struct channel_event {
3232
/* Total 'fees' related to this channel event */
3333
struct amount_msat fees;
3434

35-
/* What token are the credit/debits? */
36-
const char *currency;
37-
3835
/* Payment identifier (typically the preimage hash) */
3936
struct sha256 *payment_id;
4037

@@ -56,7 +53,6 @@ struct channel_event *new_channel_event(const tal_t *ctx,
5653
struct amount_msat credit,
5754
struct amount_msat debit,
5855
struct amount_msat fees,
59-
const char *currency,
6056
struct sha256 *payment_id STEALS,
6157
u32 part_id,
6258
u64 timestamp);

0 commit comments

Comments
 (0)