wallet: rename b32script to scriptpubkey in PSBT change paths
What changed, and why it matters
This commit is a simple variable rename inside a Bitcoin/Lightning wallet file. The old name 'b32script' suggested all change addresses were bech32 format, but the project now uses a newer address type (p2tr) by default. The developer renamed the variable to 'scriptpubkey' to avoid confusion and removed an unused header file. No behavior of the program changes.
No security action needed; treat as routine code hygiene.
Security signals we found
No strong security signals were identified.
Evidence from the diff
Pure refactoring in wallet/reservation.c: renames local variables b32script/scriptpubkey in finish_psbt() and json_addpsbtoutput(), plus removal of the unused #include
Changed components
wallet/reservation.cInspect captured patch +12 / −14
diff --git a/wallet/reservation.c b/wallet/reservation.c
index a340cd8..f268998 100644
--- a/wallet/reservation.c
+++ b/wallet/reservation.c
@@ -11,7 +11,6 @@
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <wallet/txfilter.h>
/* 12 hours is usually enough reservation time */
#define RESERVATION_DEFAULT (6 * 12)
@@ -360,7 +359,7 @@ static struct command_result *finish_psbt(struct command *cmd,
change = change_amount(change, feerate_per_kw, weight);
if (amount_sat_greater(change, AMOUNT_SAT(0))) {
s64 keyidx;
- u8 *b32script;
+ u8 *scriptpubkey;
enum addrtype type;
/* FIXME: P2TR for elements! */
@@ -377,18 +376,17 @@ static struct command_result *finish_psbt(struct command *cmd,
" Keys exhausted.");
if (chainparams->is_elements) {
- b32script = p2wpkh_for_keyidx(tmpctx, cmd->ld, keyidx);
+ scriptpubkey = p2wpkh_for_keyidx(tmpctx, cmd->ld, keyidx);
} else {
- b32script = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
+ scriptpubkey = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
}
- if (!b32script) {
+ if (!scriptpubkey) {
return command_fail(cmd, LIGHTNINGD,
"Failed to generate change address."
" Keys generation failure");
}
-
change_outnum = psbt->num_outputs;
- psbt_append_output(psbt, b32script, change);
+ psbt_append_output(psbt, scriptpubkey, change);
/* Add additional weight of output */
weight += bitcoin_tx_output_weight(
chainparams->is_elements ? BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN : BITCOIN_SCRIPTPUBKEY_P2TR_LEN);
@@ -656,7 +654,7 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
ssize_t outnum;
u32 weight;
s64 keyidx;
- const u8 *b32script;
+ const u8 *scriptpubkey;
bool *add_initiator_serial_ids;
struct wally_psbt_output *output;
u64 serial_id;
@@ -666,7 +664,7 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
p_opt("initialpsbt", param_psbt, &psbt),
p_opt("locktime", param_number, &locktime),
p_opt("destination", param_bitcoin_address,
- &b32script),
+ &scriptpubkey),
p_opt_def("add_initiator_serial_ids", param_bool,
&add_initiator_serial_ids, false),
NULL))
@@ -698,7 +696,7 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
return command_check_done(cmd);
/* Get a change adddress */
- if (!b32script) {
+ if (!scriptpubkey) {
enum addrtype type;
/* FIXME: P2TR for elements! */
@@ -714,12 +712,12 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
" Keys exhausted.");
if (chainparams->is_elements) {
- b32script = p2wpkh_for_keyidx(tmpctx, cmd->ld, keyidx);
+ scriptpubkey = p2wpkh_for_keyidx(tmpctx, cmd->ld, keyidx);
} else {
- b32script = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
+ scriptpubkey = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
}
- if (!b32script) {
+ if (!scriptpubkey) {
return command_fail(cmd, LIGHTNINGD,
"Failed to generate change address."
" Keys generation failure");
@@ -727,7 +725,7 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
}
outnum = psbt->num_outputs;
- output = psbt_append_output(psbt, b32script, *amount);
+ output = psbt_append_output(psbt, scriptpubkey, *amount);
if (*add_initiator_serial_ids) {
serial_id = psbt_new_output_serial(psbt, TX_INITIATOR);
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.