common: remove `struct coin_mvt` altogether.
What changed, and why it matters
This commit removes an unused internal data structure (`struct coin_mvt`) and the helper functions that converted two other structures into it. It is a code cleanup change with no visible effect on users and no security relevance.
No security action required. Review as normal code-cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes struct coin_mvt, struct mvt_id, the mvt_type enum, mvt_type_str(), and the finalize_chain_mvt() / finalize_channel_mvt() constructors from common/coin_mvt.c and common/coin_mvt.h. The commit message states that only struct chain_coin_mvt and struct channel_coin_mvt are now used. No callers of the removed code are updated in this diff, implying they were already unused or removed in prior commits. This is a pure refactoring/dead-code removal.
Changed components
common/coin_mvt.ccommon/coin_mvt.hInspect captured patch +0 / −147
diff --git a/common/coin_mvt.c b/common/coin_mvt.c
index 3595f585..e3d7d9d5 100644
--- a/common/coin_mvt.c
+++ b/common/coin_mvt.c
@@ -9,12 +9,6 @@
#define EXTERNAL "external"
-static const char *mvt_types[] = { "chain_mvt", "channel_mvt" };
-const char *mvt_type_str(enum mvt_type type)
-{
- return mvt_types[type];
-}
-
static const char *mvt_tags[] = {
"deposit",
"withdrawal",
@@ -391,73 +385,6 @@ struct channel_coin_mvt *new_coin_channel_push(const tal_t *ctx,
AMOUNT_MSAT(0));
}
-struct coin_mvt *finalize_chain_mvt(const tal_t *ctx,
- const struct chain_coin_mvt *chain_mvt,
- const char *hrp_name TAKES,
- u32 timestamp,
- struct node_id *node_id)
-{
- struct coin_mvt *mvt = tal(ctx, struct coin_mvt);
-
- mvt->account_id = tal_strdup(mvt, chain_mvt->account_name);
- mvt->originating_acct =
- tal_strdup_or_null(mvt, chain_mvt->originating_acct);
- mvt->hrp_name = tal_strdup(mvt, hrp_name);
- mvt->type = CHAIN_MVT;
-
- mvt->id.tx_txid = chain_mvt->tx_txid;
- mvt->id.outpoint = chain_mvt->outpoint;
- mvt->id.payment_hash = chain_mvt->payment_hash;
- mvt->tags = tal_steal(mvt, chain_mvt->tags);
- mvt->credit = chain_mvt->credit;
- mvt->debit = chain_mvt->debit;
-
- mvt->output_val = tal(mvt, struct amount_sat);
- *mvt->output_val = chain_mvt->output_val;
- mvt->output_count = chain_mvt->output_count;
- mvt->fees = NULL;
-
- mvt->timestamp = timestamp;
- mvt->blockheight = chain_mvt->blockheight;
- mvt->version = COIN_MVT_VERSION;
- mvt->node_id = node_id;
- mvt->peer_id = chain_mvt->peer_id;
-
- return mvt;
-}
-
-struct coin_mvt *finalize_channel_mvt(const tal_t *ctx,
- const struct channel_coin_mvt *chan_mvt,
- const char *hrp_name TAKES,
- u32 timestamp,
- const struct node_id *node_id TAKES)
-{
- struct coin_mvt *mvt = tal(ctx, struct coin_mvt);
-
- mvt->account_id = fmt_channel_id(mvt, &chan_mvt->chan_id);
- /* channel moves don't have external events! */
- mvt->originating_acct = NULL;
- mvt->hrp_name = tal_strdup(mvt, hrp_name);
- mvt->type = CHANNEL_MVT;
- mvt->id.payment_hash = chan_mvt->payment_hash;
- mvt->id.part_id = chan_mvt->part_id;
- mvt->id.tx_txid = NULL;
- mvt->id.outpoint = NULL;
- mvt->tags = tal_steal(mvt, chan_mvt->tags);
- mvt->credit = chan_mvt->credit;
- mvt->debit = chan_mvt->debit;
- mvt->output_val = NULL;
- mvt->output_count = 0;
- mvt->fees = tal(mvt, struct amount_msat);
- *mvt->fees = chan_mvt->fees;
- mvt->timestamp = timestamp;
- mvt->version = COIN_MVT_VERSION;
- mvt->node_id = tal_dup(mvt, struct node_id, node_id);
- mvt->peer_id = NULL;
-
- return mvt;
-}
-
void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt)
{
if (mvt->account_name) {
diff --git a/common/coin_mvt.h b/common/coin_mvt.h
index 3e112de2..58cd80e1 100644
--- a/common/coin_mvt.h
+++ b/common/coin_mvt.h
@@ -9,11 +9,6 @@
#define COIN_MVT_VERSION 2
#define WALLET "wallet"
-enum mvt_type {
- CHAIN_MVT = 0,
- CHANNEL_MVT = 1,
-};
-
#define NUM_MVT_TAGS (SPLICE + 1)
enum mvt_tag {
DEPOSIT = 0,
@@ -99,60 +94,6 @@ struct chain_coin_mvt {
u32 output_count;
};
-/* differs depending on type!? */
-struct mvt_id {
- struct sha256 *payment_hash;
- u64 *part_id;
- const struct bitcoin_txid *tx_txid;
- const struct bitcoin_outpoint *outpoint;
-};
-
-struct coin_mvt {
- /* name of 'account': wallet, external, <channel_id> */
- const char *account_id;
-
- /* Peer that this event occurred with */
- const struct node_id *peer_id;
-
- /* if account_id is external, the account this 'impacted' */
- const char *originating_acct;
-
- /* Chain name: BIP 173, except signet lightning-style: tbs not tb */
- const char *hrp_name;
-
- /* type of movement: channel or chain */
- enum mvt_type type;
-
- /* identifier */
- struct mvt_id id;
-
- /* label / tag array */
- enum mvt_tag *tags;
-
- /* only one or the other */
- struct amount_msat credit;
- struct amount_msat debit;
-
- /* Value of the output. May be different than
- * our credit/debit amount, eg channel opens */
- struct amount_sat *output_val;
- /* Really only needed for channel closes */
- size_t output_count;
-
- /* Amount of fees collected/paid by channel mvt */
- struct amount_msat *fees;
-
- u32 timestamp;
- u32 blockheight;
-
- /* version is a counter of the format of the data payload that
- * makes up a coin movement */
- u8 version;
-
- /* node originating this movement */
- struct node_id *node_id;
-};
-
enum mvt_tag *new_tag_arr(const tal_t *ctx, enum mvt_tag tag);
struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx,
@@ -285,24 +226,9 @@ struct channel_coin_mvt *new_coin_channel_push(const tal_t *ctx,
bool is_credit)
NON_NULL_ARGS(2);
-struct coin_mvt *finalize_chain_mvt(const tal_t *ctx,
- const struct chain_coin_mvt *chain_mvt,
- const char *hrp_name,
- u32 timestamp,
- struct node_id *node_id)
- NON_NULL_ARGS(2, 3);
-
-struct coin_mvt *finalize_channel_mvt(const tal_t *ctx,
- const struct channel_coin_mvt *chan_mvt,
- const char *hrp_name,
- u32 timestamp,
- const struct node_id *node_id)
- NON_NULL_ARGS(2, 3, 5);
-
/* Is this an xternal account? */
bool chain_mvt_is_external(const struct chain_coin_mvt *mvt);
-const char *mvt_type_str(enum mvt_type type);
const char *mvt_tag_str(enum mvt_tag tag);
void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt);
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.