diff --git a/common/coin_mvt.c b/common/coin_mvt.c index f45658725..782b12eb7 100644 --- a/common/coin_mvt.c +++ b/common/coin_mvt.c @@ -27,12 +27,6 @@ const char *mvt_tag_str(enum mvt_tag tag) return mvt_tags[tag]; } -static const char *mvt_units[] = { "btc", }; -const char *mvt_unit_str(enum mvt_unit_type unit) -{ - return mvt_units[unit]; -} - struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, struct bitcoin_txid *funding_txid, u32 funding_outnum, @@ -40,8 +34,7 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, u64 *part_id, struct amount_msat amount, enum mvt_tag tag, - bool is_credit, - enum mvt_unit_type unit) + bool is_credit) { struct channel_coin_mvt *mvt = tal(ctx, struct channel_coin_mvt); @@ -58,8 +51,6 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, mvt->credit = AMOUNT_MSAT(0); } - mvt->unit = unit; - return mvt; } @@ -71,8 +62,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, const struct sha256 *payment_hash TAKES, u32 blockheight, enum mvt_tag tag, struct amount_msat amount, - bool is_credit, - enum mvt_unit_type unit) + bool is_credit) { struct chain_coin_mvt *mvt = tal(ctx, struct chain_coin_mvt); @@ -102,7 +92,6 @@ static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, mvt->debit = amount; mvt->credit = AMOUNT_MSAT(0); } - mvt->unit = unit; return mvt; } @@ -115,7 +104,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt_sat(const tal_t *ctx, const struct sha256 *payment_hash TAKES, u32 blockheight, enum mvt_tag tag, struct amount_sat amt_sat, - bool is_credit, enum mvt_unit_type unit) + bool is_credit) { struct amount_msat amt_msat; bool ok; @@ -124,8 +113,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt_sat(const tal_t *ctx, return new_chain_coin_mvt(ctx, account_name, tx_txid, output_txid, vout, payment_hash, - blockheight, tag, amt_msat, is_credit, - unit); + blockheight, tag, amt_msat, is_credit); } struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx, @@ -134,12 +122,11 @@ struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx, const struct bitcoin_txid *out_txid, u32 vout, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit) + struct amount_msat amount) { return new_chain_coin_mvt(ctx, account_name, tx_txid, out_txid, vout, NULL, blockheight, - WITHDRAWAL, amount, false, unit); + WITHDRAWAL, amount, false); } struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx, @@ -148,8 +135,7 @@ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx, const struct bitcoin_txid *out_txid, u32 vout, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit) + struct amount_sat amount) { struct amount_msat amt_msat; bool ok; @@ -158,27 +144,25 @@ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx, assert(ok); return new_coin_withdrawal(ctx, account_name, tx_txid, out_txid, vout, - blockheight, amt_msat, unit); + blockheight, amt_msat); } struct chain_coin_mvt *new_coin_chain_fees(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *tx_txid, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit) + struct amount_msat amount) { return new_chain_coin_mvt(ctx, account_name, tx_txid, NULL, 0, NULL, blockheight, - CHAIN_FEES, amount, false, unit); + CHAIN_FEES, amount, false); } struct chain_coin_mvt *new_coin_chain_fees_sat(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *tx_txid, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit) + struct amount_sat amount) { struct amount_msat amt_msat; bool ok; @@ -187,7 +171,7 @@ struct chain_coin_mvt *new_coin_chain_fees_sat(const tal_t *ctx, assert(ok); return new_coin_chain_fees(ctx, account_name, tx_txid, - blockheight, amt_msat, unit); + blockheight, amt_msat); } struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx, @@ -197,25 +181,23 @@ struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx, u32 vout, u32 blockheight, struct amount_msat amount, - bool is_credit, - enum mvt_unit_type unit) + bool is_credit) { return new_chain_coin_mvt(ctx, account_name, txid, out_txid, vout, NULL, blockheight, JOURNAL, - amount, is_credit, unit); + amount, is_credit); } struct chain_coin_mvt *new_coin_deposit(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, u32 vout, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit) + struct amount_msat amount) { return new_chain_coin_mvt(ctx, account_name, txid, txid, vout, NULL, blockheight, DEPOSIT, - amount, true, unit); + amount, true); } struct chain_coin_mvt *new_coin_deposit_sat(const tal_t *ctx, @@ -223,8 +205,7 @@ struct chain_coin_mvt *new_coin_deposit_sat(const tal_t *ctx, const struct bitcoin_txid *txid, u32 vout, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit) + struct amount_sat amount) { struct amount_msat amt_msat; bool ok; @@ -233,8 +214,7 @@ struct chain_coin_mvt *new_coin_deposit_sat(const tal_t *ctx, assert(ok); return new_coin_deposit(ctx, account_name, txid, - vout, blockheight, - amt_msat, unit); + vout, blockheight, amt_msat); } struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx, const char *account_name, @@ -242,8 +222,7 @@ struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx, const struct bitcoin_txid *out_txid, u32 vout, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit) + struct amount_sat amount) { struct amount_msat amt_msat; bool ok; @@ -255,8 +234,7 @@ struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx, txid, out_txid, vout, NULL, blockheight, PENALTY, - amt_msat, false, - unit); + amt_msat, false); } struct chain_coin_mvt *new_coin_onchain_htlc_sat(const tal_t *ctx, @@ -267,41 +245,39 @@ struct chain_coin_mvt *new_coin_onchain_htlc_sat(const tal_t *ctx, struct sha256 payment_hash, u32 blockheight, struct amount_sat amount, - bool is_credit, - enum mvt_unit_type unit) + bool is_credit) { return new_chain_coin_mvt_sat(ctx, account_name, txid, out_txid, vout, take(tal_dup(NULL, struct sha256, &payment_hash)), blockheight, - ONCHAIN_HTLC, amount, is_credit, unit); + ONCHAIN_HTLC, amount, is_credit); } struct chain_coin_mvt *new_coin_pushed(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit) + struct amount_msat amount) { return new_chain_coin_mvt(ctx, account_name, txid, NULL, 0, NULL, blockheight, PUSHED, amount, - false, unit); + false); } struct chain_coin_mvt *new_coin_spend_track(const tal_t *ctx, const struct bitcoin_txid *txid, const struct bitcoin_txid *out_txid, - u32 vout, u32 blockheight, - enum mvt_unit_type unit) + u32 vout, u32 blockheight) { return new_chain_coin_mvt_sat(ctx, "wallet", txid, out_txid, vout, NULL, blockheight, SPEND_TRACK, AMOUNT_SAT(0), - false, unit); + false); } struct coin_mvt *finalize_chain_mvt(const tal_t *ctx, const struct chain_coin_mvt *chain_mvt, + const char *bip173_name, u32 timestamp, struct node_id *node_id, s64 count) @@ -310,6 +286,7 @@ struct coin_mvt *finalize_chain_mvt(const tal_t *ctx, mvt->account_id = tal_strndup(mvt, chain_mvt->account_name, strlen(chain_mvt->account_name)); + mvt->bip173_name = tal_strndup(mvt, bip173_name, strlen(bip173_name)); mvt->type = CHAIN_MVT; mvt->id.tx_txid = chain_mvt->tx_txid; @@ -319,7 +296,6 @@ struct coin_mvt *finalize_chain_mvt(const tal_t *ctx, mvt->tag = chain_mvt->tag; mvt->credit = chain_mvt->credit; mvt->debit = chain_mvt->debit; - mvt->unit = chain_mvt->unit; mvt->timestamp = timestamp; mvt->blockheight = chain_mvt->blockheight; mvt->version = COIN_MVT_VERSION; @@ -331,6 +307,7 @@ struct coin_mvt *finalize_chain_mvt(const tal_t *ctx, struct coin_mvt *finalize_channel_mvt(const tal_t *ctx, const struct channel_coin_mvt *chan_mvt, + const char *bip173_name, u32 timestamp, struct node_id *node_id, s64 count) { @@ -338,6 +315,7 @@ struct coin_mvt *finalize_channel_mvt(const tal_t *ctx, mvt->account_id = type_to_string(mvt, struct channel_id, &chan_mvt->chan_id); + mvt->bip173_name = tal_strndup(mvt, bip173_name, strlen(bip173_name)); mvt->type = CHANNEL_MVT; mvt->id.payment_hash = chan_mvt->payment_hash; mvt->id.part_id = chan_mvt->part_id; @@ -347,7 +325,6 @@ struct coin_mvt *finalize_channel_mvt(const tal_t *ctx, mvt->tag = chan_mvt->tag; mvt->credit = chan_mvt->credit; mvt->debit = chan_mvt->debit; - mvt->unit = chan_mvt->unit; mvt->timestamp = timestamp; /* channel movements don't have a blockheight */ mvt->blockheight = 0; @@ -382,7 +359,6 @@ void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt) towire_u8(pptr, mvt->tag); towire_amount_msat(pptr, mvt->credit); towire_amount_msat(pptr, mvt->debit); - towire_u8(pptr, mvt->unit); } void fromwire_chain_coin_mvt(const u8 **cursor, size_t *max, struct chain_coin_mvt *mvt) @@ -415,5 +391,4 @@ void fromwire_chain_coin_mvt(const u8 **cursor, size_t *max, struct chain_coin_m mvt->tag = fromwire_u8(cursor, max); mvt->credit = fromwire_amount_msat(cursor, max); mvt->debit = fromwire_amount_msat(cursor, max); - mvt->unit = fromwire_u8(cursor, max); } diff --git a/common/coin_mvt.h b/common/coin_mvt.h index 8a44d1511..6c51a0f94 100644 --- a/common/coin_mvt.h +++ b/common/coin_mvt.h @@ -32,10 +32,6 @@ enum mvt_tag { SPEND_TRACK = 9, }; -enum mvt_unit_type { - BTC = 0, -}; - struct channel_coin_mvt { /* account_id */ struct channel_id chan_id; @@ -43,7 +39,7 @@ struct channel_coin_mvt { /* identifier */ struct sha256 *payment_hash; - /* mutlti-part payments may share a payment hash, + /* mutli-part payments may share a payment hash, * so we should also record a 'part-id' for them */ u64 *part_id; @@ -54,8 +50,6 @@ struct channel_coin_mvt { struct amount_msat credit; struct amount_msat debit; - /* what currency is this coin denominated in? */ - enum mvt_unit_type unit; }; struct chain_coin_mvt { @@ -78,9 +72,6 @@ struct chain_coin_mvt { /* only one or the other */ struct amount_msat credit; struct amount_msat debit; - - /* what currency is this coin denominated in? */ - enum mvt_unit_type unit; }; /* differs depending on type!? */ @@ -95,6 +86,7 @@ struct mvt_id { struct coin_mvt { /* name of 'account': wallet, external, */ const char *account_id; + const char *bip173_name; /* type of movement: channel or chain */ enum mvt_type type; @@ -109,9 +101,6 @@ struct coin_mvt { struct amount_msat credit; struct amount_msat debit; - /* what currency is this coin denominated in? */ - enum mvt_unit_type unit; - u32 timestamp; u32 blockheight; @@ -133,8 +122,7 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, u64 *part_id, struct amount_msat amount, enum mvt_tag tag, - bool is_credit, - enum mvt_unit_type unit); + bool is_credit); struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx, const char *account_name, @@ -142,28 +130,24 @@ struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx, const struct bitcoin_txid *out_txid, u32 vout, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit); + struct amount_msat amount); struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *tx_txid, const struct bitcoin_txid *out_txid, u32 vout, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit); + struct amount_sat amount); struct chain_coin_mvt *new_coin_chain_fees(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *tx_txid, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit); + struct amount_msat amount); struct chain_coin_mvt *new_coin_chain_fees_sat(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *tx_txid, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit); + struct amount_sat amount); struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, @@ -171,29 +155,25 @@ struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx, u32 vout, u32 blockheight, struct amount_msat amount, - bool is_credit, - enum mvt_unit_type unit); + bool is_credit); struct chain_coin_mvt *new_coin_deposit(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, u32 vout, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit); + struct amount_msat amount); struct chain_coin_mvt *new_coin_deposit_sat(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, u32 vout, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit); + struct amount_sat amount); struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, const struct bitcoin_txid *out_txid, u32 vout, u32 blockheight, - struct amount_sat amount, - enum mvt_unit_type unit); + struct amount_sat amount); struct chain_coin_mvt *new_coin_onchain_htlc_sat(const tal_t *ctx, const char *account_name, @@ -203,32 +183,30 @@ struct chain_coin_mvt *new_coin_onchain_htlc_sat(const tal_t *ctx, struct sha256 payment_hash, u32 blockheight, struct amount_sat amount, - bool is_credit, - enum mvt_unit_type unit); + bool is_credit); struct chain_coin_mvt *new_coin_spend_track(const tal_t *ctx, const struct bitcoin_txid *txid, const struct bitcoin_txid *out_txid, - u32 vout, u32 blockheight, - enum mvt_unit_type unit); + u32 vout, u32 blockheight); struct chain_coin_mvt *new_coin_pushed(const tal_t *ctx, const char *account_name, const struct bitcoin_txid *txid, u32 blockheight, - struct amount_msat amount, - enum mvt_unit_type unit); + struct amount_msat amount); struct coin_mvt *finalize_chain_mvt(const tal_t *ctx, const struct chain_coin_mvt *chain_mvt, + const char *bip173_name, u32 timestamp, struct node_id *node_id, s64 mvt_count); struct coin_mvt *finalize_channel_mvt(const tal_t *ctx, const struct channel_coin_mvt *chan_mvt, + const char *bip173_name, u32 timestamp, struct node_id *node_id, s64 mvt_count); const char *mvt_type_str(enum mvt_type type); const char *mvt_tag_str(enum mvt_tag tag); -const char *mvt_unit_str(enum mvt_unit_type unit); void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt); void fromwire_chain_coin_mvt(const u8 **cursor, size_t *max, struct chain_coin_mvt *mvt); diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index 0d764814c..cbf59b808 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -549,7 +549,7 @@ i.e. only definitively resolved HTLCs or confirmed bitcoin transactions. "tag":"deposit", "blockheight":102, // (`channel_mvt` type only. may be null) "timestamp":1585948198, - "unit_of_account":"btc" + "coin_type":"bc" } } ``` @@ -610,7 +610,7 @@ before confirmation. The `timestamp` is seconds since Unix epoch of the node's machine time at the time lightningd broadcasts the notification. -`unit_of_account` is the 'currency' this coin movememnt is denominated in. +`coin_type` is the BIP173 name for the coin which moved. ## Hooks diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index 81e99ee18..0c874ee1b 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -680,8 +680,7 @@ static void record_output_spend(struct lightningd *ld, vout); *input_amt = utxo->amount; - mvt = new_coin_spend_track(ctx, txid, utxo_txid, vout, - blockheight, BTC); + mvt = new_coin_spend_track(ctx, txid, utxo_txid, vout, blockheight); notify_chain_mvt(ld, mvt); tal_free(ctx); } @@ -711,7 +710,7 @@ static void record_tx_outs_and_fees(struct lightningd *ld, const struct bitcoin_ assert(amount_asset_is_main(&asset)); outval = amount_asset_to_sat(&asset); mvt = new_coin_withdrawal_sat(ctx, "wallet", txid, txid, - i, blockheight, outval, BTC); + i, blockheight, outval); notify_chain_mvt(ld, mvt); } @@ -724,7 +723,7 @@ static void record_tx_outs_and_fees(struct lightningd *ld, const struct bitcoin_ * the funding txid when looking at a channel. */ notify_chain_mvt(ld, new_coin_chain_fees_sat(ctx, "wallet", txid, - blockheight, fee, BTC)); + blockheight, fee)); tal_free(ctx); } diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index cc84efb51..32faa3e72 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -104,7 +104,7 @@ static void record_channel_open(struct channel *channel) struct channel_id, &channel_id), &channel->funding_txid, - blockheight, channel->push, BTC); + blockheight, channel->push); notify_chain_mvt(channel->peer->ld, mvt); } } else { @@ -119,7 +119,7 @@ static void record_channel_open(struct channel *channel) &channel_id), &channel->funding_txid, channel->funding_outnum, - blockheight, channel_open_amt, BTC); + blockheight, channel_open_amt); notify_chain_mvt(channel->peer->ld, mvt); tal_free(ctx); } diff --git a/lightningd/coin_mvts.c b/lightningd/coin_mvts.c index 5fb5f0265..3d0dfc31b 100644 --- a/lightningd/coin_mvts.c +++ b/lightningd/coin_mvts.c @@ -18,8 +18,8 @@ void notify_channel_mvt(struct lightningd *ld, const struct channel_coin_mvt *mv timestamp = time_now().ts.tv_sec; count = update_count(ld); - cm = finalize_channel_mvt(mvt, mvt, timestamp, - &ld->id, count); + cm = finalize_channel_mvt(mvt, mvt, chainparams->bip173_name, + timestamp, &ld->id, count); notify_coin_mvt(ld, cm); } @@ -31,8 +31,8 @@ void notify_chain_mvt(struct lightningd *ld, const struct chain_coin_mvt *mvt) timestamp = time_now().ts.tv_sec; count = update_count(ld); - cm = finalize_chain_mvt(mvt, mvt, timestamp, - &ld->id, count); + cm = finalize_chain_mvt(mvt, mvt, chainparams->bip173_name, + timestamp, &ld->id, count); notify_coin_mvt(ld, cm); } @@ -44,7 +44,7 @@ struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx, channel->funding_outnum, hin->payment_hash, NULL, hin->msat, INVOICE, - true, BTC); + true); } struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx, @@ -55,7 +55,7 @@ struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx, channel->funding_outnum, hin->payment_hash, NULL, hin->msat, ROUTED, - true, BTC); + true); } struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx, @@ -66,7 +66,7 @@ struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx, channel->funding_outnum, hout->payment_hash, &hout->partid, hout->msat, INVOICE, - false, BTC); + false); } struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx, @@ -77,7 +77,7 @@ struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx, channel->funding_outnum, hout->payment_hash, NULL, hout->msat, ROUTED, - false, BTC); + false); } void coin_mvts_init_count(struct lightningd *ld) diff --git a/lightningd/notification.c b/lightningd/notification.c index 60d76361e..cb398048c 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -402,7 +402,7 @@ static void coin_movement_notification_serialize(struct json_stream *stream, json_add_null(stream, "blockheight"); } json_add_u32(stream, "timestamp", mvt->timestamp); - json_add_string(stream, "unit_of_account", mvt_unit_str(mvt->unit)); + json_add_string(stream, "coin_type", mvt->bip173_name); json_object_end(stream); } diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index ba81cb4b6..77178db94 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -342,8 +342,7 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg) wallet_add_utxo(channel->peer->ld->wallet, u, p2wpkh); mvt = new_coin_deposit_sat(msg, "wallet", &u->txid, - u->outnum, blockheight, - u->amount, BTC); + u->outnum, blockheight, u->amount); notify_chain_mvt(channel->peer->ld, mvt); } diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index fd5ba6071..04457ca70 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -144,7 +144,7 @@ static void record_their_successful_cheat(const struct bitcoin_txid *txid, * that we were expecting to revoke */ mvt = new_coin_penalty_sat(NULL, NULL, txid, &out->txid, out->outnum, - blockheight, out->sat, BTC); + blockheight, out->sat); send_coin_mvt(take(mvt)); } @@ -163,8 +163,7 @@ static void record_htlc_fulfilled(const struct bitcoin_txid *txid, * htlc here, we record it as a 'deposit/withdrawal' type */ mvt = new_coin_onchain_htlc_sat(NULL, NULL, txid, &out->txid, out->outnum, out->payment_hash, - blockheight, out->sat, we_fulfilled, - BTC); + blockheight, out->sat, we_fulfilled); send_coin_mvt(take(mvt)); } @@ -174,7 +173,7 @@ static void update_ledger_chain_fees_msat(const struct bitcoin_txid *txid, struct amount_msat fees) { send_coin_mvt(take(new_coin_chain_fees(NULL, NULL, txid, - blockheight, fees, BTC))); + blockheight, fees))); } static void update_ledger_chain_fees(const struct bitcoin_txid *txid, @@ -182,8 +181,7 @@ static void update_ledger_chain_fees(const struct bitcoin_txid *txid, struct amount_sat fees) { struct chain_coin_mvt *mvt; - mvt = new_coin_chain_fees_sat(NULL, NULL, txid, - blockheight, fees, BTC); + mvt = new_coin_chain_fees_sat(NULL, NULL, txid, blockheight, fees); send_coin_mvt(take(mvt)); } @@ -250,7 +248,7 @@ static void record_mutual_closure(const struct bitcoin_txid *txid, assert(output_num > -1); /* Otherwise, we record the channel withdrawal */ send_coin_mvt(take(new_coin_withdrawal(NULL, NULL, txid, txid, output_num, - blockheight, output_msat, BTC))); + blockheight, output_msat))); } static void record_chain_fees_unilateral(const struct bitcoin_txid *txid, @@ -286,8 +284,7 @@ static void record_chain_fees_unilateral(const struct bitcoin_txid *txid, /* Log the difference and update our_msat */ send_coin_mvt(take(new_coin_journal_entry(NULL, NULL, txid, NULL, 0, blockheight, - missing, - true, BTC))); + missing, true))); if (!amount_msat_add(&our_msat, our_msat, missing)) status_failed(STATUS_FAIL_INTERNAL_ERROR, "unable to add %s to %s", @@ -320,8 +317,7 @@ static void record_coin_loss(const struct bitcoin_txid *txid, /* We don't for sure know that it's a 'penalty' * but we write it as that anyway... */ mvt = new_coin_penalty_sat(NULL, NULL, txid, &out->txid, - out->outnum, blockheight, out->sat, - BTC); + out->outnum, blockheight, out->sat); send_coin_mvt(take(mvt)); } @@ -343,8 +339,7 @@ static void record_channel_withdrawal_minus_fees(const struct bitcoin_txid *tx_t send_coin_mvt(take(new_coin_withdrawal_sat( NULL, NULL, tx_txid, &out->txid, - out->outnum, blockheight, - emitted_amt, BTC))); + out->outnum, blockheight, emitted_amt))); } @@ -2506,11 +2501,9 @@ static void update_ledger_cheat(const struct bitcoin_txid *txid, &out->sat)); /* add the difference to our ledger balance */ - /* FIXME: elements is not always btc? */ send_coin_mvt(take(new_coin_journal_entry(NULL, NULL, txid, &out->txid, out->outnum, - blockheight, amt, - true, BTC))); + blockheight, amt, true))); } /* BOLT #5: @@ -3073,10 +3066,8 @@ static void update_ledger_unknown(const struct bitcoin_txid *txid, } else is_credit = true; - /* FIXME: elements txs not in BTC ?? */ send_coin_mvt(take(new_coin_journal_entry(NULL, NULL, txid, NULL, 0, - blockheight, diff, - is_credit, BTC))); + blockheight, diff, is_credit))); } static void handle_unknown_commitment(const struct bitcoin_tx *tx, diff --git a/onchaind/test/run-grind_feerate-bug.c b/onchaind/test/run-grind_feerate-bug.c index 7f00439ef..952b7e5dc 100644 --- a/onchaind/test/run-grind_feerate-bug.c +++ b/onchaind/test/run-grind_feerate-bug.c @@ -102,16 +102,14 @@ struct chain_coin_mvt *new_coin_chain_fees(const tal_t *ctx UNNEEDED, const char *account_name UNNEEDED, const struct bitcoin_txid *tx_txid UNNEEDED, u32 blockheight UNNEEDED, - struct amount_msat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_msat amount UNNEEDED) { fprintf(stderr, "new_coin_chain_fees called!\n"); abort(); } /* Generated stub for new_coin_chain_fees_sat */ struct chain_coin_mvt *new_coin_chain_fees_sat(const tal_t *ctx UNNEEDED, const char *account_name UNNEEDED, const struct bitcoin_txid *tx_txid UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_chain_fees_sat called!\n"); abort(); } /* Generated stub for new_coin_journal_entry */ struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx UNNEEDED, @@ -121,19 +119,17 @@ struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, struct amount_msat amount UNNEEDED, - bool is_credit UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + bool is_credit UNNEEDED) { fprintf(stderr, "new_coin_journal_entry called!\n"); abort(); } /* Generated stub for new_coin_onchain_htlc_sat */ struct chain_coin_mvt *new_coin_onchain_htlc_sat(const tal_t *ctx UNNEEDED, - const char *account_name UNNEEDED, + const char *account_name UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, struct sha256 payment_hash UNNEEDED, u32 blockheight UNNEEDED, struct amount_sat amount UNNEEDED, - bool is_credit UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + bool is_credit UNNEEDED) { fprintf(stderr, "new_coin_onchain_htlc_sat called!\n"); abort(); } /* Generated stub for new_coin_penalty_sat */ struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx UNNEEDED, @@ -142,8 +138,7 @@ struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_penalty_sat called!\n"); abort(); } /* Generated stub for new_coin_withdrawal */ struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx UNNEEDED, @@ -152,8 +147,7 @@ struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_msat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_msat amount UNNEEDED) { fprintf(stderr, "new_coin_withdrawal called!\n"); abort(); } /* Generated stub for new_coin_withdrawal_sat */ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx UNNEEDED, @@ -162,8 +156,7 @@ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_withdrawal_sat called!\n"); abort(); } /* Generated stub for notleak_ */ void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index 5a8684e90..7f8c60d7b 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/onchaind/test/run-grind_feerate.c @@ -114,16 +114,14 @@ struct chain_coin_mvt *new_coin_chain_fees(const tal_t *ctx UNNEEDED, const char *account_name UNNEEDED, const struct bitcoin_txid *tx_txid UNNEEDED, u32 blockheight UNNEEDED, - struct amount_msat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_msat amount UNNEEDED) { fprintf(stderr, "new_coin_chain_fees called!\n"); abort(); } /* Generated stub for new_coin_chain_fees_sat */ struct chain_coin_mvt *new_coin_chain_fees_sat(const tal_t *ctx UNNEEDED, const char *account_name UNNEEDED, const struct bitcoin_txid *tx_txid UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_chain_fees_sat called!\n"); abort(); } /* Generated stub for new_coin_journal_entry */ struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx UNNEEDED, @@ -133,19 +131,17 @@ struct chain_coin_mvt *new_coin_journal_entry(const tal_t *ctx UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, struct amount_msat amount UNNEEDED, - bool is_credit UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + bool is_credit UNNEEDED) { fprintf(stderr, "new_coin_journal_entry called!\n"); abort(); } /* Generated stub for new_coin_onchain_htlc_sat */ struct chain_coin_mvt *new_coin_onchain_htlc_sat(const tal_t *ctx UNNEEDED, - const char *account_name UNNEEDED, + const char *account_name UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, struct sha256 payment_hash UNNEEDED, u32 blockheight UNNEEDED, struct amount_sat amount UNNEEDED, - bool is_credit UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + bool is_credit UNNEEDED) { fprintf(stderr, "new_coin_onchain_htlc_sat called!\n"); abort(); } /* Generated stub for new_coin_penalty_sat */ struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx UNNEEDED, @@ -154,8 +150,7 @@ struct chain_coin_mvt *new_coin_penalty_sat(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_penalty_sat called!\n"); abort(); } /* Generated stub for new_coin_withdrawal */ struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx UNNEEDED, @@ -164,8 +159,7 @@ struct chain_coin_mvt *new_coin_withdrawal(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_msat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_msat amount UNNEEDED) { fprintf(stderr, "new_coin_withdrawal called!\n"); abort(); } /* Generated stub for new_coin_withdrawal_sat */ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx UNNEEDED, @@ -174,8 +168,7 @@ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *out_txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_withdrawal_sat called!\n"); abort(); } /* Generated stub for notleak_ */ void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) diff --git a/tests/plugins/coin_movements.py b/tests/plugins/coin_movements.py index be842a9af..dc92adeec 100755 --- a/tests/plugins/coin_movements.py +++ b/tests/plugins/coin_movements.py @@ -31,7 +31,7 @@ def notify_coin_movement(plugin, coin_movement, **kwargs): plugin.log("{} coins debit: {}".format(idx, coin_movement['debit'])) plugin.log("{} coins tag: {}".format(idx, coin_movement['tag'])) plugin.log("{} coins timestamp: {}".format(idx, coin_movement['timestamp'])) - plugin.log("{} coins unit_of_account: {}".format(idx, coin_movement['unit_of_account'])) + plugin.log("{} coins coin_type: {}".format(idx, coin_movement['coin_type'])) for f in ['payment_hash', 'utxo_txid', 'vout', 'txid', 'part_id', 'blockheight']: if f in coin_movement: diff --git a/tests/utils.py b/tests/utils.py index 4dd00bc3d..3962c2681 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -42,7 +42,7 @@ def check_coin_moves(n, account_id, expected_moves): assert mv['debit'] == "{}msat".format(exp['debit']) assert mv['tag'] == exp['tag'] assert mv['timestamp'] > 0 - assert mv['unit_of_account'] == 'btc' + assert mv['coin_type'] == 'bcrt' # chain moves should have blockheights if mv['type'] == 'chain_mvt': assert mv['blockheight'] is not None diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 97a6c3bd5..8cdda0b73 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -410,8 +410,7 @@ struct chain_coin_mvt *new_coin_deposit_sat(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 vout UNNEEDED, u32 blockheight UNNEEDED, - struct amount_sat amount UNNEEDED, - enum mvt_unit_type unit UNNEEDED) + struct amount_sat amount UNNEEDED) { fprintf(stderr, "new_coin_deposit_sat called!\n"); abort(); } /* Generated stub for notify_chain_mvt */ void notify_chain_mvt(struct lightningd *ld UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED) diff --git a/wallet/wallet.c b/wallet/wallet.c index 4e1ec616e..1cc48ad70 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1698,7 +1698,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, if (blockheight) { mvt = new_coin_deposit_sat(utxo, "wallet", &utxo->txid, utxo->outnum, blockheight ? *blockheight : 0, - utxo->amount, BTC); + utxo->amount); notify_chain_mvt(w->ld, mvt); }