splice script: Add new PENDING state and log
What changed, and why it matters
This commit is a routine code refactor in Core Lightning's splicing plugin. It adds a new 'PENDING' state label for tracking wallet funding situations, moves a debug-logging helper function earlier in the source file, and improves the debug log output. There is no indication of a security fix or vulnerability.
No security action required. Review as normal code quality/refactor change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces SPLICE_CMD_PENDING to the splice_cmd_state enum and updates cmd_state_string() to return a formatted label for it. It also relocates cmd_state_string() and add_to_debug_log() earlier in splice.c and enhances add_to_debug_log() to temporarily simulate wallet output amounts and hide fee flags when generating debug strings for actions where the on-chain wallet pays the fee. This is purely diagnostic/state-tracking code; no cryptographic, network, or permission logic is modified.
Changed components
plugins/spender/splice.cplugins/spender/splice.hInspect captured patch +60 / −39
diff --git a/plugins/spender/splice.c b/plugins/spender/splice.c
index 005b9308..9fbfff59 100644
--- a/plugins/spender/splice.c
+++ b/plugins/spender/splice.c
@@ -20,6 +20,65 @@ struct abort_pkg {
char *str;
};
+static const char *cmd_state_string(enum splice_cmd_state state)
+{
+ switch (state) {
+ case SPLICE_CMD_NONE:
+ return " ";
+ case SPLICE_CMD_PENDING:
+ return " PENDING ";
+ case SPLICE_CMD_INIT:
+ return " INIT ";
+ case SPLICE_CMD_UPDATE:
+ return " UPDATE ";
+ case SPLICE_CMD_UPDATE_NEEDS_CHANGES:
+ return "UPDATE_NEEDS_CHANGES";
+ case SPLICE_CMD_UPDATE_DONE:
+ return " UPDATE_DONE ";
+ case SPLICE_CMD_RECVED_SIGS:
+ return " RECVED_SIGS ";
+ case SPLICE_CMD_DONE:
+ return " DONE ";
+ }
+ return NULL;
+}
+
+static void add_to_debug_log(struct splice_cmd *scmd, const char *phase)
+{
+ char **log = &scmd->debug_log;
+ if (!*log)
+ return;
+
+ tal_append_fmt(log, "#%d: (%s)\n", ++scmd->debug_counter, phase);
+
+ for (size_t i = 0; i < tal_count(scmd->actions); i++) {
+ struct splice_script_result *action = scmd->actions[i];
+ struct splice_cmd_action_state *state = scmd->states[i];
+ bool simulate_wallet_amount = false;
+ bool hide_fee = false;
+
+ if (action->onchain_wallet && action->pays_fee) {
+ if (amount_sat_is_zero(action->out_sat)) {
+ simulate_wallet_amount = true;
+ action->out_sat = scmd->needed_funds;
+ } else {
+ hide_fee = true;
+ action->pays_fee = false;
+ }
+ }
+
+ tal_append_fmt(log, "[%s] %s\n",
+ cmd_state_string(state->state),
+ splice_to_string(tmpctx, action));
+
+ if (simulate_wallet_amount)
+ action->out_sat = AMOUNT_SAT(0);
+
+ if (hide_fee)
+ action->pays_fee = true;
+ }
+}
+
static void debug_log_to_json(struct json_stream *response,
const char *debug_log)
{
@@ -847,45 +906,6 @@ static struct command_result *check_emergency_sat(struct command *cmd,
return NULL;
}
-static const char *cmd_state_string(enum splice_cmd_state state)
-{
- switch (state) {
- case SPLICE_CMD_NONE:
- return " ";
- case SPLICE_CMD_INIT:
- return " INIT ";
- case SPLICE_CMD_UPDATE:
- return " UPDATE ";
- case SPLICE_CMD_UPDATE_NEEDS_CHANGES:
- return "UPDATE_NEEDS_CHANGES";
- case SPLICE_CMD_UPDATE_DONE:
- return " UPDATE_DONE ";
- case SPLICE_CMD_RECVED_SIGS:
- return " RECVED_SIGS ";
- case SPLICE_CMD_DONE:
- return " DONE ";
- }
- return NULL;
-}
-
-static void add_to_debug_log(struct splice_cmd *scmd, const char *phase)
-{
- char **log = &scmd->debug_log;
- if (!*log)
- return;
-
- tal_append_fmt(log, "#%d: (%s)\n", ++scmd->debug_counter, phase);
-
- for (size_t i = 0; i < tal_count(scmd->actions); i++) {
- struct splice_script_result *action = scmd->actions[i];
- struct splice_cmd_action_state *state = scmd->states[i];
-
- tal_append_fmt(log, "[%s] %s\n",
- cmd_state_string(state->state),
- splice_to_string(tmpctx, action));
- }
-}
-
static struct command_result *handle_wetrun(struct command *cmd,
struct splice_cmd *splice_cmd)
{
diff --git a/plugins/spender/splice.h b/plugins/spender/splice.h
index 4f4e1ad2..97875d2a 100644
--- a/plugins/spender/splice.h
+++ b/plugins/spender/splice.h
@@ -14,6 +14,7 @@ enum splice_cmd_state {
SPLICE_CMD_UPDATE_NEEDS_CHANGES,
SPLICE_CMD_UPDATE_DONE,
SPLICE_CMD_RECVED_SIGS,
+ SPLICE_CMD_PENDING,
SPLICE_CMD_DONE,
};
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.