sign_tx: move the common ui confirmation decls to their own header
What changed, and why it matters
This commit is a straightforward code cleanup: it moves several on-screen confirmation function declarations from individual source files into a shared header file. There is no change to what the code actually does, no bug fix, and no security-related behavior change.
No security action needed; this is a benign refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors UI confirmation declarations for transaction signing. It creates main/ui/sign_tx.h containing forward declarations for show_btc_transaction_outputs_activity, show_btc_final_confirmation_activity, show_elements_transaction_outputs_activity, show_elements_final_confirmation_activity, and show_elements_swap_activity. It then replaces duplicated forward declarations in sign_liquid_tx.c, sign_psbt.c, sign_tx.c, and sign_tx.c with an include of the new header. It also removes redundant includes of ../ui.h and ../utils/network.h in some files and renames one local parameter from tx_is_partial to is_partial. No logic or security semantics are altered.
Changed components
main/process/sign_liquid_tx.cmain/process/sign_psbt.cmain/process/sign_tx.cmain/ui/sign_tx.cmain/ui/sign_tx.hInspect captured patch +38 / −37
diff --git a/main/process/sign_liquid_tx.c b/main/process/sign_liquid_tx.c
index e9eaef2..1cf2f50 100644
--- a/main/process/sign_liquid_tx.c
+++ b/main/process/sign_liquid_tx.c
@@ -1,10 +1,9 @@
#ifndef AMALGAMATED_BUILD
#include "../jade_assert.h"
#include "../jade_wally_verify.h"
-#include "../ui.h"
+#include "../ui/sign_tx.h"
#include "../utils/cbor_rpc.h"
#include "../utils/malloc_ext.h"
-#include "../utils/network.h"
#include "../utils/temporary_stack.h"
#include "../utils/util.h"
@@ -13,9 +12,6 @@
#include "process_utils.h"
-bool show_elements_final_confirmation_activity(
- const network_t network_id, const char* title, const uint64_t fee, const char* warning_msg);
-
static const char TX_TYPE_STR_SWAP[] = "swap";
static const char TX_TYPE_STR_SEND_PAYMENT[] = "send_payment";
diff --git a/main/process/sign_psbt.c b/main/process/sign_psbt.c
index 2512f3a..2039b70 100644
--- a/main/process/sign_psbt.c
+++ b/main/process/sign_psbt.c
@@ -8,11 +8,10 @@
#include "../process.h"
#include "../sensitive.h"
#include "../storage.h"
-#include "../ui.h"
+#include "../ui/sign_tx.h"
#include "../utils/cbor_rpc.h"
#include "../utils/event.h"
#include "../utils/malloc_ext.h"
-#include "../utils/network.h"
#include "../utils/psbt.h"
#include "../utils/temporary_stack.h"
#include "../utils/util.h"
@@ -28,19 +27,11 @@
#include "process_utils.h"
-bool show_btc_transaction_outputs_activity(
- network_t network_id, const struct wally_tx* tx, const output_info_t* output_info);
bool show_btc_fee_confirmation_activity(network_t network_id, const struct wally_tx* tx, const output_info_t* outinfo,
script_flavour_t aggregate_inputs_scripts_flavour, uint64_t input_amount, uint64_t output_amount);
-
-bool show_elements_transaction_outputs_activity(network_t network_id, const struct wally_tx* tx,
- const output_info_t* output_info, const asset_info_t* assets, size_t num_assets);
-bool show_elements_swap_activity(network_t network_id, bool initial_proposal, const asset_summary_t* in_sums,
- size_t num_in_sums, const asset_summary_t* out_sums, size_t num_out_sums, const asset_info_t* assets,
- size_t num_assets);
bool show_elements_fee_confirmation_activity(network_t network_id, const struct wally_tx* tx,
const output_info_t* outinfo, script_flavour_t aggregate_inputs_scripts_flavour, uint64_t fees, TxType_t txtype,
- bool tx_is_partial);
+ bool is_partial);
// From https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
static const uint8_t PSBT_MAGIC_PREFIX[5] = { 0x70, 0x73, 0x62, 0x74, 0xFF }; // 'psbt' + 0xff
@@ -1104,8 +1095,7 @@ void sign_psbt_process(void* process_ptr)
// Parse to wally structure
if (!deserialise_psbt(bytes, bytes_len, &psbt)) {
- jade_process_reject_message(
- process, CBOR_RPC_BAD_PARAMETERS, "Failed to extract psbt from passed bytes");
+ jade_process_reject_message(process, CBOR_RPC_BAD_PARAMETERS, "Failed to extract psbt from passed bytes");
goto cleanup;
}
jade_process_call_on_exit(process, jade_wally_free_psbt_wrapper, psbt);
diff --git a/main/process/sign_tx.c b/main/process/sign_tx.c
index 8488dd6..ea96e2b 100644
--- a/main/process/sign_tx.c
+++ b/main/process/sign_tx.c
@@ -1,4 +1,5 @@
#ifndef AMALGAMATED_BUILD
+#include "../ui/sign_tx.h"
#include "../button_events.h"
#include "../descriptor.h"
#include "../jade_assert.h"
@@ -7,11 +8,9 @@
#include "../multisig.h"
#include "../process.h"
#include "../sensitive.h"
-#include "../ui.h"
#include "../utils/cbor_rpc.h"
#include "../utils/event.h"
#include "../utils/malloc_ext.h"
-#include "../utils/network.h"
#include "../utils/wally_ext.h"
#include "../wallet.h"
@@ -38,22 +37,11 @@ bool asset_summary_update(asset_summary_t* sums, const size_t num_sums, const ui
const size_t asset_id_len, const uint64_t value);
bool asset_summary_validate(asset_summary_t* sums, const size_t num_sums);
-bool show_btc_transaction_outputs_activity(
- const network_t network_id, const struct wally_tx* tx, const output_info_t* output_info);
-bool show_elements_transaction_outputs_activity(const network_t network_id, const struct wally_tx* tx,
- const output_info_t* output_info, const asset_info_t* assets, size_t num_assets);
-
-bool show_elements_swap_activity(const network_t network_id, bool initial_proposal, const asset_summary_t* in_sums,
- size_t num_in_sums, const asset_summary_t* out_sums, size_t num_out_sums, const asset_info_t* assets,
- size_t num_assets);
-
-bool show_btc_final_confirmation_activity(network_t network_id, uint64_t fee, const char* warning_msg);
-bool show_elements_final_confirmation_activity(
- const network_t network_id, const char* title, const uint64_t fee, const char* 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);
+bool show_btc_fee_confirmation_activity(network_t network_id, const struct wally_tx* tx, const output_info_t* outinfo,
+ script_flavour_t aggregate_inputs_scripts_flavour, uint64_t input_amount, uint64_t output_amount);
+bool show_elements_fee_confirmation_activity(network_t network_id, const struct wally_tx* tx,
+ const output_info_t* outinfo, script_flavour_t aggregate_inputs_scripts_flavour, uint64_t fees, TxType_t txtype,
+ bool is_partial);
struct wally_tx* rpc_get_signing_tx(
jade_process_t* process, const CborValue* params, const network_t network_id, const bool for_liquid)
diff --git a/main/ui/sign_tx.c b/main/ui/sign_tx.c
index cc2119f..c27c775 100644
--- a/main/ui/sign_tx.c
+++ b/main/ui/sign_tx.c
@@ -9,9 +9,9 @@
#include "../jade_assert.h"
#include "../jade_wally_verify.h"
#include "../ui.h"
+#include "../ui/sign_tx.h"
#include "../utils/address.h"
#include "../utils/event.h"
-#include "../utils/network.h"
#include "../utils/util.h"
// from confirm_address
diff --git a/main/ui/sign_tx.h b/main/ui/sign_tx.h
new file mode 100644
index 0000000..97ba268
--- /dev/null
+++ b/main/ui/sign_tx.h
@@ -0,0 +1,27 @@
+#ifndef UI_SIGN_TX_H_
+#define UI_SIGN_TX_H_
+
+#include "../ui.h"
+#include "../utils/network.h"
+
+struct asset_info_t;
+struct asset_summary_t;
+struct output_info_t;
+struct wally_tx;
+
+bool show_btc_transaction_outputs_activity(
+ network_t network_id, const struct wally_tx* tx, const output_info_t* output_info);
+
+bool show_btc_final_confirmation_activity(const network_t network_id, uint64_t fee, const char* warning_msg);
+
+bool show_elements_transaction_outputs_activity(network_t network_id, const struct wally_tx* tx,
+ const output_info_t* output_info, const asset_info_t* assets, size_t num_assets);
+
+bool show_elements_final_confirmation_activity(
+ network_t network_id, const char* title, uint64_t fee, const char* warning_msg);
+
+bool show_elements_swap_activity(network_t network_id, bool initial_proposal, const asset_summary_t* in_sums,
+ size_t num_in_sums, const asset_summary_t* out_sums, size_t num_out_sums, const asset_info_t* assets,
+ size_t num_assets);
+
+#endif /* UI_SIGN_TX_H_ */
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.