sign_tx: move btc fee confirmation impl to sign_utils
What changed, and why it matters
This commit simply moves an existing Bitcoin transaction fee confirmation function from one source file to another. The code logic is copied verbatim with no functional changes, so it does not fix, introduce, or change any security behavior.
No security action needed; treat as routine code cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure refactor: show_btc_fee_confirmation_activity() is removed from main/process/sign_tx.c and added to main/process/sign_utils.c. The function body, assertions, warning logic, and call to show_btc_final_confirmation_activity() are identical. No callers, signatures, or behavior are modified.
Changed components
main/process/sign_tx.cmain/process/sign_utils.cInspect captured patch +43 / −44
diff --git a/main/process/sign_tx.c b/main/process/sign_tx.c
index f097cf6..cb40b09 100644
--- a/main/process/sign_tx.c
+++ b/main/process/sign_tx.c
@@ -333,50 +333,6 @@ cleanup:
return true;
}
-bool show_btc_fee_confirmation_activity(const network_t network_id, const struct wally_tx* tx,
- const output_info_t* outinfo, const script_flavour_t aggregate_inputs_scripts_flavour, const uint64_t input_amount,
- const uint64_t output_amount)
-{
- JADE_ASSERT(tx);
- // outputinfo is optional
- JADE_ASSERT(input_amount);
- JADE_ASSERT(output_amount);
-
- JADE_ASSERT(input_amount >= output_amount);
-
- // User to agree fee amount
- // The fee amount is the shortfall between input and output amounts
- // The 'spend' amount is the total of the outputs not flagged as change
- const uint64_t fees = input_amount - output_amount;
- uint64_t spend_amount = output_amount;
- if (outinfo) {
- for (size_t i = 0; i < tx->num_outputs; ++i) {
- if (outinfo[i].flags & OUTPUT_FLAG_CHANGE) {
- // Deduct change output amount
- JADE_ASSERT(spend_amount >= tx->outputs[i].satoshi);
- spend_amount -= tx->outputs[i].satoshi;
- }
- }
- }
-
- char warnbuf[128]; // sufficient
- const char* warning_msg = NULL;
- const bool warn_fees = fees && fees >= spend_amount;
- const bool warn_scripts = aggregate_inputs_scripts_flavour == SCRIPT_FLAVOUR_MIXED;
- if (warn_fees && warn_scripts) {
- const int retval = snprintf(warnbuf, sizeof(warnbuf), "%s %s", WARN_MSG_HIGH_FEES, WARN_MSG_MIXED_INPUTS);
- JADE_ASSERT(retval > 0 && retval < sizeof(warnbuf));
- warning_msg = warnbuf;
- } else if (warn_scripts) {
- warning_msg = WARN_MSG_MIXED_INPUTS;
- } else if (warn_fees) {
- warning_msg = WARN_MSG_HIGH_FEES;
- }
-
- // Return whether the user accepts or declines
- return show_btc_final_confirmation_activity(network_id, fees, warning_msg);
-}
-
// Loop to generate and send Anti-Exfil signatures as they are requested.
static void send_ae_signature_replies(const network_t network_id, jade_process_t* process, signing_data_t* signing_data)
{
diff --git a/main/process/sign_utils.c b/main/process/sign_utils.c
index 86de814..763548a 100644
--- a/main/process/sign_utils.c
+++ b/main/process/sign_utils.c
@@ -631,6 +631,49 @@ done:
return true;
}
+bool show_btc_fee_confirmation_activity(const network_t network_id, const struct wally_tx* tx, const output_info_t* outinfo,
+ const script_flavour_t aggregate_inputs_scripts_flavour, const uint64_t input_amount, const uint64_t output_amount)
+{
+ JADE_ASSERT(tx);
+ // outputinfo is optional
+ JADE_ASSERT(input_amount);
+ JADE_ASSERT(output_amount);
+
+ JADE_ASSERT(input_amount >= output_amount);
+
+ // User to agree fee amount
+ // The fee amount is the shortfall between input and output amounts
+ // The 'spend' amount is the total of the outputs not flagged as change
+ const uint64_t fees = input_amount - output_amount;
+ uint64_t spend_amount = output_amount;
+ if (outinfo) {
+ for (size_t i = 0; i < tx->num_outputs; ++i) {
+ if (outinfo[i].flags & OUTPUT_FLAG_CHANGE) {
+ // Deduct change output amount
+ JADE_ASSERT(spend_amount >= tx->outputs[i].satoshi);
+ spend_amount -= tx->outputs[i].satoshi;
+ }
+ }
+ }
+
+ char warnbuf[128]; // sufficient
+ const char* warning_msg = NULL;
+ const bool warn_fees = fees && fees >= spend_amount;
+ const bool warn_scripts = aggregate_inputs_scripts_flavour == SCRIPT_FLAVOUR_MIXED;
+ if (warn_fees && warn_scripts) {
+ const int retval = snprintf(warnbuf, sizeof(warnbuf), "%s %s", WARN_MSG_HIGH_FEES, WARN_MSG_MIXED_INPUTS);
+ JADE_ASSERT(retval > 0 && retval < sizeof(warnbuf));
+ warning_msg = warnbuf;
+ } else if (warn_scripts) {
+ warning_msg = WARN_MSG_MIXED_INPUTS;
+ } else if (warn_fees) {
+ warning_msg = WARN_MSG_HIGH_FEES;
+ }
+
+ // Return whether the user accepts or declines
+ return show_btc_final_confirmation_activity(network_id, fees, warning_msg);
+}
+
bool show_elements_fee_confirmation_activity(const network_t network_id, const struct wally_tx* tx,
const output_info_t* outinfo, const script_flavour_t aggregate_inputs_scripts_flavour, const uint64_t fees,
const TxType_t txtype, const bool is_partial)
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.