build: annotate functions returning error codes to ensure they are checked
What changed, and why it matters
This commit is a preventive build-hardening change. It adds compiler annotations (WARN_UNUSED_RESULT) to many functions that return success/failure codes, so the compiler will warn if a caller ignores the result. The goal is to catch future bugs where an error return is silently dropped, but the commit itself does not fix any specific known bug or change runtime behavior.
Treat as routine hardening. After merging, enable -Werror or equivalent so that newly introduced unchecked returns become build failures, then audit any existing warnings that this annotation surfaces. No immediate incident response is warranted.
Security signals we found
Compiler annotation added to enforce checking of error-returning functions
No specific vulnerability fixed in the diff
No functional code changes or call-site fixes included
Hardening pattern commonly used to prevent ignored-failure bugs
Evidence from the diff
The patch adds #include “jade_assert.h” to 25 header files and prefixes many bool-returning functions with WARN_UNUSED_RESULT. This macro likely expands to an attribute such as attribute((warn_unused_result)) on GCC/Clang. The change is purely declarative: no function bodies, call sites, or logic are modified. It increases the chance that unchecked error returns will produce compile-time warnings, which can then be addressed. It is a defensive, non-functional change.
Changed components
main/aes.hmain/assets.hmain/attestation/attestation.hmain/bcur.hmain/descriptor.hmain/identity.hmain/keychain.hmain/multisig.hmain/otpauth.hmain/process.hmain/process/process_utils.hmain/process/sign_utils.hmain/qrcode.hmain/qrmode.hmain/qrscan.hmain/rsa.hmain/serial.hmain/signer.hmain/storage.hmain/utils/address.hmain/utils/event.hmain/utils/psbt.hmain/utils/urldecode.hmain/utils/util.hmain/wallet.hInspect captured patch +215 / −152
diff --git a/main/aes.h b/main/aes.h
index 8f677e1..9e8a87b 100644
--- a/main/aes.h
+++ b/main/aes.h
@@ -6,6 +6,8 @@
#include <wally_crypto.h>
+#include "jade_assert.h"
+
// Round 'len' up to next multiple of AES_BLOCK_LEN
// NOTE: exact multiples are rounded up to the next multiple
#define AES_PADDED_LEN(len) (((len / AES_BLOCK_LEN) + 1) * AES_BLOCK_LEN)
@@ -13,10 +15,10 @@
// iv, padded payload (un-padded length provided)
#define AES_ENCRYPTED_LEN(len) (AES_BLOCK_LEN + AES_PADDED_LEN(len))
-bool aes_encrypt_bytes(const uint8_t* aeskey, size_t aeskey_len, const uint8_t* bytes, size_t bytes_len,
- uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool aes_encrypt_bytes(const uint8_t* aeskey, size_t aeskey_len, const uint8_t* bytes,
+ size_t bytes_len, uint8_t* output, size_t output_len);
-bool aes_decrypt_bytes(const uint8_t* aeskey, size_t aeskey_len, const uint8_t* bytes, size_t bytes_len,
- uint8_t* output, size_t output_len, size_t* written);
+WARN_UNUSED_RESULT bool aes_decrypt_bytes(const uint8_t* aeskey, size_t aeskey_len, const uint8_t* bytes,
+ size_t bytes_len, uint8_t* output, size_t output_len, size_t* written);
#endif /* AES_H_ */
\ No newline at end of file
diff --git a/main/assets.h b/main/assets.h
index 7f7a402..1b715bf 100644
--- a/main/assets.h
+++ b/main/assets.h
@@ -1,6 +1,7 @@
#ifndef JADE_ASSETS_H_
#define JADE_ASSETS_H_
+#include "jade_assert.h"
#include "utils/cbor_rpc.h"
#include "utils/network.h"
@@ -15,9 +16,10 @@ typedef struct _asset_info {
uint8_t precision;
} asset_info_t;
-bool assets_get_allocate(const char* field, const CborValue* value, asset_info_t** data, size_t* written);
+WARN_UNUSED_RESULT bool assets_get_allocate(
+ const char* field, const CborValue* value, asset_info_t** data, size_t* written);
-bool assets_get_info(network_t network_id, const asset_info_t* assets, size_t num_assets, const char* asset_id,
- asset_info_t* asset_info_out);
+WARN_UNUSED_RESULT bool assets_get_info(network_t network_id, const asset_info_t* assets, size_t num_assets,
+ const char* asset_id, asset_info_t* asset_info_out);
#endif /* JADE_ASSETS_H_ */
diff --git a/main/attestation/attestation.h b/main/attestation/attestation.h
index 5cb422e..8d855d1 100644
--- a/main/attestation/attestation.h
+++ b/main/attestation/attestation.h
@@ -5,6 +5,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "../jade_assert.h"
+
// RSA 4096-bit key
#define JADE_ATTEST_RSA_KEY_LEN 512
#define JADE_ATTEST_RSA_PUBKEY_PEM_MAX_LEN 832 // usually 800
@@ -14,15 +16,15 @@ bool attestation_can_be_initialised(void);
bool attestation_initialised(void);
-bool attestation_initialise(const char* privkey_pem, size_t privkey_pem_len, const char* ext_pubkey_pem,
- size_t ext_pubkey_pem_len, const uint8_t* ext_signature, size_t ext_signature_len);
+WARN_UNUSED_RESULT bool attestation_initialise(const char* privkey_pem, size_t privkey_pem_len,
+ const char* ext_pubkey_pem, size_t ext_pubkey_pem_len, const uint8_t* ext_signature, size_t ext_signature_len);
-bool attestation_sign_challenge(const uint8_t* challenge, size_t challenge_len, uint8_t* signature,
+WARN_UNUSED_RESULT bool attestation_sign_challenge(const uint8_t* challenge, size_t challenge_len, uint8_t* signature,
size_t signature_len, char* pubkey_pem, size_t pubkey_pem_len, size_t* pem_written, uint8_t* ext_signature,
size_t ext_signature_len, size_t* ext_sig_written);
-bool attestation_verify(const uint8_t* challenge, size_t challenge_len, const char* pubkey_pem, size_t pubkey_pem_len,
- const uint8_t* signature, size_t signature_len, const char* ext_pubkey_pem, size_t ext_pubkey_pem_len,
- const uint8_t* ext_signature, size_t ext_signature_len);
+WARN_UNUSED_RESULT bool attestation_verify(const uint8_t* challenge, size_t challenge_len, const char* pubkey_pem,
+ size_t pubkey_pem_len, const uint8_t* signature, size_t signature_len, const char* ext_pubkey_pem,
+ size_t ext_pubkey_pem_len, const uint8_t* ext_signature, size_t ext_signature_len);
#endif /* JADE_ATTESTATION_H_ */
diff --git a/main/bcur.h b/main/bcur.h
index 742b0e9..a205f06 100644
--- a/main/bcur.h
+++ b/main/bcur.h
@@ -6,6 +6,7 @@
#include <stdint.h>
#include "display.h"
+#include "jade_assert.h"
#include "utils/cbor_rpc.h"
#include "wallet.h"
@@ -24,20 +25,25 @@ extern const char BCUR_TYPE_JADE_BIP8539_REPLY[];
extern const char BCUR_TYPE_BYTES[];
// Parse BC-UR messages - decodes BC-UR and parses nested CBOR
-bool bcur_parse_bip39_wrapper(const char* bcur, size_t bcur_len, char* mnemonic, size_t mnemonic_len, size_t* written);
-bool bcur_parse_bip39(const uint8_t* cbor, size_t cbor_len, char* mnemonic, size_t mnemonic_len, size_t* written);
-bool bcur_parse_bytes(const uint8_t* cbor, size_t cbor_len, const uint8_t** bytes, size_t* bytes_len);
-bool bcur_parse_psbt(const uint8_t* cbor, size_t cbor_len, struct wally_psbt** psbt_out);
-bool bcur_parse_jade_message(const uint8_t* cbor, size_t cbor_len, CborParser* parser, CborValue* root,
- const char* expected_method, CborValue* params);
+WARN_UNUSED_RESULT bool bcur_parse_bip39_wrapper(
+ const char* bcur, size_t bcur_len, char* mnemonic, size_t mnemonic_len, size_t* written);
+WARN_UNUSED_RESULT bool bcur_parse_bip39(
+ const uint8_t* cbor, size_t cbor_len, char* mnemonic, size_t mnemonic_len, size_t* written);
+WARN_UNUSED_RESULT bool bcur_parse_bytes(
+ const uint8_t* cbor, size_t cbor_len, const uint8_t** bytes, size_t* bytes_len);
+WARN_UNUSED_RESULT bool bcur_parse_psbt(const uint8_t* cbor, size_t cbor_len, struct wally_psbt** psbt_out);
+WARN_UNUSED_RESULT bool bcur_parse_jade_message(const uint8_t* cbor, size_t cbor_len, CborParser* parser,
+ CborValue* root, const char* expected_method, CborValue* params);
// Build BC-UR CBOR messages
void bcur_build_cbor_crypto_hdkey(
const uint32_t* path, size_t path_len, uint8_t* output, size_t output_len, size_t* written);
void bcur_build_cbor_crypto_account(script_variant_t script_variant, const uint32_t* path, size_t path_len,
uint8_t* output, size_t output_len, size_t* written);
-bool bcur_build_cbor_bytes(const uint8_t* data, size_t data_len, uint8_t** output, size_t* output_len);
-bool bcur_build_cbor_crypto_psbt(const struct wally_psbt* psbt, uint8_t** output, size_t* output_len);
+WARN_UNUSED_RESULT bool bcur_build_cbor_bytes(
+ const uint8_t* data, size_t data_len, uint8_t** output, size_t* output_len);
+WARN_UNUSED_RESULT bool bcur_build_cbor_crypto_psbt(
+ const struct wally_psbt* psbt, uint8_t** output, size_t* output_len);
// Scan a QR code that may be a BC-UR code/fragment - ie. single-frame or animated/multi-frame.
// Returns true if a complete (ie. potentially multi-frame) bc-ur code is scanned, or if a single
@@ -48,8 +54,8 @@ bool bcur_build_cbor_crypto_psbt(const struct wally_psbt* psbt, uint8_t** output
// If not BC-UR, the scanned payload is returned with a type of NULL.
// In either case the caller takes ownership, and must free the output data bytes and any type string.
// Returns false if scanning fails or is abandoned - in which case there is nothing to free.
-bool bcur_scan_qr(const char* prompt_text, char** output_type, uint8_t** output, size_t* output_len, size_t offset,
- const char* help_url);
+WARN_UNUSED_RESULT bool bcur_scan_qr(const char* prompt_text, char** output_type, uint8_t** output, size_t* output_len,
+ size_t offset, const char* help_url);
// Encodes the passed payload into a set of one or more BC-UR fragments with the given 'type'.
// These are then rendered as a set of QR codes of the passed version/size.
diff --git a/main/descriptor.h b/main/descriptor.h
index 2599a09..40c71bc 100644
--- a/main/descriptor.h
+++ b/main/descriptor.h
@@ -1,6 +1,7 @@
#ifndef DESCRIPTOR_H_
#define DESCRIPTOR_H_
+#include "jade_assert.h"
#include "signer.h"
#include "utils/network.h"
@@ -55,31 +56,34 @@ bool descriptor_allow_liquid(void);
// If `signers` is NULL then only the number of signers is returned in `written` (and `blinding_key` is ignored).
// If `blinding_key` is non-NULL, then the blinding key hex value is returned (if present in descriptor)
// - caller must free the blinding key with wally_free_string().
-bool descriptor_get_signers(const char* name, const descriptor_data_t* descriptor, const network_t network_id,
- descriptor_type_t* type, signer_t* signers, size_t signers_len, size_t* written, char** blinding_key,
- const char** errmsg);
+WARN_UNUSED_RESULT bool descriptor_get_signers(const char* name, const descriptor_data_t* descriptor,
+ const network_t network_id, descriptor_type_t* type, signer_t* signers, size_t signers_len, size_t* written,
+ char** blinding_key, const char** errmsg);
// Generate an address using a descriptor/miniscript expression
// On success output must be freed with wally_free_string()
-bool descriptor_to_address(const char* name, const descriptor_data_t* descriptor, const network_t network_id,
- uint32_t multi_index, uint32_t child_num, descriptor_type_t* type, char** output, const char** errmsg);
+WARN_UNUSED_RESULT bool descriptor_to_address(const char* name, const descriptor_data_t* descriptor,
+ const network_t network_id, uint32_t multi_index, uint32_t child_num, descriptor_type_t* type, char** output,
+ const char** errmsg);
// Generate a script using a descriptor/miniscript expression
// On success output must be freed
// NOTE: For miniscript expressions, the script generated is untyped bitcoin script.
// For descriptors, a scriptPubKey is generated.
-bool descriptor_to_script(const char* name, const descriptor_data_t* descriptor, const network_t network_id,
- uint32_t multi_index, uint32_t child_num, descriptor_type_t* type, uint8_t** output, size_t* output_len,
- const char** errmsg);
+WARN_UNUSED_RESULT bool descriptor_to_script(const char* name, const descriptor_data_t* descriptor,
+ const network_t network_id, uint32_t multi_index, uint32_t child_num, descriptor_type_t* type, uint8_t** output,
+ size_t* output_len, const char** errmsg);
// Iterate over a number of leaf child indexes testing the generated script for a match against the passed script
-bool descriptor_search_for_script(const char* name, const descriptor_data_t* descriptor, const network_t network_id,
- uint32_t multi_index, uint32_t* child_num, size_t search_depth, const uint8_t* script, size_t script_len);
+WARN_UNUSED_RESULT bool descriptor_search_for_script(const char* name, const descriptor_data_t* descriptor,
+ const network_t network_id, uint32_t multi_index, uint32_t* child_num, size_t search_depth, const uint8_t* script,
+ size_t script_len);
// Storage related functions
-bool descriptor_to_bytes(descriptor_data_t* descriptor, uint8_t* output_bytes, size_t output_len);
-bool descriptor_from_bytes(const uint8_t* bytes, size_t bytes_len, descriptor_data_t* descriptor);
-bool descriptor_load_from_storage(const char* descriptor_name, descriptor_data_t* output, const char** errmsg);
+WARN_UNUSED_RESULT bool descriptor_to_bytes(descriptor_data_t* descriptor, uint8_t* output_bytes, size_t output_len);
+WARN_UNUSED_RESULT bool descriptor_from_bytes(const uint8_t* bytes, size_t bytes_len, descriptor_data_t* descriptor);
+WARN_UNUSED_RESULT bool descriptor_load_from_storage(
+ const char* descriptor_name, descriptor_data_t* output, const char** errmsg);
void descriptor_get_valid_record_names(
char names[][MAX_DESCRIPTOR_NAME_SIZE], const size_t num_names, size_t* num_written);
diff --git a/main/identity.h b/main/identity.h
index e614e12..904404f 100644
--- a/main/identity.h
+++ b/main/identity.h
@@ -6,6 +6,8 @@
#include <stdint.h>
#include <string.h>
+#include "jade_assert.h"
+
static inline bool is_identity_protocol_ssh(const char* identity, const size_t identity_len)
{
return identity_len > 6 && !memcmp(identity, "ssh://", 6);
@@ -46,13 +48,14 @@ static inline bool is_identity_curve_valid(const char* curve_name, const size_t
return is_identity_curve_nist256p1(curve_name, curve_name_len);
}
-bool get_identity_pubkey(const char* identity, size_t identity_len, size_t index, const char* curve, size_t curve_name,
- const char* type, size_t type_len, uint8_t* pubkey_out, size_t pubkey_out_len);
+WARN_UNUSED_RESULT bool get_identity_pubkey(const char* identity, size_t identity_len, size_t index, const char* curve,
+ size_t curve_name, const char* type, size_t type_len, uint8_t* pubkey_out, size_t pubkey_out_len);
-bool get_identity_shared_key(const char* identity, size_t identity_len, size_t index, const char* curve_name,
- size_t curve_name_len, const uint8_t* their_pubkey, size_t their_pubkey_len, uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool get_identity_shared_key(const char* identity, size_t identity_len, size_t index,
+ const char* curve_name, size_t curve_name_len, const uint8_t* their_pubkey, size_t their_pubkey_len,
+ uint8_t* output, size_t output_len);
-bool sign_identity(const char* identity, size_t identity_len, size_t index, const char* curve_name,
+WARN_UNUSED_RESULT bool sign_identity(const char* identity, size_t identity_len, size_t index, const char* curve_name,
size_t curve_name_len, const uint8_t* challenge_hash, size_t challenge_hash_len, uint8_t* pubkey_out,
size_t pubkey_out_len, uint8_t* signature_out, size_t signature_out_len);
diff --git a/main/keychain.h b/main/keychain.h
index 34aeb54..0b602c3 100644
--- a/main/keychain.h
+++ b/main/keychain.h
@@ -1,6 +1,7 @@
#ifndef KEYCHAIN_H_
#define KEYCHAIN_H_
+#include "jade_assert.h"
#include "utils/network.h"
#include <stdbool.h>
@@ -57,18 +58,20 @@ bool keychain_is_network_type_consistent(const network_type_t network_type);
// mnemonic returned should be freed by caller with wally_free_string
void keychain_get_new_mnemonic(char** mnemonic, size_t nwords);
-bool keychain_get_new_privatekey(uint8_t* privatekey, size_t size);
+WARN_UNUSED_RESULT bool keychain_get_new_privatekey(uint8_t* privatekey, size_t size);
bool keychain_has_pin(void);
uint8_t keychain_pin_attempts_remaining(void);
void keychain_erase_encrypted(void);
void keychain_derive_from_seed(const uint8_t* seed, size_t seed_len, keychain_t* keydata);
-bool keychain_derive_from_mnemonic(const char* mnemonic, const char* passphrase, keychain_t* keydata);
-bool keychain_complete_derivation_with_passphrase(const char* passphrase);
-
-bool keychain_store(const uint8_t* aeskey, size_t aeslen);
-bool keychain_load(const uint8_t* aeskey, size_t aeslen);
-bool keychain_reencrypt(const uint8_t* curr_aeskey, size_t curr_aeslen, const uint8_t* new_aeskey, size_t new_aeslen);
+WARN_UNUSED_RESULT bool keychain_derive_from_mnemonic(
+ const char* mnemonic, const char* passphrase, keychain_t* keydata);
+WARN_UNUSED_RESULT bool keychain_complete_derivation_with_passphrase(const char* passphrase);
+
+WARN_UNUSED_RESULT bool keychain_store(const uint8_t* aeskey, size_t aeslen);
+WARN_UNUSED_RESULT bool keychain_load(const uint8_t* aeskey, size_t aeslen);
+WARN_UNUSED_RESULT bool keychain_reencrypt(
+ const uint8_t* curr_aeskey, size_t curr_aeslen, const uint8_t* new_aeskey, size_t new_aeslen);
#endif /* KEYCHAIN_H_ */
diff --git a/main/multisig.h b/main/multisig.h
index 09740fe..13e1dfb 100644
--- a/main/multisig.h
+++ b/main/multisig.h
@@ -1,6 +1,7 @@
#ifndef MULTISIG_H_
#define MULTISIG_H_
+#include "jade_assert.h"
#include "signer.h"
#include "utils/cbor_rpc.h"
#include "wallet.h"
@@ -51,29 +52,29 @@ typedef struct _multisig_data {
uint8_t xpubs[MAX_ALLOWED_SIGNERS * BIP32_SERIALIZED_LEN];
} multisig_data_t;
-bool multisig_data_to_bytes(script_variant_t variant, bool sorted, uint8_t threshold,
+WARN_UNUSED_RESULT bool multisig_data_to_bytes(script_variant_t variant, bool sorted, uint8_t threshold,
const uint8_t* master_blinding_key, size_t master_blinding_key_len, const signer_t* signers, size_t num_signers,
size_t total_num_path_elements, uint8_t* output_bytes, size_t output_len);
-bool multisig_data_from_bytes(const uint8_t* bytes, size_t bytes_len, multisig_data_t* output, signer_t* signer_details,
- size_t signer_details_len, size_t* written);
+WARN_UNUSED_RESULT bool multisig_data_from_bytes(const uint8_t* bytes, size_t bytes_len, multisig_data_t* output,
+ signer_t* signer_details, size_t signer_details_len, size_t* written);
-bool multisig_load_from_storage(const char* multisig_name, multisig_data_t* output, signer_t* signer_details,
- size_t signer_details_len, size_t* written, const char** errmsg);
+WARN_UNUSED_RESULT bool multisig_load_from_storage(const char* multisig_name, multisig_data_t* output,
+ signer_t* signer_details, size_t signer_details_len, size_t* written, const char** errmsg);
-bool multisig_validate_paths(
+WARN_UNUSED_RESULT bool multisig_validate_paths(
const bool is_change, CborValue* all_signer_paths, bool* all_paths_as_expected, bool* final_elements_consistent);
-bool multisig_get_pubkeys(const uint8_t* xpubs, size_t num_xpubs, CborValue* all_signer_paths, uint8_t* pubkeys,
- size_t pubkeys_len, size_t* written);
+WARN_UNUSED_RESULT bool multisig_get_pubkeys(const uint8_t* xpubs, size_t num_xpubs, CborValue* all_signer_paths,
+ uint8_t* pubkeys, size_t pubkeys_len, size_t* written);
-bool multisig_get_master_blinding_key(const multisig_data_t* multisig_data, uint8_t* master_blinding_key,
- size_t master_blinding_key_len, const char** errmsg);
+WARN_UNUSED_RESULT bool multisig_get_master_blinding_key(const multisig_data_t* multisig_data,
+ uint8_t* master_blinding_key, size_t master_blinding_key_len, const char** errmsg);
void multisig_get_valid_record_names(
const size_t* script_type, char names[][MAX_MULTISIG_NAME_SIZE], size_t num_names, size_t* num_written);
-bool multisig_create_export_file(const char* multisig_name, const multisig_data_t* multisig_data,
+WARN_UNUSED_RESULT bool multisig_create_export_file(const char* multisig_name, const multisig_data_t* multisig_data,
const signer_t* signer_details, size_t num_signer_details, char* output, size_t output_len, size_t* written);
#endif /* MULTISIG_H_ */
diff --git a/main/otpauth.h b/main/otpauth.h
index 6dbdb55..f9cafa4 100644
--- a/main/otpauth.h
+++ b/main/otpauth.h
@@ -5,6 +5,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "jade_assert.h"
+
#define OTP_MAX_NAME_LEN 16
#define OTP_MAX_URI_LEN 256
#define OTP_MAX_TOKEN_LEN 12
@@ -45,13 +47,14 @@ typedef struct otpauth_migrate_decode_ctx {
typedef enum { OTP_ERR_OK, OTP_ERR_TOTP_TIME, OTP_ERR_HOTP_COUNTER } otp_err_t;
-bool otp_is_valid(const otpauth_ctx_t* otp_ctx);
+WARN_UNUSED_RESULT bool otp_is_valid(const otpauth_ctx_t* otp_ctx);
// Parse the otp uri into a context object
-bool otp_uri_to_ctx(const char* uri, size_t uri_len, otpauth_ctx_t* otp_ctx);
+WARN_UNUSED_RESULT bool otp_uri_to_ctx(const char* uri, size_t uri_len, otpauth_ctx_t* otp_ctx);
// Parse the otp migrate uri into a context object
-bool otp_migrate_uri_to_ctx(const char* uri, size_t uri_len, size_t max_uris, otpauth_migrate_ctx_t* ctx);
+WARN_UNUSED_RESULT bool otp_migrate_uri_to_ctx(
+ const char* uri, size_t uri_len, size_t max_uris, otpauth_migrate_ctx_t* ctx);
// Free the context object from parsing (whether successful or not)
void otp_migrate_uri_to_ctx_free(otpauth_migrate_ctx_t* ctx);
@@ -60,11 +63,11 @@ void otp_set_explicit_value(otpauth_ctx_t* otp_ctx, int64_t value);
otp_err_t otp_set_default_value(otpauth_ctx_t* otp_ctx, uint64_t* value_out);
// Get the auth code for the given context
-bool otp_get_auth_code(const otpauth_ctx_t* otp_ctx, char* token, size_t token_len);
+WARN_UNUSED_RESULT bool otp_get_auth_code(const otpauth_ctx_t* otp_ctx, char* token, size_t token_len);
// Functions to deal with uri encryption and persistence
// NOTE: otp_name must be nul-terminated, uri does not
-bool otp_save_uri(const char* otp_name, const char* uri, size_t uri_len);
-bool otp_load_uri(const char* otp_name, char* uri, size_t uri_len, size_t* written);
+WARN_UNUSED_RESULT bool otp_save_uri(const char* otp_name, const char* uri, size_t uri_len);
+WARN_UNUSED_RESULT bool otp_load_uri(const char* otp_name, char* uri, size_t uri_len, size_t* written);
#endif /* OTPAUTH_H_ */
diff --git a/main/process.h b/main/process.h
index 5aa1bca..da5c0c6 100644
--- a/main/process.h
+++ b/main/process.h
@@ -12,6 +12,8 @@
#include <cbor.h>
+#include "jade_assert.h"
+
// This should be the size of the largest valid input message.
// Used by ble and serial when reading data in. (sign-liquid-txn)
// NOTE: limited to 17k when SPIRAM not enabled.
@@ -65,7 +67,7 @@ typedef struct {
} bytes_info_t;
const char* get_jade_id(void);
-bool jade_process_init(
+WARN_UNUSED_RESULT bool jade_process_init(
TaskHandle_t** serial_handle, TaskHandle_t** ble_handle, TaskHandle_t** qemu_tcp_handle, TaskHandle_t** gui_handle);
// Intialise and cleanup jade process structs
@@ -83,7 +85,7 @@ void jade_process_transfer_current_message(jade_process_t* process, jade_process
void jade_process_free_current_message(jade_process_t* process);
// Push messages to/from a process
-bool jade_process_push_in_message(const uint8_t* data, size_t size);
+WARN_UNUSED_RESULT bool jade_process_push_in_message(const uint8_t* data, size_t size);
void jade_process_push_out_message(const uint8_t* data, size_t length, jade_msg_source_t source);
// Send message replies
diff --git a/main/process/process_utils.h b/main/process/process_utils.h
index c03f974..da2bfb7 100644
--- a/main/process/process_utils.h
+++ b/main/process/process_utils.h
@@ -1,6 +1,7 @@
#ifndef PROCESS_UTILS_H_
#define PROCESS_UTILS_H_
+#include "../jade_assert.h"
#include "../keychain.h"
#include "../process.h"
#include "../utils/cbor_rpc.h"
@@ -117,29 +118,31 @@ bool check_extended_data_fields(CborValue* params, const char* expected_origid,
// Common parameter extraction/handling
int params_set_epoch_time(CborValue* params, const char** errmsg);
-bool params_identity_curve_index(CborValue* params, const char** identity, size_t* identity_len, const char** curve,
- size_t* curve_len, size_t* index, const char** errmsg);
+WARN_UNUSED_RESULT bool params_identity_curve_index(CborValue* params, const char** identity, size_t* identity_len,
+ const char** curve, size_t* curve_len, size_t* index, const char** errmsg);
-bool params_hashprevouts_outputindex(CborValue* params, const uint8_t** hash_prevouts, size_t* hash_prevouts_len,
- size_t* output_index, const char** errmsg);
+WARN_UNUSED_RESULT bool params_hashprevouts_outputindex(CborValue* params, const uint8_t** hash_prevouts,
+ size_t* hash_prevouts_len, size_t* output_index, const char** errmsg);
typedef struct _descriptor_data descriptor_data_t;
-bool params_load_descriptor(CborValue* params, char* descriptor_name, const size_t descriptor_name_len,
- descriptor_data_t* descriptor, const char** errmsg);
+WARN_UNUSED_RESULT bool params_load_descriptor(CborValue* params, char* descriptor_name,
+ const size_t descriptor_name_len, descriptor_data_t* descriptor, const char** errmsg);
typedef struct _multisig_data multisig_data_t;
-bool params_load_multisig(CborValue* params, char* multisig_name, size_t multisig_name_len,
+WARN_UNUSED_RESULT bool params_load_multisig(CborValue* params, char* multisig_name, size_t multisig_name_len,
multisig_data_t* multisig_data, const char** errmsg);
-bool params_multisig_pubkeys(bool is_change, CborValue* params, multisig_data_t* multisig_data, uint8_t* pubkeys,
- size_t pubkeys_len, size_t* pubkeys_written, char* warningmsg, size_t warningmsg_len, const char** errmsg);
-bool params_get_master_blindingkey(
+WARN_UNUSED_RESULT bool params_multisig_pubkeys(bool is_change, CborValue* params, multisig_data_t* multisig_data,
+ uint8_t* pubkeys, size_t pubkeys_len, size_t* pubkeys_written, char* warningmsg, size_t warningmsg_len,
+ const char** errmsg);
+WARN_UNUSED_RESULT bool params_get_master_blindingkey(
CborValue* params, uint8_t* master_blinding_key, size_t master_blinding_key_len, const char** errmsg);
-bool params_tx_input_signing_data(const bool use_ae_signatures, CborValue* params, input_data_t* sig_data,
- const uint8_t** ae_host_commitment, size_t* ae_host_commitment_len, const uint8_t** script, size_t* script_len,
- script_flavour_t* aggregate_script_flavour, const char** errmsg);
+WARN_UNUSED_RESULT bool params_tx_input_signing_data(const bool use_ae_signatures, CborValue* params,
+ input_data_t* sig_data, const uint8_t** ae_host_commitment, size_t* ae_host_commitment_len, const uint8_t** script,
+ size_t* script_len, script_flavour_t* aggregate_script_flavour, const char** errmsg);
-bool params_get_bip85_rsa_key(CborValue* params, size_t* key_bits, size_t* index, const char** errmsg);
+WARN_UNUSED_RESULT bool params_get_bip85_rsa_key(
+ CborValue* params, size_t* key_bits, size_t* index, const char** errmsg);
// Track the types of the input prevout scripts
script_flavour_t get_script_flavour(const uint8_t* script, const size_t script_len, bool* is_p2tr);
diff --git a/main/process/sign_utils.h b/main/process/sign_utils.h
index 1324627..c25df06 100644
--- a/main/process/sign_utils.h
+++ b/main/process/sign_utils.h
@@ -1,6 +1,7 @@
#ifndef SIGN_UTILS_H_
#define SIGN_UTILS_H_
+#include "../jade_assert.h"
#include "process_utils.h"
typedef enum { TXTYPE_SEND_PAYMENT, TXTYPE_SWAP } TxType_t;
@@ -19,31 +20,31 @@ typedef struct _asset_summary {
uint64_t validated_value;
} asset_summary_t;
-bool params_txn_validate(network_t network_id, bool for_liquid, const struct wally_tx* const tx, uint64_t* explicit_fee,
- const char** errmsg);
+WARN_UNUSED_RESULT bool params_txn_validate(network_t network_id, bool for_liquid, const struct wally_tx* const tx,
+ uint64_t* explicit_fee, const char** errmsg);
-bool params_trusted_commitments(
+WARN_UNUSED_RESULT bool params_trusted_commitments(
jade_process_t* process, const CborValue* params, const struct wally_tx* tx, commitment_t** data);
-bool params_additional_info(jade_process_t* process, CborValue* params, const struct wally_tx* tx, TxType_t* txtype,
- bool* is_partial, asset_summary_t** in_sums, size_t* num_in_sums, asset_summary_t** out_sums, size_t* num_out_sums,
- const char** errmsg);
+WARN_UNUSED_RESULT bool params_additional_info(jade_process_t* process, CborValue* params, const struct wally_tx* tx,
+ TxType_t* txtype, bool* is_partial, asset_summary_t** in_sums, size_t* num_in_sums, asset_summary_t** out_sums,
+ size_t* num_out_sums, const char** errmsg);
// Returns true if commitments are present and validated correctly.
// Returns false otherwise, with errmsg set if an error occurred, or
// NULL if no commitment data was present.
-bool params_commitment_data(
+WARN_UNUSED_RESULT bool params_commitment_data(
CborValue* item, commitment_t* commitment, const struct wally_tx_output* const txout, const char** errmsg);
-bool asset_summary_update(
+WARN_UNUSED_RESULT bool asset_summary_update(
asset_summary_t* sums, size_t num_sums, const uint8_t* asset_id, size_t asset_id_len, uint64_t value);
bool asset_summary_validate(asset_summary_t* sums, size_t num_sums);
-bool update_elements_outputs(
+WARN_UNUSED_RESULT bool update_elements_outputs(
const struct wally_tx* tx, commitment_t* commitments, output_info_t* outinfo, const char** errmsg);
-bool validate_elements_outputs(network_t network_id, const struct wally_tx* tx, TxType_t txtype,
+WARN_UNUSED_RESULT bool validate_elements_outputs(network_t network_id, const struct wally_tx* tx, TxType_t txtype,
const output_info_t* const output_info, asset_summary_t* in_sums, size_t num_in_sums, asset_summary_t* out_sums,
size_t num_out_sums, const char** errmsg);
diff --git a/main/qrcode.h b/main/qrcode.h
index dde59c5..7477f20 100644
--- a/main/qrcode.h
+++ b/main/qrcode.h
@@ -43,6 +43,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "jade_assert.h"
+
// QR Code Format Encoding
#define MODE_NUMERIC 0
#define MODE_ALPHANUMERIC 1
@@ -86,7 +88,7 @@ void qrcode_freeIcon(Icon* icon);
// Blockstream added function
// NOTE: only supports v1 and v2 qrcodes atm.
-bool qrcode_toFragmentsIcons(
+WARN_UNUSED_RESULT bool qrcode_toFragmentsIcons(
QRCode* qrcode, uint8_t target_size, bool show_grid, Icon** icons_out, size_t* num_icons_out);
#ifdef __cplusplus
diff --git a/main/qrmode.h b/main/qrmode.h
index 6e7f93a..25da5c3 100644
--- a/main/qrmode.h
+++ b/main/qrmode.h
@@ -7,6 +7,7 @@
#include <cbor.h>
+#include "jade_assert.h"
#include "otpauth.h"
// NOTE: Jade only supports the bip39 English wordlist,
@@ -27,7 +28,7 @@ void display_xpub_qr(void);
void handle_scan_qr(void);
// Display a BC-UR bytes message
-bool display_bcur_bytes_qr(
+WARN_UNUSED_RESULT bool display_bcur_bytes_qr(
const char* message[], size_t message_size, const uint8_t* data, size_t data_len, const char* help_url);
// Display bip85/bip39 encrypted entropy as BC-UR QR.
diff --git a/main/qrscan.h b/main/qrscan.h
index b89aa35..f60d884 100644
--- a/main/qrscan.h
+++ b/main/qrscan.h
@@ -6,6 +6,8 @@
#include <stdbool.h>
#include <stddef.h>
+#include "jade_assert.h"
+
// An extracted QR code string
#define QR_MAX_PAYLOAD_LENGTH 1024
@@ -37,14 +39,15 @@ struct _qr_data_t {
#ifdef CONFIG_DEBUG_MODE
// Function to scan single image - may be useful for testing
-bool scan_qr(const size_t width, const size_t height, const uint8_t* data, const size_t len, qr_data_t* qr_data);
+WARN_UNUSED_RESULT bool scan_qr(
+ const size_t width, const size_t height, const uint8_t* data, const size_t len, qr_data_t* qr_data);
#endif
// Function to scan a qr code with the camera.
// Any scanned/extracted string (which passes any additional validity check)
// is written to the passed qr_data struct, and the function returns true.
// The function returns false if scanning is aborted, and no string is returned.
-bool jade_camera_scan_qr(
+WARN_UNUSED_RESULT bool jade_camera_scan_qr(
qr_data_t* qr_data, const char* text_label, qr_guide_type_t qr_guide_type, const char* help_url);
#endif /* QRSCAN_H_ */
diff --git a/main/rsa.h b/main/rsa.h
index 8c7cda1..fac5789 100644
--- a/main/rsa.h
+++ b/main/rsa.h
@@ -5,6 +5,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "jade_assert.h"
+
#define RSA_KEY_SIZE_VALID(bits) (bits == 1024 || bits == 2048 || bits == 3072 || bits == 4096 || bits == 8192)
#define MAX_RSA_GEN_KEY_LEN 4096
#define RSA_DIGEST_LEN 32 // sha256
@@ -20,10 +22,10 @@ typedef struct {
} rsa_signature_t;
// Function to get bip85-generated rsa key pem
-bool rsa_get_bip85_pubkey_pem(size_t key_bits, size_t index, char* output, size_t output_len);
+WARN_UNUSED_RESULT bool rsa_get_bip85_pubkey_pem(size_t key_bits, size_t index, char* output, size_t output_len);
// Function to get bip85-generated rsa key pem
-bool rsa_bip85_key_sign_digests(size_t key_bits, size_t index, const rsa_signing_digest_t* digests, size_t digests_len,
- rsa_signature_t* signatures, size_t signatures_len);
+WARN_UNUSED_RESULT bool rsa_bip85_key_sign_digests(size_t key_bits, size_t index, const rsa_signing_digest_t* digests,
+ size_t digests_len, rsa_signature_t* signatures, size_t signatures_len);
#endif /* JADE_RSA_H_ */
diff --git a/main/serial.h b/main/serial.h
index bcc5b1c..f503488 100644
--- a/main/serial.h
+++ b/main/serial.h
@@ -5,7 +5,9 @@
#include <freertos/task.h>
#include <stdbool.h>
-bool serial_init(TaskHandle_t* serial_handle);
+#include "jade_assert.h"
+
+WARN_UNUSED_RESULT bool serial_init(TaskHandle_t* serial_handle);
bool serial_enabled(void);
void serial_start(void);
void serial_stop(void);
diff --git a/main/signer.h b/main/signer.h
index 8fb65db..4276043 100644
--- a/main/signer.h
+++ b/main/signer.h
@@ -7,6 +7,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "jade_assert.h"
+
// The maximum number of script signers supported
#define MAX_ALLOWED_SIGNERS 15
@@ -36,7 +38,7 @@ typedef struct {
size_t path_len;
} signer_t;
-bool validate_signers(const signer_t* signers, size_t num_signers, bool accept_string_path,
+WARN_UNUSED_RESULT bool validate_signers(const signer_t* signers, size_t num_signers, bool accept_string_path,
const uint8_t* wallet_fingerprint, size_t wallet_fingerprint_len, size_t* total_num_path_elements);
#endif /* SIGNER_H_ */
\ No newline at end of file
diff --git a/main/storage.h b/main/storage.h
index 8d8adee..538eb7c 100644
--- a/main/storage.h
+++ b/main/storage.h
@@ -7,6 +7,7 @@
#include <nvs.h>
+#include "jade_assert.h"
#include "utils/network.h"
#define BLE_ENABLED 0x1
diff --git a/main/utils/address.h b/main/utils/address.h
index c71ce0e..bcc55df 100644
--- a/main/utils/address.h
+++ b/main/utils/address.h
@@ -5,6 +5,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "../jade_assert.h"
#include "network.h"
#define MAX_ADDRESS_LEN 128
@@ -26,6 +27,6 @@ void elements_script_to_address(const network_t network_id, const uint8_t* scrip
const uint8_t* blinding_key, size_t blinding_key_len, char* output, size_t output_len);
// Attempt to parse an address - return the network and the scriptpubkey
-bool parse_address(const char* address, address_data_t* addr_data);
+WARN_UNUSED_RESULT bool parse_address(const char* address, address_data_t* addr_data);
#endif /* UTILS_ADDRESS_H_ */
diff --git a/main/utils/event.h b/main/utils/event.h
index c25a8e7..b5d5156 100644
--- a/main/utils/event.h
+++ b/main/utils/event.h
@@ -3,6 +3,8 @@
#include <esp_event.h>
+#include "../jade_assert.h"
+
#define ESP_NO_EVENT 0xFF
ESP_EVENT_DECLARE_BASE(JADE_EVENT);
diff --git a/main/utils/psbt.h b/main/utils/psbt.h
index 0234511..ec91809 100644
--- a/main/utils/psbt.h
+++ b/main/utils/psbt.h
@@ -6,6 +6,8 @@
#include <stdint.h>
#include <wally_bip32.h>
+#include "../jade_assert.h"
+
struct wally_psbt;
/* An iterator for keypaths in a PSBT input or output.
@@ -43,7 +45,7 @@ bool key_iter_output_begin_public(const struct wally_psbt* psbt, size_t index, k
bool key_iter_next(key_iter* iter);
// Get the path to the key the iterator current points to
-bool key_iter_get_path(const key_iter* iter, uint32_t* path, size_t path_len, size_t* written);
+WARN_UNUSED_RESULT bool key_iter_get_path(const key_iter* iter, uint32_t* path, size_t path_len, size_t* written);
// Get the number of keys in the keypaths the iterator current points to
size_t key_iter_get_num_keys(const key_iter* iter);
@@ -52,12 +54,14 @@ size_t key_iter_get_num_keys(const key_iter* iter);
bool key_iter_contains_pubkey(const key_iter* iter, const uint8_t* pubkey, size_t pubkey_len);
// Get the public key of the `key_index`th key in the keypath the iterator current points to
-bool key_iter_get_pubkey_at(const key_iter* iter, size_t key_index, uint8_t* pubkey, size_t pubkey_len);
+WARN_UNUSED_RESULT bool key_iter_get_pubkey_at(
+ const key_iter* iter, size_t key_index, uint8_t* pubkey, size_t pubkey_len);
// Get the fingerprint of the `key_index`th key in the keypath the iterator current points to
void key_iter_get_fingerprint_at(const key_iter* iter, size_t key_index, uint8_t* fingerprint, size_t fingerprint_len);
// Get the path to the `key_index`th key in the keypath the iterator current points to
-bool key_iter_get_path_at(const key_iter* iter, size_t key_index, uint32_t* path, size_t path_len, size_t* written);
+WARN_UNUSED_RESULT bool key_iter_get_path_at(
+ const key_iter* iter, size_t key_index, uint32_t* path, size_t path_len, size_t* written);
#endif /* PSBT_H_ */
diff --git a/main/utils/urldecode.h b/main/utils/urldecode.h
index e2460a9..4d87375 100644
--- a/main/utils/urldecode.h
+++ b/main/utils/urldecode.h
@@ -4,7 +4,9 @@
#include <stdbool.h>
#include <stddef.h>
-bool urldecode(const char* src, size_t src_len, char* dest, size_t dest_len);
-bool urlencode(const char* src, size_t src_len, char* dest, size_t dest_len);
+#include "../jade_assert.h"
+
+WARN_UNUSED_RESULT bool urldecode(const char* src, size_t src_len, char* dest, size_t dest_len);
+WARN_UNUSED_RESULT bool urlencode(const char* src, size_t src_len, char* dest, size_t dest_len);
#endif /* UTILS_URLDECODE_H_ */
diff --git a/main/utils/util.h b/main/utils/util.h
index 45818e5..0b09c7f 100644
--- a/main/utils/util.h
+++ b/main/utils/util.h
@@ -5,7 +5,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "jade_assert.h"
+#include "../jade_assert.h"
#ifdef CONFIG_IDF_TARGET_ESP32S3
#include <dsps_mem.h>
@@ -112,10 +112,10 @@ void split_text(
const char* src, size_t len, size_t wordlen, char* output, size_t output_len, size_t* num_words, size_t* written);
// Parse a uint64 from a string. Allows leading zeros but no non-digit chars
-bool parse_uint64(const char* str, size_t str_len, uint64_t* value_out);
+WARN_UNUSED_RESULT bool parse_uint64(const char* str, size_t str_len, uint64_t* value_out);
// As for parse_uint64 but for 32 bit integers
-bool parse_uint32(const char* str, size_t str_len, uint32_t* value_out);
+WARN_UNUSED_RESULT bool parse_uint32(const char* str, size_t str_len, uint32_t* value_out);
// Bip32 path utils
#define BIP32_MAX_CHILD_INDEX 0x7fffffff
@@ -144,6 +144,7 @@ bool is_potential_green_server_path(const uint32_t* path, size_t path_len, uint3
// Helper function to convert a base32 string to binary, returns 0 on failure
size_t base32_to_bin(const char* b32_str, size_t b32_str_len, uint8_t* bin, size_t bin_len);
// Helper function to convert binary data to a base32 string, padding optional
-bool bin_to_base32(const uint8_t* bin, size_t bin_len, char* b32_str, size_t b32_str_len, bool use_padding);
+WARN_UNUSED_RESULT bool bin_to_base32(
+ const uint8_t* bin, size_t bin_len, char* b32_str, size_t b32_str_len, bool use_padding);
#endif /* UTIL_H_ */
diff --git a/main/wallet.h b/main/wallet.h
index b4208d9..a4fc7ac 100644
--- a/main/wallet.h
+++ b/main/wallet.h
@@ -3,6 +3,7 @@
#include <stdbool.h>
+#include "jade_assert.h"
#include "utils/network.h"
#include <wally_bip32.h>
@@ -56,19 +57,20 @@ typedef enum { GREEN, P2PKH, P2WPKH, P2WPKH_P2SH, MULTI_P2WSH, MULTI_P2SH, MULTI
void wallet_init(void);
-bool wallet_bip32_path_as_str(
+WARN_UNUSED_RESULT bool wallet_bip32_path_as_str(
const uint32_t parts[], size_t num_parts, char* output, size_t output_len, bool path_only);
-bool wallet_bip32_path_from_str(const char* pathstr, size_t str_len, uint32_t* path, size_t path_len, size_t* written);
+WARN_UNUSED_RESULT bool wallet_bip32_path_from_str(
+ const char* pathstr, size_t str_len, uint32_t* path, size_t path_len, size_t* written);
-bool wallet_derive_pubkey(const uint8_t* serialised_key, size_t key_len, const uint32_t* path, size_t path_len,
- uint32_t flags, struct ext_key* hdkey);
-bool wallet_derive_from_xpub(
+WARN_UNUSED_RESULT bool wallet_derive_pubkey(const uint8_t* serialised_key, size_t key_len, const uint32_t* path,
+ size_t path_len, uint32_t flags, struct ext_key* hdkey);
+WARN_UNUSED_RESULT bool wallet_derive_from_xpub(
const char* xpub, const uint32_t* path, size_t path_len, uint32_t flags, struct ext_key* hdkey);
size_t script_length_for_variant(script_variant_t variant);
const char* get_script_variant_string(script_variant_t variant);
-bool get_script_variant(const char* variant, size_t variant_len, script_variant_t* output);
-bool get_singlesig_variant_from_script_type(size_t script_type, script_variant_t* variant);
+WARN_UNUSED_RESULT bool get_script_variant(const char* variant, size_t variant_len, script_variant_t* output);
+WARN_UNUSED_RESULT bool get_singlesig_variant_from_script_type(size_t script_type, script_variant_t* variant);
bool is_greenaddress(script_variant_t variant);
bool is_singlesig(script_variant_t variant);
bool is_multisig(script_variant_t variant);
@@ -84,68 +86,74 @@ bool wallet_is_expected_multisig_path(size_t cosigner_index, bool is_change, con
void wallet_build_receive_path(
uint32_t subaccount, uint32_t branch, uint32_t pointer, uint32_t* output_path, size_t output_len, size_t* written);
-bool wallet_build_ga_script_ex(network_t network_id, const struct ext_key* user_key,
+WARN_UNUSED_RESULT bool wallet_build_ga_script_ex(network_t network_id, const struct ext_key* user_key,
const struct ext_key* recovery_hdkey, size_t csv_blocks, const uint32_t* path, size_t path_len, uint8_t* output,
size_t output_len, size_t* written);
-bool wallet_build_ga_script(network_t network_id, const char* xpubrecovery, size_t csv_blocks, const uint32_t* path,
- size_t path_len, uint8_t* output, size_t output_len, size_t* written);
-bool wallet_build_singlesig_script(network_t network_id, script_variant_t script_variant, const struct ext_key* hdkey,
- uint8_t* output, size_t output_len, size_t* written);
-bool wallet_search_for_singlesig_script(network_t network_id, script_variant_t script_variant,
+WARN_UNUSED_RESULT bool wallet_build_ga_script(network_t network_id, const char* xpubrecovery, size_t csv_blocks,
+ const uint32_t* path, size_t path_len, uint8_t* output, size_t output_len, size_t* written);
+WARN_UNUSED_RESULT bool wallet_build_singlesig_script(network_t network_id, script_variant_t script_variant,
+ const struct ext_key* hdkey, uint8_t* output, size_t output_len, size_t* written);
+WARN_UNUSED_RESULT bool wallet_search_for_singlesig_script(network_t network_id, script_variant_t script_variant,
const struct ext_key* search_root, size_t* index, size_t search_depth, const uint8_t* script, size_t script_len);
-bool wallet_build_multisig_script(script_variant_t script_variant, bool sorted, uint8_t threshold,
+WARN_UNUSED_RESULT bool wallet_build_multisig_script(script_variant_t script_variant, bool sorted, uint8_t threshold,
const uint8_t* pubkeys, size_t pubkeys_len, uint8_t* output, size_t output_len, size_t* written);
-bool wallet_search_for_multisig_script(script_variant_t script_variant, bool sorted, uint8_t threshold,
- const struct ext_key* search_roots, size_t search_roots_len, size_t* index, size_t search_depth,
+WARN_UNUSED_RESULT bool wallet_search_for_multisig_script(script_variant_t script_variant, bool sorted,
+ uint8_t threshold, const struct ext_key* search_roots, size_t search_roots_len, size_t* index, size_t search_depth,
const uint8_t* script, size_t script_len);
typedef struct _descriptor_data descriptor_data_t;
-bool wallet_build_descriptor_script(network_t network_id, const char* descriptor_name,
+WARN_UNUSED_RESULT bool wallet_build_descriptor_script(network_t network_id, const char* descriptor_name,
const descriptor_data_t* descriptor, size_t multi_index, size_t index, uint8_t* output, size_t output_len,
size_t* written, const char** errmsg);
-bool wallet_search_for_descriptor_script(network_t network_id, const char* descriptor_name,
+WARN_UNUSED_RESULT bool wallet_search_for_descriptor_script(network_t network_id, const char* descriptor_name,
const descriptor_data_t* descriptor, size_t multi_index, size_t* index, size_t search_depth, const uint8_t* script,
size_t script_len);
void wallet_get_fingerprint(uint8_t* output, size_t output_len);
-bool wallet_get_hdkey(const uint32_t* path, size_t path_len, uint32_t flags, struct ext_key* output);
-bool wallet_get_xpub(network_t network_id, const uint32_t* path, size_t path_len, char** output);
+WARN_UNUSED_RESULT bool wallet_get_hdkey(const uint32_t* path, size_t path_len, uint32_t flags, struct ext_key* output);
+WARN_UNUSED_RESULT bool wallet_get_xpub(network_t network_id, const uint32_t* path, size_t path_len, char** output);
-bool wallet_calculate_gaservice_path(struct ext_key* root_key, uint32_t* gaservice_path, size_t gaservice_path_len);
-bool wallet_serialize_gaservice_path(
+WARN_UNUSED_RESULT bool wallet_calculate_gaservice_path(
+ struct ext_key* root_key, uint32_t* gaservice_path, size_t gaservice_path_len);
+WARN_UNUSED_RESULT bool wallet_serialize_gaservice_path(
uint8_t* serialized, size_t serialized_len, const uint32_t* gaservice_path, size_t gaservice_path_len);
-bool wallet_unserialize_gaservice_path(
+WARN_UNUSED_RESULT bool wallet_unserialize_gaservice_path(
const uint8_t* serialized, size_t serialized_len, uint32_t* gaservice_path, size_t gaservice_path_len);
-bool wallet_get_gaservice_fingerprint(network_t network_id, uint8_t* output, size_t output_len);
-bool wallet_get_gaservice_path(
+WARN_UNUSED_RESULT bool wallet_get_gaservice_fingerprint(network_t network_id, uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool wallet_get_gaservice_path(
const uint32_t* path, size_t path_len, uint32_t* ga_path, size_t ga_path_len, size_t* written);
-bool wallet_get_gaservice_root_key(const struct ext_key* service, bool subaccount_root, struct ext_key* gakey);
+WARN_UNUSED_RESULT bool wallet_get_gaservice_root_key(
+ const struct ext_key* service, bool subaccount_root, struct ext_key* gakey);
-bool wallet_get_message_hash(const uint8_t* bytes, size_t bytes_len, uint8_t* output, size_t output_len);
-bool wallet_sign_message_hash(const uint8_t* signature_hash, size_t signature_hash_len, const uint32_t* path,
- size_t path_len, const uint8_t* ae_host_entropy, size_t ae_host_entropy_len, uint8_t* output, size_t output_len,
- size_t* written);
+WARN_UNUSED_RESULT bool wallet_get_message_hash(
+ const uint8_t* bytes, size_t bytes_len, uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool wallet_sign_message_hash(const uint8_t* signature_hash, size_t signature_hash_len,
+ const uint32_t* path, size_t path_len, const uint8_t* ae_host_entropy, size_t ae_host_entropy_len, uint8_t* output,
+ size_t output_len, size_t* written);
signing_data_t* signing_data_allocate(const size_t num_inputs);
void signing_data_free(void* signing_data);
// Get the signature hash for the "index"-th input of "tx".
-bool wallet_get_tx_input_hash(struct wally_tx* tx, size_t index, signing_data_t* signing_data, const uint8_t* script,
- size_t script_len, const uint8_t* genesis, const size_t genesis_len);
-bool wallet_get_signer_commitment(const uint8_t* signature_hash, size_t signature_hash_len, const uint32_t* path,
- size_t path_len, const uint8_t* commitment, size_t commitment_len, uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool wallet_get_tx_input_hash(struct wally_tx* tx, size_t index, signing_data_t* signing_data,
+ const uint8_t* script, size_t script_len, const uint8_t* genesis, const size_t genesis_len);
+WARN_UNUSED_RESULT bool wallet_get_signer_commitment(const uint8_t* signature_hash, size_t signature_hash_len,
+ const uint32_t* path, size_t path_len, const uint8_t* commitment, size_t commitment_len, uint8_t* output,
+ size_t output_len);
// Sign the signature hash in input_data.
-bool wallet_sign_tx_input_hash(
+WARN_UNUSED_RESULT bool wallet_sign_tx_input_hash(
network_t network_id, input_data_t* input_data, const uint8_t* ae_host_entropy, size_t ae_host_entropy_len);
-bool wallet_hmac_with_master_key(const uint8_t* data, size_t data_len, uint8_t* output, size_t output_len);
-bool wallet_get_public_blinding_key(const uint8_t* master_blinding_key, size_t master_blinding_key_len,
- const uint8_t* script, size_t script_len, uint8_t* output, size_t output_len);
-bool wallet_get_shared_blinding_nonce(const uint8_t* master_blinding_key, size_t master_blinding_key_len,
- const uint8_t* script, size_t script_len, const uint8_t* their_pubkey, size_t their_pubkey_len,
- uint8_t* output_nonce, size_t output_nonce_len, uint8_t* output_pubkey, size_t output_pubkey_len);
-bool wallet_get_blinding_factor(const uint8_t* master_blinding_key, size_t master_blinding_key_len,
+WARN_UNUSED_RESULT bool wallet_hmac_with_master_key(
+ const uint8_t* data, size_t data_len, uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool wallet_get_public_blinding_key(const uint8_t* master_blinding_key,
+ size_t master_blinding_key_len, const uint8_t* script, size_t script_len, uint8_t* output, size_t output_len);
+WARN_UNUSED_RESULT bool wallet_get_shared_blinding_nonce(const uint8_t* master_blinding_key,
+ size_t master_blinding_key_len, const uint8_t* script, size_t script_len, const uint8_t* their_pubkey,
+ size_t their_pubkey_len, uint8_t* output_nonce, size_t output_nonce_len, uint8_t* output_pubkey,
+ size_t output_pubkey_len);
+WARN_UNUSED_RESULT bool wallet_get_blinding_factor(const uint8_t* master_blinding_key, size_t master_blinding_key_len,
const uint8_t* hash_prevouts, size_t hash_len, size_t output_index, BlindingFactorType_t type, uint8_t* output,
size_t output_len);
Why this scored 36/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.