common/coin_mvt: make more parameters const.
What changed, and why it matters
This commit only adds the C keyword 'const' to function parameters and test stubs. It does not change any program logic, data flow, or behavior. It is a code-quality/cleanup change with no security relevance.
No action required. Treat as routine cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies function signatures in common/coin_mvt.{c,h}, lightningd/coin_mvts.{c,h}, and wallet/test/run-db.c/run-wallet.c to mark pointer parameters as const (e.g., u64 part_id becomes const u64 part_id, struct htlc_in hin becomes const struct htlc_in hin). It also renames a couple of stub parameter names (mvt -> chain_mvt/chan_mvt). No logic, allocation, parsing, or control flow is altered. This is a compile-time type-safety improvement.
Changed components
common/coin_mvt.ccommon/coin_mvt.hlightningd/coin_mvts.clightningd/coin_mvts.hwallet/test/run-db.cwallet/test/run-wallet.cInspect captured patch +32 / −29
diff --git a/common/coin_mvt.c b/common/coin_mvt.c
index e3d7d9d5..d0d6d500 100644
--- a/common/coin_mvt.c
+++ b/common/coin_mvt.c
@@ -51,7 +51,7 @@ 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,
const struct channel_id *cid,
const struct sha256 *payment_hash TAKES,
- u64 *part_id TAKES,
+ const u64 *part_id TAKES,
struct amount_msat amount,
const enum mvt_tag *tags TAKES,
bool is_credit,
diff --git a/common/coin_mvt.h b/common/coin_mvt.h
index 58cd80e1..664b3ac9 100644
--- a/common/coin_mvt.h
+++ b/common/coin_mvt.h
@@ -99,7 +99,7 @@ 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,
const struct channel_id *cid,
const struct sha256 *payment_hash TAKES,
- u64 *part_id TAKES,
+ const u64 *part_id TAKES,
struct amount_msat amount,
const enum mvt_tag *tags TAKES,
bool is_credit,
diff --git a/lightningd/coin_mvts.c b/lightningd/coin_mvts.c
index da6137b8..5ac2ef98 100644
--- a/lightningd/coin_mvts.c
+++ b/lightningd/coin_mvts.c
@@ -7,8 +7,8 @@
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx,
- struct htlc_in *hin,
- struct channel *channel)
+ const struct htlc_in *hin,
+ const struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
&hin->payment_hash, NULL,
@@ -17,8 +17,8 @@ struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx,
}
struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx,
- struct htlc_in *hin,
- struct channel *channel)
+ const struct htlc_in *hin,
+ const struct channel *channel)
{
struct amount_msat fees_collected;
@@ -36,8 +36,8 @@ struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx,
}
struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx,
- struct htlc_out *hout,
- struct channel *channel)
+ const struct htlc_out *hout,
+ const struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
&hout->payment_hash, &hout->partid,
@@ -46,8 +46,8 @@ struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx,
}
struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx,
- struct htlc_out *hout,
- struct channel *channel)
+ const struct htlc_out *hout,
+ const struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
&hout->payment_hash, NULL,
diff --git a/lightningd/coin_mvts.h b/lightningd/coin_mvts.h
index abdc8315..8d7613d8 100644
--- a/lightningd/coin_mvts.h
+++ b/lightningd/coin_mvts.h
@@ -21,17 +21,17 @@ struct balance_snapshot {
};
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx,
- struct htlc_in *hin,
- struct channel *channel);
+ const struct htlc_in *hin,
+ const struct channel *channel);
struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx,
- struct htlc_in *hin,
- struct channel *channel);
+ const struct htlc_in *hin,
+ const struct channel *channel);
struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx,
- struct htlc_out *hout,
- struct channel *channel);
+ const struct htlc_out *hout,
+ const struct channel *channel);
struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx,
- struct htlc_out *hout,
- struct channel *channel);
+ const struct htlc_out *hout,
+ const struct channel *channel);
void send_account_balance_snapshot(struct lightningd *ld);
#endif /* LIGHTNING_LIGHTNINGD_COIN_MVTS_H */
diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c
index 369c15a4..c8cfb8f5 100644
--- a/wallet/test/run-db.c
+++ b/wallet/test/run-db.c
@@ -290,7 +290,8 @@ struct peer *new_peer(struct lightningd *ld UNNEEDED, u64 dbid UNNEEDED,
bool connected_incoming UNNEEDED)
{ fprintf(stderr, "new_peer called!\n"); abort(); }
/* Generated stub for notify_chain_mvt */
-void notify_chain_mvt(struct lightningd *ld UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
+void notify_chain_mvt(struct lightningd *ld UNNEEDED,
+ const struct chain_coin_mvt *chain_mvt UNNEEDED)
{ fprintf(stderr, "notify_chain_mvt called!\n"); abort(); }
/* Generated stub for notify_forward_event */
void notify_forward_event(struct lightningd *ld UNNEEDED,
diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c
index 52eedf8e..f8bfff7b 100644
--- a/wallet/test/run-wallet.c
+++ b/wallet/test/run-wallet.c
@@ -654,23 +654,23 @@ void memleak_scan_outpointfilter(struct htable *memtable UNNEEDED,
{ fprintf(stderr, "memleak_scan_outpointfilter called!\n"); abort(); }
/* Generated stub for new_channel_mvt_invoice_hin */
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx UNNEEDED,
- struct htlc_in *hin UNNEEDED,
- struct channel *channel UNNEEDED)
+ const struct htlc_in *hin UNNEEDED,
+ const struct channel *channel UNNEEDED)
{ fprintf(stderr, "new_channel_mvt_invoice_hin called!\n"); abort(); }
/* Generated stub for new_channel_mvt_invoice_hout */
struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx UNNEEDED,
- struct htlc_out *hout UNNEEDED,
- struct channel *channel UNNEEDED)
+ const struct htlc_out *hout UNNEEDED,
+ const struct channel *channel UNNEEDED)
{ fprintf(stderr, "new_channel_mvt_invoice_hout called!\n"); abort(); }
/* Generated stub for new_channel_mvt_routed_hin */
struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx UNNEEDED,
- struct htlc_in *hin UNNEEDED,
- struct channel *channel UNNEEDED)
+ const struct htlc_in *hin UNNEEDED,
+ const struct channel *channel UNNEEDED)
{ fprintf(stderr, "new_channel_mvt_routed_hin called!\n"); abort(); }
/* Generated stub for new_channel_mvt_routed_hout */
struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx UNNEEDED,
- struct htlc_out *hout UNNEEDED,
- struct channel *channel UNNEEDED)
+ const struct htlc_out *hout UNNEEDED,
+ const struct channel *channel UNNEEDED)
{ fprintf(stderr, "new_channel_mvt_routed_hout called!\n"); abort(); }
/* Generated stub for new_coin_wallet_deposit */
struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED,
@@ -698,10 +698,12 @@ struct uncommitted_channel *new_uncommitted_channel(struct peer *peer UNNEEDED)
bool node_announcement_same(const u8 *nann1 UNNEEDED, const u8 *nann2 UNNEEDED)
{ fprintf(stderr, "node_announcement_same called!\n"); abort(); }
/* Generated stub for notify_chain_mvt */
-void notify_chain_mvt(struct lightningd *ld UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
+void notify_chain_mvt(struct lightningd *ld UNNEEDED,
+ const struct chain_coin_mvt *chain_mvt UNNEEDED)
{ fprintf(stderr, "notify_chain_mvt called!\n"); abort(); }
/* Generated stub for notify_channel_mvt */
-void notify_channel_mvt(struct lightningd *ld UNNEEDED, const struct channel_coin_mvt *mvt UNNEEDED)
+void notify_channel_mvt(struct lightningd *ld UNNEEDED,
+ const struct channel_coin_mvt *chan_mvt UNNEEDED)
{ fprintf(stderr, "notify_channel_mvt called!\n"); abort(); }
/* Generated stub for notify_channel_open_failed */
void notify_channel_open_failed(struct lightningd *ld UNNEEDED,
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.