bkpr: strings in structures should be const.
What changed, and why it matters
This commit only adds the 'const' keyword to string pointers in the bookkeeping plugin's data structures and function signatures. It does not change program logic, fix a crash, or address any security vulnerability. It is a code-quality/correctness change that tells the compiler these strings should not be modified.
No security action needed. Treat as normal code-quality maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure const-correctness refactor in plugins/bkpr. It changes char fields in structs (chain_event, channel_event, channel_apy, income_event, csv_fmt, onchain_fee, fee_sum, rebalance, txo_set is not touched) and function parameters (account_entry_tag_find, chain_to_income, csv_safe_str) to const char. No behavior changes; no memory allocation, parsing, or trust boundary changes.
Changed components
plugins/bkpr/account_entry.cplugins/bkpr/account_entry.hplugins/bkpr/chain_event.hplugins/bkpr/channel_event.hplugins/bkpr/channelsapy.hplugins/bkpr/incomestmt.cplugins/bkpr/incomestmt.hplugins/bkpr/onchain_fee.hplugins/bkpr/recorder.hInspect captured patch +16 / −16
diff --git a/plugins/bkpr/account_entry.c b/plugins/bkpr/account_entry.c
index 0606c69b..a199fe42 100644
--- a/plugins/bkpr/account_entry.c
+++ b/plugins/bkpr/account_entry.c
@@ -16,7 +16,7 @@ const char *account_entry_tag_str(enum account_entry_tag tag)
return tags[tag];
}
-bool account_entry_tag_find(char *str, enum account_entry_tag *tag)
+bool account_entry_tag_find(const char *str, enum account_entry_tag *tag)
{
for (size_t i = 0; i < NUM_ACCOUNT_ENTRY_TAGS; i++) {
if (streq(str, tags[i])) {
diff --git a/plugins/bkpr/account_entry.h b/plugins/bkpr/account_entry.h
index 8823f672..ec6b8cca 100644
--- a/plugins/bkpr/account_entry.h
+++ b/plugins/bkpr/account_entry.h
@@ -14,5 +14,5 @@ enum account_entry_tag {
const char *account_entry_tag_str(enum account_entry_tag tag);
/* True if entry tag found, false otherwise */
-bool account_entry_tag_find(char *str, enum account_entry_tag *tag);
+bool account_entry_tag_find(const char *str, enum account_entry_tag *tag);
#endif /* LIGHTNING_PLUGINS_BKPR_ACCOUNT_ENTRY_H */
diff --git a/plugins/bkpr/chain_event.h b/plugins/bkpr/chain_event.h
index e04ba6f4..d4ea73ef 100644
--- a/plugins/bkpr/chain_event.h
+++ b/plugins/bkpr/chain_event.h
@@ -19,10 +19,10 @@ struct chain_event {
u64 acct_db_id;
/* Name of the account this belongs to */
- char *acct_name;
+ const char *acct_name;
/* Name of account this originated from */
- char *origin_acct;
+ const char *origin_acct;
/* Tag describing the event */
const char *tag;
diff --git a/plugins/bkpr/channel_event.h b/plugins/bkpr/channel_event.h
index c844f82d..8b449b85 100644
--- a/plugins/bkpr/channel_event.h
+++ b/plugins/bkpr/channel_event.h
@@ -18,7 +18,7 @@ struct channel_event {
u64 acct_db_id;
/* Name of the account this belongs to */
- char *acct_name;
+ const char *acct_name;
/* Tag describing the event */
const char *tag;
diff --git a/plugins/bkpr/channelsapy.h b/plugins/bkpr/channelsapy.h
index 1e4ccef2..d7c93884 100644
--- a/plugins/bkpr/channelsapy.h
+++ b/plugins/bkpr/channelsapy.h
@@ -5,7 +5,7 @@
#include <ccan/tal/tal.h>
struct channel_apy {
- char *acct_name;
+ const char *acct_name;
struct amount_msat routed_in;
struct amount_msat routed_out;
diff --git a/plugins/bkpr/incomestmt.c b/plugins/bkpr/incomestmt.c
index 99908868..a73437e5 100644
--- a/plugins/bkpr/incomestmt.c
+++ b/plugins/bkpr/incomestmt.c
@@ -33,7 +33,7 @@ static struct account *get_account(struct account **accts,
static struct income_event *chain_to_income(const tal_t *ctx,
struct chain_event *ev,
- char *acct_to_attribute,
+ const char *acct_to_attribute,
struct amount_msat credit,
struct amount_msat debit)
{
@@ -98,7 +98,7 @@ static struct income_event *onchainfee_to_income(const tal_t *ctx,
* by wrapping the desc in double-quotes ("). But what if
* there's already double-quotes? Well we swap these to
* single-quotes (') and then use the json_escape function */
-static char *csv_safe_str(const tal_t *ctx, char *input TAKES)
+static char *csv_safe_str(const tal_t *ctx, const char *input TAKES)
{
struct json_escape *esc;
char *dupe;
diff --git a/plugins/bkpr/incomestmt.h b/plugins/bkpr/incomestmt.h
index b381598f..1857718c 100644
--- a/plugins/bkpr/incomestmt.h
+++ b/plugins/bkpr/incomestmt.h
@@ -6,9 +6,9 @@
#include <stdio.h>
struct income_event {
- char *acct_name;
- char *tag;
- char *desc;
+ const char *acct_name;
+ const char *tag;
+ const char *desc;
struct amount_msat credit;
struct amount_msat debit;
/* Some CSVs require us to put fees on the
@@ -23,7 +23,7 @@ struct income_event {
/* Each csv format has a header and a 'row print' function */
struct csv_fmt {
- char *fmt_name;
+ const char *fmt_name;
void (*emit_header)(FILE *);
void (*emit_entry)(const tal_t *, FILE *, struct income_event *);
};
diff --git a/plugins/bkpr/onchain_fee.h b/plugins/bkpr/onchain_fee.h
index 03773a01..fde72cec 100644
--- a/plugins/bkpr/onchain_fee.h
+++ b/plugins/bkpr/onchain_fee.h
@@ -14,7 +14,7 @@ struct onchain_fee {
u64 acct_db_id;
/* Name of the account this belongs to */
- char *acct_name;
+ const char *acct_name;
/* Transaction that we're recording fees for */
struct bitcoin_txid txid;
diff --git a/plugins/bkpr/recorder.h b/plugins/bkpr/recorder.h
index 1e508889..eef9e297 100644
--- a/plugins/bkpr/recorder.h
+++ b/plugins/bkpr/recorder.h
@@ -17,7 +17,7 @@ struct onchain_fee;
struct fee_sum {
u64 acct_db_id;
- char *acct_name;
+ const char *acct_name;
struct bitcoin_txid *txid;
struct amount_msat fees_paid;
};
@@ -35,8 +35,8 @@ struct txo_set {
struct rebalance {
u64 in_ev_id;
u64 out_ev_id;
- char *in_acct_name;
- char *out_acct_name;
+ const char *in_acct_name;
+ const char *out_acct_name;
struct amount_msat rebal_msat;
struct amount_msat fee_msat;
};
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.