xpay: clean preapprove*_succeed functions
What changed, and why it matters
This is a routine code cleanup in the xpay plugin. Two nearly identical functions that handle successful 'pre-approval' responses for invoice and keysend payments were merged into one shared function. There is no change in behavior, no bug fix, and no security relevance.
No security action needed. Treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors plugins/xpay/xpay.c by replacing preapproveinvoice_succeed and preapprovekeysend_succeed with a single preapprove_succeed function. Both original functions performed the exact same logic: conclude a check-only command or call populate_private_layer. The diff only changes function references and removes the duplicate implementation; no control flow, validation, or security logic is altered.
Changed components
plugins/xpay/xpay.cInspect captured patch +6 / −25
diff --git a/plugins/xpay/xpay.c b/plugins/xpay/xpay.c
index 277f1a55..d7a0649d 100644
--- a/plugins/xpay/xpay.c
+++ b/plugins/xpay/xpay.c
@@ -2133,11 +2133,8 @@ static struct command_result *populate_private_layer(struct command *cmd,
}
static struct command_result *
-preapproveinvoice_succeed(struct command *cmd,
- const char *method,
- const char *buf,
- const jsmntok_t *result,
- struct payment *payment)
+preapprove_succeed(struct command *cmd, const char *method, const char *buf,
+ const jsmntok_t *result, struct payment *payment)
{
/* Now we can conclude `check` command */
if (command_check_only(cmd)) {
@@ -2782,12 +2779,12 @@ static struct command_result *xpay_core(struct command *cmd,
/* Now preapprove, then start payment. */
if (command_check_only(cmd)) {
req = jsonrpc_request_start(cmd, "check",
- &preapproveinvoice_succeed,
+ &preapprove_succeed,
&forward_error, payment);
json_add_string(req->js, "command_to_check", "preapproveinvoice");
} else {
req = jsonrpc_request_start(cmd, "preapproveinvoice",
- &preapproveinvoice_succeed,
+ &preapprove_succeed,
&forward_error, payment);
}
json_add_string(req->js, "bolt11", payment->invstring);
@@ -2984,22 +2981,6 @@ static struct command_result *xpay_layer_created(struct command *aux_cmd,
return aux_command_done(aux_cmd);
}
-static struct command_result *
-preapprovekeysend_succeed(struct command *cmd,
- const char *method,
- const char *buf,
- const jsmntok_t *result,
- struct payment *payment)
-{
- /* Now we can conclude `check` command */
- if (command_check_only(cmd)) {
- return command_check_done(cmd);
- }
-
- /* Actually we don't need a private layer, but unification is easy. */
- return populate_private_layer(cmd, payment);
-}
-
static struct command_result *json_xkeysend(struct command *cmd,
const char *buf,
const jsmntok_t *params)
@@ -3083,12 +3064,12 @@ static struct command_result *json_xkeysend(struct command *cmd,
/* We do pre-approval immediately (note: even if command_check_only!) */
if (command_check_only(cmd)) {
req = jsonrpc_request_start(cmd, "check",
- preapprovekeysend_succeed,
+ preapprove_succeed,
forward_error, payment);
json_add_string(req->js, "command_to_check", "preapprovekeysend");
} else {
req = jsonrpc_request_start(cmd, "preapprovekeysend",
- preapprovekeysend_succeed,
+ preapprove_succeed,
forward_error, payment);
}
json_add_pubkey(req->js, "destination", &payment->destination);
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.