bkpr: remove different currency support.

We still output the fields, they're just always the currency of the node.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `bookkeeper` now explicitly assumes every transaction is in the same currency as the node (true unless you added manually)
This commit is contained in:
Rusty Russell
2025-08-14 10:57:56 +09:30
parent 47c2735e17
commit b1fa2ef30b
15 changed files with 34 additions and 138 deletions

View File

@@ -134,14 +134,6 @@ struct chain_coin_mvt *new_coin_external_spend(const tal_t *ctx UNNEEDED,
struct mvt_tags tags)
{ fprintf(stderr, "new_coin_external_spend called!\n"); abort(); }
/* Generated stub for new_coin_wallet_deposit */
struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED,
u32 blockheight UNNEEDED,
struct amount_sat amount UNNEEDED,
struct mvt_tags tags)
{ fprintf(stderr, "new_coin_wallet_deposit called!\n"); abort(); }
/* Generated stub for new_onchain_htlc_deposit */
struct chain_coin_mvt *new_onchain_htlc_deposit(const tal_t *ctx UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED,

View File

@@ -184,14 +184,6 @@ struct chain_coin_mvt *new_coin_external_spend(const tal_t *ctx UNNEEDED,
struct mvt_tags tags)
{ fprintf(stderr, "new_coin_external_spend called!\n"); abort(); }
/* Generated stub for new_coin_wallet_deposit */
struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED,
u32 blockheight UNNEEDED,
struct amount_sat amount UNNEEDED,
struct mvt_tags tags)
{ fprintf(stderr, "new_coin_wallet_deposit called!\n"); abort(); }
/* Generated stub for new_onchain_htlc_deposit */
struct chain_coin_mvt *new_onchain_htlc_deposit(const tal_t *ctx UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED,

View File

@@ -316,7 +316,8 @@ static struct command_result *json_inspect(struct command *cmd,
ev->output_value);
json_add_amount_msat(res, "credit_msat",
ev->credit);
json_add_string(res, "currency", ev->currency);
json_add_string(res, "currency",
chainparams->lightning_hrp);
if (ev->origin_acct)
json_add_string(res, "originating_account",
ev->origin_acct);
@@ -333,7 +334,7 @@ static struct command_result *json_inspect(struct command *cmd,
"output_value_msat",
ev->output_value);
json_add_string(res, "currency",
ev->currency);
chainparams->lightning_hrp);
}
json_add_string(res, "spend_tag", ev->tag);
json_add_txid(res, "spending_txid",
@@ -628,7 +629,6 @@ struct new_account_info {
struct account *acct;
struct amount_msat curr_bal;
u32 timestamp;
char *currency;
};
static void try_update_open_fees(struct command *cmd,
@@ -709,7 +709,6 @@ static bool new_missed_channel_account(struct command *cmd,
const char *buf,
const jsmntok_t *result,
struct account *acct,
const char *currency,
u64 timestamp)
{
struct chain_event *chain_ev;
@@ -762,7 +761,6 @@ static bool new_missed_channel_account(struct command *cmd,
ok = amount_msat_add(&chain_ev->output_value,
amt, remote_amt);
assert(ok);
chain_ev->currency = tal_strdup(chain_ev, currency);
chain_ev->origin_acct = NULL;
/* 2s before the channel opened, minimum */
chain_ev->timestamp = timestamp - 2;
@@ -821,7 +819,6 @@ static bool new_missed_channel_account(struct command *cmd,
push_credit,
push_debit,
AMOUNT_MSAT(0),
currency,
NULL, 0,
timestamp - 1);
log_channel_event(db, acct, chan_ev);
@@ -905,7 +902,6 @@ static char *msat_find_diff(struct amount_msat balance,
}
static void log_journal_entry(struct account *acct,
const char *currency,
u64 timestamp,
struct amount_msat credit_diff,
struct amount_msat debit_diff)
@@ -923,7 +919,6 @@ static void log_journal_entry(struct account *acct,
credit_diff,
debit_diff,
AMOUNT_MSAT(0),
currency,
NULL, 0,
timestamp);
db_begin_transaction(db);
@@ -959,7 +954,6 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd,
if (!new_missed_channel_account(cmd, buf, result,
info->acct,
info->currency,
info->timestamp)) {
plugin_log(cmd->plugin, LOG_BROKEN,
"Unable to find account %s in listpeerchannels",
@@ -981,7 +975,6 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd,
plugin_err(cmd->plugin, "%s", err);
log_journal_entry(info->acct,
info->currency,
info->timestamp - 1,
credit_diff, debit_diff);
}
@@ -1068,17 +1061,14 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
json_for_each_arr(i, acct_tok, accounts_tok) {
struct account *acct;
struct amount_msat snap_balance, credit, debit, credit_diff, debit_diff;
char *acct_name, *currency;
char *acct_name;
bool existed;
err = json_scan(cmd, buf, acct_tok,
"{account_id:%"
",balance_msat:%"
",coin_type:%}",
",balance_msat:%}",
JSON_SCAN_TAL(tmpctx, json_strdup, &acct_name),
JSON_SCAN(json_to_msat, &snap_balance),
JSON_SCAN_TAL(tmpctx, json_strdup,
&currency));
JSON_SCAN(json_to_msat, &snap_balance));
if (err)
plugin_err(cmd->plugin,
"`balance_snapshot` payload did not"
@@ -1129,8 +1119,6 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
info->acct = tal_steal(info, acct);
info->curr_bal = snap_balance;
info->timestamp = timestamp_now;
info->currency =
tal_strdup(info, currency);
tal_arr_expand(&new_accts, info);
continue;
@@ -1155,7 +1143,6 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
credit_diff,
debit_diff,
AMOUNT_MSAT(0),
currency,
NULL, 0,
timestamp);
@@ -1372,7 +1359,6 @@ listpeerchannels_done(struct command *cmd,
if (new_missed_channel_account(cmd, buf, result,
info->acct,
info->ev->currency,
info->ev->timestamp)) {
db_begin_transaction(db);
account_get_credit_debit(cmd->plugin, db, info->acct->name,
@@ -1389,7 +1375,6 @@ listpeerchannels_done(struct command *cmd,
plugin_err(cmd->plugin, "%s", err);
log_journal_entry(info->acct,
info->ev->currency,
info->ev->timestamp - 1,
credit_diff, debit_diff);
} else
@@ -1509,7 +1494,6 @@ parse_and_log_chain_move(struct command *cmd,
e->credit = credit;
e->debit = debit;
e->currency = tal_steal(e, coin_type);
e->timestamp = timestamp;
e->tag = mvt_tag_str(tags[0]);
e->desc = tal_steal(e, desc);
@@ -1671,7 +1655,6 @@ parse_and_log_channel_move(struct command *cmd,
e->credit = credit;
e->debit = debit;
e->currency = tal_steal(e, coin_type);
e->timestamp = timestamp;
e->tag = mvt_tag_str(tags[0]);
e->desc = tal_steal(e, desc);
@@ -1747,7 +1730,6 @@ static struct command_result *json_utxo_deposit(struct command *cmd, const char
",transfer_from:%"
",outpoint:%"
",amount_msat:%"
",coin_type:%"
",timestamp:%"
",blockheight:%"
"}}}",
@@ -1755,7 +1737,6 @@ static struct command_result *json_utxo_deposit(struct command *cmd, const char
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->origin_acct),
JSON_SCAN(json_to_outpoint, &ev->outpoint),
JSON_SCAN(json_to_msat, &ev->credit),
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->currency),
JSON_SCAN(json_to_u64, &ev->timestamp),
JSON_SCAN(json_to_u32, &ev->blockheight));
@@ -1824,7 +1805,6 @@ static struct command_result *json_utxo_spend(struct command *cmd, const char *b
",outpoint:%"
",spending_txid:%"
",amount_msat:%"
",coin_type:%"
",timestamp:%"
",blockheight:%"
"}}}",
@@ -1832,7 +1812,6 @@ static struct command_result *json_utxo_spend(struct command *cmd, const char *b
JSON_SCAN(json_to_outpoint, &ev->outpoint),
JSON_SCAN(json_to_txid, ev->spending_txid),
JSON_SCAN(json_to_msat, &ev->debit),
JSON_SCAN_TAL(tmpctx, json_strdup, &ev->currency),
JSON_SCAN(json_to_u64, &ev->timestamp),
JSON_SCAN(json_to_u32, &ev->blockheight));

View File

@@ -13,7 +13,7 @@ void json_add_chain_event(struct json_stream *out, struct chain_event *ev)
json_add_string(out, "tag", ev->tag);
json_add_amount_msat(out, "credit_msat", ev->credit);
json_add_amount_msat(out, "debit_msat", ev->debit);
json_add_string(out, "currency", ev->currency);
json_add_string(out, "currency", chainparams->lightning_hrp);
json_add_outpoint(out, "outpoint", &ev->outpoint);
if (ev->spending_txid)

View File

@@ -47,9 +47,6 @@ struct chain_event {
/* Total 'amount' of output on this chain event */
struct amount_msat output_value;
/* What token are the credit/debits? */
const char *currency;
/* What time did the event happen */
u64 timestamp;

View File

@@ -1,5 +1,6 @@
#include "config.h"
#include <bitcoin/chainparams.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/tal/str/str.h>
#include <common/amount.h>
@@ -11,7 +12,6 @@ struct channel_event *new_channel_event(const tal_t *ctx,
struct amount_msat credit,
struct amount_msat debit,
struct amount_msat fees,
const char *currency,
struct sha256 *payment_id STEALS,
u32 part_id,
u64 timestamp)
@@ -22,7 +22,6 @@ struct channel_event *new_channel_event(const tal_t *ctx,
ev->credit = credit;
ev->debit = debit;
ev->fees = fees;
ev->currency = tal_strdup(ev, currency);
ev->payment_id = tal_steal(ev, payment_id);
ev->part_id = part_id;
ev->timestamp = timestamp;
@@ -43,7 +42,7 @@ void json_add_channel_event(struct json_stream *out,
json_add_amount_msat(out, "debit_msat", ev->debit);
if (!amount_msat_is_zero(ev->fees))
json_add_amount_msat(out, "fees_msat", ev->fees);
json_add_string(out, "currency", ev->currency);
json_add_string(out, "currency", chainparams->lightning_hrp);
if (ev->payment_id) {
json_add_sha256(out, "payment_id", ev->payment_id);
json_add_u32(out, "part_id", ev->part_id);

View File

@@ -32,9 +32,6 @@ struct channel_event {
/* Total 'fees' related to this channel event */
struct amount_msat fees;
/* What token are the credit/debits? */
const char *currency;
/* Payment identifier (typically the preimage hash) */
struct sha256 *payment_id;
@@ -56,7 +53,6 @@ struct channel_event *new_channel_event(const tal_t *ctx,
struct amount_msat credit,
struct amount_msat debit,
struct amount_msat fees,
const char *currency,
struct sha256 *payment_id STEALS,
u32 part_id,
u64 timestamp);

View File

@@ -1,4 +1,5 @@
#include "config.h"
#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
#include <ccan/tal/str/str.h>
#include <common/coin_mvt.h>
@@ -43,7 +44,6 @@ static struct income_event *chain_to_income(const tal_t *ctx,
inc->credit = credit;
inc->debit = debit;
inc->fees = AMOUNT_MSAT(0);
inc->currency = tal_strdup(inc, ev->currency);
inc->timestamp = ev->timestamp;
inc->outpoint = tal_dup(inc, struct bitcoin_outpoint, &ev->outpoint);
inc->desc = tal_strdup_or_null(inc, ev->desc);
@@ -65,7 +65,6 @@ static struct income_event *channel_to_income(const tal_t *ctx,
inc->credit = credit;
inc->debit = debit;
inc->fees = ev->fees;
inc->currency = tal_strdup(inc, ev->currency);
inc->timestamp = ev->timestamp;
inc->outpoint = NULL;
inc->txid = NULL;
@@ -86,7 +85,6 @@ static struct income_event *onchainfee_to_income(const tal_t *ctx,
inc->credit = fee->debit;
inc->debit = fee->credit;
inc->fees = AMOUNT_MSAT(0);
inc->currency = tal_strdup(inc, fee->currency);
inc->timestamp = fee->timestamp;
inc->txid = tal_dup(inc, struct bitcoin_txid, &fee->txid);
inc->outpoint = NULL;
@@ -296,7 +294,6 @@ static struct onchain_fee **find_consolidated_fees(const tal_t *ctx,
fee = tal(fee_sums, struct onchain_fee);
fee->credit = sums[i]->fees_paid;
fee->debit = AMOUNT_MSAT(0);
fee->currency = tal_steal(fee, sums[i]->currency);
fee->acct_name = tal_steal(fee, sums[i]->acct_name);
fee->txid = *sums[i]->txid;
@@ -429,7 +426,7 @@ void json_add_income_event(struct json_stream *out, struct income_event *ev)
json_add_string(out, "tag", ev->tag);
json_add_amount_msat(out, "credit_msat", ev->credit);
json_add_amount_msat(out, "debit_msat", ev->debit);
json_add_string(out, "currency", ev->currency);
json_add_string(out, "currency", chainparams->lightning_hrp);
json_add_u64(out, "timestamp", ev->timestamp);
if (ev->desc)
@@ -454,16 +451,6 @@ const char *csv_filename(const tal_t *ctx, const struct csv_fmt *fmt)
(unsigned long)time_now().ts.tv_sec);
}
static char *convert_asset_type(struct income_event *ev)
{
/* We use the bech32 human readable part which is "bc"
* for mainnet -> map to 'BTC' for cointracker */
if (streq(ev->currency, "bc"))
return "btc";
return ev->currency;
}
static void cointrack_header(FILE *csvf)
{
fprintf(csvf,
@@ -494,6 +481,15 @@ static char *income_event_cointrack_type(const struct income_event *ev)
return "";
}
/* We use the bech32 human readable part which is "bc"
* for mainnet -> map to 'BTC' for cointracker */
static const char *asset_type_name(void)
{
if (streq(chainparams->lightning_hrp, "bc"))
return "btc";
return chainparams->lightning_hrp;
}
static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
{
/* Date mm/dd/yyyy HH:MM:SS UTC */
@@ -515,7 +511,7 @@ static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *e
if (!amount_msat_is_zero(ev->credit)) {
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
fprintf(csvf, ",");
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
} else
fprintf(csvf, ",");
@@ -525,7 +521,7 @@ static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *e
if (!amount_msat_is_zero(ev->debit)) {
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
fprintf(csvf, ",");
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
} else
fprintf(csvf, ",");
@@ -536,7 +532,7 @@ static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *e
&& streq(ev->tag, mvt_tag_str(MVT_INVOICE))) {
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
fprintf(csvf, ",");
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
} else
fprintf(csvf, ",");
@@ -587,7 +583,7 @@ static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
if (!amount_msat_is_zero(ev->debit)) {
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
fprintf(csvf, ",");
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
} else
fprintf(csvf, ",");
@@ -597,7 +593,7 @@ static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
if (!amount_msat_is_zero(ev->credit)) {
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
fprintf(csvf, ",");
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
} else
fprintf(csvf, ",");
@@ -609,7 +605,7 @@ static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
&& streq(ev->tag, mvt_tag_str(MVT_INVOICE))) {
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
fprintf(csvf, ",");
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
} else
fprintf(csvf, ",");
@@ -728,7 +724,7 @@ static void harmony_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
fprintf(csvf, ",");
/* ",Asset" */
fprintf(csvf, "%s", convert_asset_type(ev));
fprintf(csvf, "%s", asset_type_name());
fprintf(csvf, ",");
/* ",Transaction ID" */
@@ -794,7 +790,7 @@ static void quickbooks_entry(const tal_t *ctx, FILE *csvf, struct income_event *
/* Description */
fprintf(csvf, "%s (%s) %s: %s",
ev->tag, ev->acct_name, ev->currency,
ev->tag, ev->acct_name, asset_type_name(),
ev->desc ? csv_safe_str(ev, ev->desc) : "no desc");
fprintf(csvf, ",");

View File

@@ -14,7 +14,6 @@ struct income_event {
/* Some CSVs require us to put fees on the
* same line as another entry */
struct amount_msat fees;
char *currency;
u64 timestamp;
struct bitcoin_outpoint *outpoint;

View File

@@ -1,4 +1,5 @@
#include "config.h"
#include <bitcoin/chainparams.h>
#include <common/json_stream.h>
#include <plugins/bkpr/onchain_fee.h>
@@ -12,7 +13,7 @@ void json_add_onchain_fee(struct json_stream *out,
json_add_string(out, "tag", "onchain_fee");
json_add_amount_msat(out, "credit_msat", fee->credit);
json_add_amount_msat(out, "debit_msat", fee->debit);
json_add_string(out, "currency", fee->currency);
json_add_string(out, "currency", chainparams->lightning_hrp);
json_add_u64(out, "timestamp", fee->timestamp);
json_add_txid(out, "txid", &fee->txid);
json_object_end(out);

View File

@@ -23,9 +23,6 @@ struct onchain_fee {
struct amount_msat credit;
struct amount_msat debit;
/* What token are fees? */
char *currency;
/* Timestamp of the event that created this fee update */
u64 timestamp;

View File

@@ -36,7 +36,6 @@ static struct chain_event *stmt2chain_event(const tal_t *ctx, struct db_stmt *st
e->debit = db_col_amount_msat(stmt, "e.debit");
e->output_value = db_col_amount_msat(stmt, "e.output_value");
e->currency = db_col_strdup(e, stmt, "e.currency");
e->timestamp = db_col_u64(stmt, "e.timestamp");
e->blockheight = db_col_int(stmt, "e.blockheight");
@@ -101,7 +100,6 @@ static struct channel_event *stmt2channel_event(const tal_t *ctx, struct db_stmt
e->debit = db_col_amount_msat(stmt, "e.debit");
e->fees = db_col_amount_msat(stmt, "e.fees");
e->currency = db_col_strdup(e, stmt, "e.currency");
if (!db_col_is_null(stmt, "e.payment_id")) {
e->payment_id = tal(e, struct sha256);
db_col_sha256(stmt, "e.payment_id", e->payment_id);
@@ -174,7 +172,6 @@ struct chain_event **list_chain_events_timebox(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -216,7 +213,6 @@ struct chain_event **account_get_chain_events(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -251,7 +247,6 @@ static struct chain_event **find_txos_for_tx(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -283,7 +278,6 @@ struct fee_sum **calculate_onchain_fee_sums(const tal_t *ctx, struct db *db)
" of.txid"
", of.account_id"
", a.name"
", of.currency"
", CAST(SUM(of.credit) AS BIGINT) as credit"
", CAST(SUM(of.debit) AS BIGINT) as debit"
" FROM onchain_fees of"
@@ -292,7 +286,6 @@ struct fee_sum **calculate_onchain_fee_sums(const tal_t *ctx, struct db *db)
" GROUP BY of.txid"
", of.account_id"
", a.name"
", of.currency"
" ORDER BY txid, account_id"));
db_query_prepared(stmt);
@@ -309,7 +302,6 @@ struct fee_sum **calculate_onchain_fee_sums(const tal_t *ctx, struct db *db)
db_col_txid(stmt, "of.txid", sum->txid);
sum->acct_db_id = db_col_u64(stmt, "of.account_id");
sum->acct_name = db_col_strdup(sum, stmt, "a.name");
sum->currency = db_col_strdup(sum, stmt, "of.currency");
sum->fees_paid = db_col_amount_msat(stmt, "credit");
debit = db_col_amount_msat(stmt, "debit");
@@ -706,7 +698,6 @@ struct chain_event *find_chain_event_by_id(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -749,7 +740,6 @@ struct chain_event **get_chain_events_by_outpoint(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -776,7 +766,6 @@ struct chain_event **get_chain_events_by_outpoint(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -812,7 +801,6 @@ struct chain_event **get_chain_events_by_id(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -853,7 +841,6 @@ static struct chain_event *find_chain_event(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -882,7 +869,6 @@ static struct chain_event *find_chain_event(const tal_t *ctx,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -1003,7 +989,6 @@ struct channel_event **list_channel_events_timebox(const tal_t *ctx,
", e.credit"
", e.debit"
", e.fees"
", e.currency"
", e.payment_id"
", e.part_id"
", e.timestamp"
@@ -1050,7 +1035,6 @@ struct channel_event **account_get_channel_events(const tal_t *ctx,
", e.credit"
", e.debit"
", e.fees"
", e.currency"
", e.payment_id"
", e.part_id"
", e.timestamp"
@@ -1080,7 +1064,6 @@ struct channel_event **get_channel_events_by_id(const tal_t *ctx,
", e.credit"
", e.debit"
", e.fees"
", e.currency"
", e.payment_id"
", e.part_id"
", e.timestamp"
@@ -1106,7 +1089,6 @@ static struct onchain_fee *stmt2onchain_fee(const tal_t *ctx,
db_col_txid(stmt, "of.txid", &of->txid);
of->credit = db_col_amount_msat(stmt, "of.credit");
of->debit = db_col_amount_msat(stmt, "of.debit");
of->currency = db_col_strdup(of, stmt, "of.currency");
of->timestamp = db_col_u64(stmt, "of.timestamp");
of->update_count = db_col_int(stmt, "of.update_count");
@@ -1144,7 +1126,6 @@ struct onchain_fee **account_get_chain_fees(const tal_t *ctx, struct db *db,
", of.txid"
", of.credit"
", of.debit"
", of.currency"
", of.timestamp"
", of.update_count"
" FROM onchain_fees of"
@@ -1171,7 +1152,6 @@ struct onchain_fee **get_chain_fees_by_txid(const tal_t *ctx, struct db *db,
", of.txid"
", of.credit"
", of.debit"
", of.currency"
", of.timestamp"
", of.update_count"
" FROM onchain_fees of"
@@ -1198,7 +1178,6 @@ struct onchain_fee **list_chain_fees_timebox(const tal_t *ctx, struct db *db,
", of.txid"
", of.credit"
", of.debit"
", of.currency"
", of.timestamp"
", of.update_count"
" FROM onchain_fees of"
@@ -1306,7 +1285,6 @@ struct onchain_fee **account_onchain_fees(const tal_t *ctx,
", of.txid"
", of.credit"
", of.debit"
", of.currency"
", of.timestamp"
", of.update_count"
" FROM onchain_fees of"
@@ -1495,7 +1473,6 @@ void log_channel_event(struct db *db,
", credit"
", debit"
", fees"
", currency"
", payment_id"
", part_id"
", timestamp"
@@ -1503,14 +1480,13 @@ void log_channel_event(struct db *db,
", rebalance_id"
")"
" VALUES"
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
db_bind_u64(stmt, acct->db_id);
db_bind_text(stmt, e->tag);
db_bind_amount_msat(stmt, e->credit);
db_bind_amount_msat(stmt, e->debit);
db_bind_amount_msat(stmt, e->fees);
db_bind_text(stmt, e->currency);
if (e->payment_id)
db_bind_sha256(stmt, e->payment_id);
else
@@ -1548,7 +1524,6 @@ struct chain_event **find_chain_events_bytxid(const tal_t *ctx, struct db *db,
", e.credit"
", e.debit"
", e.output_value"
", e.currency"
", e.timestamp"
", e.blockheight"
", e.utxo_txid"
@@ -1595,7 +1570,6 @@ static void insert_chain_fees_diff(struct db *db,
u64 acct_id,
struct bitcoin_txid *txid,
struct amount_msat amount,
const char *currency,
u64 timestamp)
{
struct db_stmt *stmt;
@@ -1653,17 +1627,15 @@ static void insert_chain_fees_diff(struct db *db,
", txid"
", credit"
", debit"
", currency"
", timestamp"
", update_count"
") VALUES"
" (?, ?, ?, ?, ?, ?, ?);"));
" (?, ?, ?, ?, ?, ?);"));
db_bind_u64(stmt, acct_id);
db_bind_txid(stmt, txid);
db_bind_amount_msat(stmt, credit);
db_bind_amount_msat(stmt, debit);
db_bind_text(stmt, currency);
db_bind_u64(stmt, timestamp);
db_bind_int(stmt, ++update_count);
db_exec_prepared_v2(take(stmt));
@@ -1731,7 +1703,6 @@ char *update_channel_onchain_fees(const tal_t *ctx,
diff,
AMOUNT_MSAT(0),
AMOUNT_MSAT(0),
close_ev->currency,
NULL, 0,
close_ev->timestamp);
log_channel_event(db, acct, ev);
@@ -1741,7 +1712,6 @@ char *update_channel_onchain_fees(const tal_t *ctx,
AMOUNT_MSAT(0),
diff,
AMOUNT_MSAT(0),
close_ev->currency,
NULL, 0,
close_ev->timestamp);
log_channel_event(db, acct, ev);
@@ -1755,7 +1725,7 @@ char *update_channel_onchain_fees(const tal_t *ctx,
insert_chain_fees_diff(db, acct->db_id,
close_ev->spending_txid,
fees, close_ev->currency,
fees,
close_ev->timestamp);
}
@@ -2037,7 +2007,6 @@ char *maybe_update_onchain_fees(const tal_t *ctx, struct db *db,
* *was* the only game in town */
insert_chain_fees_diff(db, last_id, txid,
AMOUNT_MSAT(0),
events[i]->currency,
events[i]->timestamp);
continue;
}
@@ -2056,9 +2025,7 @@ char *maybe_update_onchain_fees(const tal_t *ctx, struct db *db,
} else
fees = fee_part_msat;
/* FIXME: fee_currency property of acct? */
insert_chain_fees_diff(db, last_id, txid, fees,
events[i]->currency,
events[i]->timestamp);
}
@@ -2127,7 +2094,6 @@ bool log_chain_event(struct db *db,
", credit"
", debit"
", output_value"
", currency"
", timestamp"
", blockheight"
", utxo_txid"
@@ -2139,7 +2105,7 @@ bool log_chain_event(struct db *db,
", spliced"
")"
" VALUES "
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
db_bind_u64(stmt, acct->db_id);
if (e->origin_acct)
@@ -2150,7 +2116,6 @@ bool log_chain_event(struct db *db,
db_bind_amount_msat(stmt, e->credit);
db_bind_amount_msat(stmt, e->debit);
db_bind_amount_msat(stmt, e->output_value);
db_bind_text(stmt, e->currency);
db_bind_u64(stmt, e->timestamp);
db_bind_int(stmt, e->blockheight);
db_bind_txid(stmt, &e->outpoint.txid);

View File

@@ -18,7 +18,6 @@ struct onchain_fee;
struct fee_sum {
u64 acct_db_id;
char *acct_name;
char *currency;
struct bitcoin_txid *txid;
struct amount_msat fees_paid;
};

View File

@@ -208,7 +208,6 @@ struct channel_event *new_channel_event(const tal_t *ctx UNNEEDED,
struct amount_msat credit UNNEEDED,
struct amount_msat debit UNNEEDED,
struct amount_msat fees UNNEEDED,
const char *currency UNNEEDED,
struct sha256 *payment_id STEALS UNNEEDED,
u32 part_id UNNEEDED,
u64 timestamp UNNEEDED)

View File

@@ -214,7 +214,6 @@ struct channel_event *new_channel_event(const tal_t *ctx UNNEEDED,
struct amount_msat credit UNNEEDED,
struct amount_msat debit UNNEEDED,
struct amount_msat fees UNNEEDED,
const char *currency UNNEEDED,
struct sha256 *payment_id STEALS UNNEEDED,
u32 part_id UNNEEDED,
u64 timestamp UNNEEDED)
@@ -313,7 +312,6 @@ static bool channel_events_eq(struct channel_event *e1, struct channel_event *e2
CHECK((e1->rebalance_id != NULL) == (e2->rebalance_id != NULL));
if (e1->rebalance_id)
CHECK(*e1->rebalance_id == *e2->rebalance_id);
CHECK(streq(e1->currency, e2->currency));
CHECK((e1->payment_id != NULL) == (e2->payment_id != NULL));
if (e1->payment_id)
CHECK(sha256_eq(e1->payment_id, e2->payment_id));
@@ -338,7 +336,6 @@ static bool chain_events_eq(struct chain_event *e1, struct chain_event *e2)
CHECK(amount_msat_eq(e1->credit, e2->credit));
CHECK(amount_msat_eq(e1->debit, e2->debit));
CHECK(amount_msat_eq(e1->output_value, e2->output_value));
CHECK(streq(e1->currency, e2->currency));
CHECK(e1->timestamp == e2->timestamp);
CHECK(e1->blockheight == e2->blockheight);
CHECK(e1->stealable == e2->stealable);
@@ -374,7 +371,6 @@ static struct channel_event *make_channel_event(const tal_t *ctx,
ev->credit = credit;
ev->debit = debit;
ev->fees = AMOUNT_MSAT(104);
ev->currency = "btc";
ev->timestamp = 1919191;
ev->part_id = 19;
ev->tag = tag;
@@ -404,7 +400,6 @@ static struct chain_event *make_chain_event(const tal_t *ctx,
ev->credit = credit;
ev->debit = debit;
ev->output_value = output_val;
ev->currency = "btc";
ev->timestamp = 1919191;
ev->blockheight = blockheight;
ev->stealable = false;
@@ -730,7 +725,6 @@ static bool test_onchain_fee_chan_close(const tal_t *ctx, struct plugin *p)
CHECK(tal_count(ofs) == 4);
for (size_t i = 0; i < tal_count(ofs); i++) {
CHECK(ofs[i]->acct_db_id == acct->db_id);
CHECK(streq(ofs[i]->currency, "btc"));
memset(&txid, '1', sizeof(struct bitcoin_txid));
if (bitcoin_txid_eq(&txid, &ofs[i]->txid)) {
@@ -881,7 +875,6 @@ static bool test_onchain_fee_chan_open(const tal_t *ctx, struct plugin *p)
amount_msat(exp_results[i].debit)));
CHECK(ofs[i]->update_count == exp_results[i].update_count);
CHECK(streq(ofs[i]->currency, "btc"));
CHECK(bitcoin_txid_eq(&ofs[i]->txid, &txid));
}
@@ -993,7 +986,6 @@ static bool test_channel_event_crud(const tal_t *ctx, struct plugin *p)
ev1->credit = AMOUNT_MSAT(100);
ev1->debit = AMOUNT_MSAT(102);
ev1->fees = AMOUNT_MSAT(104);
ev1->currency = "btc";
ev1->timestamp = 11111;
ev1->part_id = 19;
ev1->desc = tal_strdup(ev1, "hello desc1");
@@ -1009,7 +1001,6 @@ static bool test_channel_event_crud(const tal_t *ctx, struct plugin *p)
ev2->credit = AMOUNT_MSAT(200);
ev2->debit = AMOUNT_MSAT(202);
ev2->fees = AMOUNT_MSAT(204);
ev2->currency = "brct";
ev2->timestamp = 22222;
ev2->part_id = 0;
ev2->tag = tal_fmt(ev2, "deposit");
@@ -1023,7 +1014,6 @@ static bool test_channel_event_crud(const tal_t *ctx, struct plugin *p)
ev3->credit = AMOUNT_MSAT(300);
ev3->debit = AMOUNT_MSAT(302);
ev3->fees = AMOUNT_MSAT(304);
ev3->currency = "brct";
ev3->timestamp = 33333;
ev3->part_id = 5;
ev3->tag = tal_fmt(ev3, "routed");
@@ -1082,7 +1072,6 @@ static bool test_chain_event_crud(const tal_t *ctx, struct plugin *p)
ev1->credit = AMOUNT_MSAT(100);
ev1->debit = AMOUNT_MSAT(102);
ev1->output_value = AMOUNT_MSAT(104);
ev1->currency = "btc";
ev1->timestamp = 1919191;
ev1->blockheight = 1919191;
ev1->stealable = false;
@@ -1103,7 +1092,6 @@ static bool test_chain_event_crud(const tal_t *ctx, struct plugin *p)
ev2->credit = AMOUNT_MSAT(200);
ev2->debit = AMOUNT_MSAT(202);
ev2->output_value = AMOUNT_MSAT(104);
ev2->currency = "btc";
ev2->timestamp = 1919191;
ev2->blockheight = 1919191;
ev2->stealable = false;
@@ -1122,7 +1110,6 @@ static bool test_chain_event_crud(const tal_t *ctx, struct plugin *p)
ev3->credit = AMOUNT_MSAT(300);
ev3->debit = AMOUNT_MSAT(302);
ev3->output_value = AMOUNT_MSAT(304);
ev3->currency = "btc";
ev3->timestamp = 3939393;
ev3->blockheight = 3939393;
ev3->stealable = false;
@@ -1186,7 +1173,6 @@ static bool test_chain_event_crud(const tal_t *ctx, struct plugin *p)
}
struct acct_balance {
char *currency;
struct amount_msat credit;
struct amount_msat debit;
struct amount_msat balance;
@@ -1328,7 +1314,6 @@ static bool test_account_crud(const tal_t *ctx, struct plugin *p)
ev1->credit = AMOUNT_MSAT(100);
ev1->debit = AMOUNT_MSAT(102);
ev1->output_value = AMOUNT_MSAT(104);
ev1->currency = "btc";
ev1->timestamp = 1919191;
ev1->blockheight = 1919191;
ev1->stealable = false;