interactive_tx: Add verbose logging
What changed, and why it matters
This commit only adds extra debug logging to a transaction-handling routine. It does not change program logic, fix a bug, or introduce a security weakness. It is a diagnostic improvement.
No security action needed. Review as normal code-quality/logging change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds SUPERVERBOSE log statements to common/interactivetx.c so developers can inspect input additions/removals during interactive transaction construction. It also defines a SHA_FMT/SHA_VALS helper for printing 32-byte txids. No functional behavior is altered; existing error-return paths remain unchanged.
Changed components
common/interactivetx.cInspect captured patch +50 / −0
diff --git a/common/interactivetx.c b/common/interactivetx.c
index 0a72a7df..03ceb9d1 100644
--- a/common/interactivetx.c
+++ b/common/interactivetx.c
@@ -23,6 +23,10 @@
#include <common/subdaemon.h>
#include <common/wire_error.h>
+#ifndef SUPERVERBOSE
+#define SUPERVERBOSE(...)
+#endif
+
/*
* BOLT #2:
* The receiving node: ...
@@ -197,6 +201,18 @@ static u8 *read_next_msg(const tal_t *ctx,
}
}
+#define SHA_FMT \
+ "%02x%02x%02x%02x%02x%02x%02x%02x" \
+ "%02x%02x%02x%02x%02x%02x%02x%02x" \
+ "%02x%02x%02x%02x%02x%02x%02x%02x" \
+ "%02x%02x%02x%02x%02x%02x%02x%02x"
+
+#define SHA_VALS(e) \
+ e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], \
+ e[8], e[9], e[10], e[11], e[12], e[13], e[14], e[15], \
+ e[16], e[17], e[18], e[19], e[20], e[21], e[22], e[23], \
+ e[24], e[25], e[25], e[26], e[28], e[29], e[30], e[31]
+
static char *send_next(const tal_t *ctx,
struct interactivetx_context *ictx,
bool *finished)
@@ -268,6 +284,10 @@ static char *send_next(const tal_t *ctx,
return "interactivetx RM_INPUT PSBT has invalid"
" serial_id.";
+ SUPERVERBOSE("Removing input "SHA_FMT" with serial_id %s",
+ SHA_VALS(set->rm_ins[0].input.txhash),
+ tal_hexstr(ctx, &serial_id, sizeof(serial_id)));
+
msg = towire_tx_remove_input(NULL, cid, serial_id);
tal_arr_remove(&set->rm_ins, 0);
@@ -404,6 +424,36 @@ char *process_interactivetx_updates(const tal_t *ctx,
if (!next_psbt)
next_psbt = ictx->current_psbt;
+ SUPERVERBOSE("itx get_changes %zu inputs -> %zu inputs",
+ ictx->current_psbt->num_inputs,
+ next_psbt->num_inputs);
+
+ SUPERVERBOSE("current_psbt inputs:");
+ for(size_t i = 0; i < ictx->current_psbt->num_inputs; i++) {
+ u64 serial_id;
+ if (!psbt_get_serial_id(&ictx->current_psbt->inputs[i].unknowns,
+ &serial_id))
+ return "interactivetx ADD_INPUT PSBT has invalid"
+ " serial_id.";
+ SUPERVERBOSE("txhash: "SHA_FMT", index: %"PRIu32", serial_id: %s",
+ SHA_VALS(ictx->current_psbt->inputs[i].txhash),
+ ictx->current_psbt->inputs[i].index,
+ tal_hexstr(ctx, &serial_id, sizeof(serial_id)));
+ }
+
+ SUPERVERBOSE("next_psbt inputs:");
+ for(size_t i = 0; i < next_psbt->num_inputs; i++) {
+ u64 serial_id;
+ if (!psbt_get_serial_id(&next_psbt->inputs[i].unknowns,
+ &serial_id))
+ return "interactivetx ADD_INPUT PSBT has invalid"
+ " serial_id.";
+ SUPERVERBOSE("txhash: "SHA_FMT", index: %"PRIu32", serial_id: %s",
+ SHA_VALS(next_psbt->inputs[i].txhash),
+ next_psbt->inputs[i].index,
+ tal_hexstr(ctx, &serial_id, sizeof(serial_id)));
+ }
+
ictx->change_set = get_changes(ctx, ictx, next_psbt);
/* If current_psbt and next_psbt are the same, dont double free it!
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.