Skip to content

Commit 5af5636

Browse files
committed
wally: use common process cleanup wrappers for wally structs
Add a wally_map cleanup wrapper since it will be needed for taproot.
1 parent 20bc1be commit 5af5636

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

main/process/sign_liquid_tx.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ bool validate_wallet_outputs(jade_process_t* process, const char* network, const
3636
void send_ae_signature_replies(jade_process_t* process, signing_data_t* all_signing_data, uint32_t num_inputs);
3737
void send_ec_signature_replies(jade_msg_source_t source, signing_data_t* all_signing_data, uint32_t num_inputs);
3838

39-
static void wally_free_tx_wrapper(void* tx) { JADE_WALLY_VERIFY(wally_tx_free((struct wally_tx*)tx)); }
40-
4139
static const char TX_TYPE_STR_SWAP[] = "swap";
4240
static const char TX_TYPE_STR_SEND_PAYMENT[] = "send_payment";
4341
typedef enum { TXTYPE_UNKNOWN, TXTYPE_SEND_PAYMENT, TXTYPE_SWAP } TxType_t;
@@ -560,7 +558,7 @@ void sign_liquid_tx_process(void* process_ptr)
560558
jade_process_reject_message(process, CBOR_RPC_BAD_PARAMETERS, "Failed to extract tx from passed bytes", NULL);
561559
goto cleanup;
562560
}
563-
jade_process_call_on_exit(process, wally_free_tx_wrapper, tx);
561+
jade_process_call_on_exit(process, jade_wally_free_tx_wrapper, tx);
564562

565563
// copy the amount
566564
size_t num_inputs = 0;

main/process/sign_tx.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ bool show_btc_transaction_outputs_activity(
2626
const char* network, const struct wally_tx* tx, const output_info_t* output_info);
2727
bool show_btc_final_confirmation_activity(uint64_t fee, const char* warning_msg);
2828

29-
static void wally_free_tx_wrapper(void* tx) { JADE_WALLY_VERIFY(wally_tx_free((struct wally_tx*)tx)); }
30-
3129
// Can optionally be passed paths for change outputs, which we verify internally
3230
bool validate_wallet_outputs(jade_process_t* process, const char* network, const struct wally_tx* tx,
3331
CborValue* wallet_outputs, output_info_t* output_info, const char** errmsg)
@@ -414,7 +412,7 @@ void sign_tx_process(void* process_ptr)
414412
jade_process_reject_message(process, CBOR_RPC_BAD_PARAMETERS, "Failed to extract tx from passed bytes", NULL);
415413
goto cleanup;
416414
}
417-
jade_process_call_on_exit(process, wally_free_tx_wrapper, tx);
415+
jade_process_call_on_exit(process, jade_wally_free_tx_wrapper, tx);
418416

419417
// copy the amount
420418
size_t num_inputs = 0;

main/utils/wally_ext.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <freertos/FreeRTOS.h>
88
#include <freertos/task.h>
99
#include <stdint.h>
10+
#include <wally_map.h>
11+
#include <wally_transaction.h>
1012

1113
/* index == 0 is reserved for idf internal use,
1214
* see https://docs.espressif.com/projects/esp-idf/en/v4.3.2/esp32/api-guides/thread-local-storage.html
@@ -138,3 +140,7 @@ void jade_wally_init(void)
138140
set_jade_wally_ctx(&ctx, wally_get_secp_context());
139141
JADE_WALLY_VERIFY(wally_set_operations(&ops));
140142
}
143+
144+
void jade_wally_free_tx_wrapper(void* tx) { JADE_WALLY_VERIFY(wally_tx_free((struct wally_tx*)tx)); }
145+
146+
void jade_wally_free_map_wrapper(void* map) { JADE_WALLY_VERIFY(wally_map_free((struct wally_map*)map)); }

main/utils/wally_ext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
void jade_wally_init(void);
55
void jade_wally_randomize_secp_ctx(void);
66

7+
void jade_wally_free_tx_wrapper(void* tx);
8+
void jade_wally_free_map_wrapper(void* map);
9+
710
#endif /* UTILS_WALLY_EXT_H_ */

0 commit comments

Comments
 (0)