diff --git a/src/address.c b/src/address.c index 3883f92..f61a5cb 100644 --- a/src/address.c +++ b/src/address.c @@ -88,8 +88,10 @@ bool address_from_pubkey(const uint8_t public_key[static 64], // For schnorr, compressed public key we care about is the X coordinate // For ecdsa, compress public key is 1 byte (y-coord: 0x02 if even, 0x03 if odd) then X // coordinate - size_t compressed_pub_size = - compress_public_key(public_key, address_type, compressed_public_key, sizeof(compressed_public_key)); + size_t compressed_pub_size = compress_public_key(public_key, + address_type, + compressed_public_key, + sizeof(compressed_public_key)); if (compressed_pub_size == 0) { return false; diff --git a/src/constants.h b/src/constants.h index 1189a82..650f993 100644 --- a/src/constants.h +++ b/src/constants.h @@ -67,5 +67,5 @@ #define MESSAGE_SIGNING_KEY "PersonalMessageSigningHash" -#define MAX_OUTPUT_COUNT 2 +#define MAX_OUTPUT_COUNT 2 #define SCRIPT_PUBLIC_KEY_BUFFER_LEN 40 diff --git a/src/crypto.c b/src/crypto.c index 9a41be7..1638126 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -93,9 +93,9 @@ int crypto_sign_transaction(void) { } if (!calc_sighash(&G_context.tx_info.transaction, - txin, - public_key.W + 1, - G_context.tx_info.sighash)) { + txin, + public_key.W + 1, + G_context.tx_info.sighash)) { return -1; } diff --git a/src/sighash.c b/src/sighash.c index 87034c6..4670d10 100644 --- a/src/sighash.c +++ b/src/sighash.c @@ -143,9 +143,7 @@ static bool calc_outputs_hash(transaction_t* tx, uint8_t* out_hash, size_t out_l } memset(inner_buffer, 0, sizeof(inner_buffer)); - if (!hash_update(&inner_hash_writer, - inner_buffer, - 2)) { + if (!hash_update(&inner_hash_writer, inner_buffer, 2)) { // Write the output script version, assume 0 return false; } diff --git a/src/transaction/types.h b/src/transaction/types.h index 7b89211..730793f 100644 --- a/src/transaction/types.h +++ b/src/transaction/types.h @@ -77,7 +77,8 @@ typedef struct { typedef struct { uint64_t value; - uint8_t script_public_key[SCRIPT_PUBLIC_KEY_BUFFER_LEN]; // In hex: 20 + public_key_hex + ac (34/35 bytes total) + uint8_t script_public_key[SCRIPT_PUBLIC_KEY_BUFFER_LEN]; // In hex: 20 + public_key_hex + ac + // (34/35 bytes total) } transaction_output_t; typedef struct { diff --git a/src/transaction/utils.c b/src/transaction/utils.c index 4dca6f0..9215b8a 100644 --- a/src/transaction/utils.c +++ b/src/transaction/utils.c @@ -38,7 +38,10 @@ bool transaction_utils_check_encoding(const uint8_t* memo, uint64_t memo_len) { return true; } -bool script_public_key_to_address(uint8_t* out_address, size_t out_len, uint8_t* in_script_public_key, size_t script_len) { +bool script_public_key_to_address(uint8_t* out_address, + size_t out_len, + uint8_t* in_script_public_key, + size_t script_len) { uint8_t public_key[64] = {0}; // script public keys are always at least 32 bytes. We'll check this again @@ -46,7 +49,7 @@ bool script_public_key_to_address(uint8_t* out_address, size_t out_len, uint8_t* if (script_len < 32) { return false; } - + // public script keys begin with the length, followed by the amount of data size_t first_byte = (size_t) in_script_public_key[0]; address_type_e type = SCHNORR; diff --git a/src/transaction/utils.h b/src/transaction/utils.h index 3cf88df..436129b 100644 --- a/src/transaction/utils.h +++ b/src/transaction/utils.h @@ -51,7 +51,10 @@ bool transaction_utils_check_encoding(const uint8_t* memo, uint64_t memo_len); * Pointer to the buffer to read script_public_key from * @param[in] script_len length of script output buffer */ -void script_public_key_to_address(uint8_t* out_address, size_t out_len, uint8_t* in_script_public_key, size_t script_len); +void script_public_key_to_address(uint8_t* out_address, + size_t out_len, + uint8_t* in_script_public_key, + size_t script_len); /** * Calculate the fees by checking the difference between inputs and outputs