-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return to Exchange after a swap transaction
- Loading branch information
1 parent
c1de5cf
commit 675b525
Showing
9 changed files
with
82 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,80 @@ | ||
#pragma once | ||
|
||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
/* This file is the shared API between Exchange and the apps started in Library mode for Exchange | ||
* | ||
* DO NOT MODIFY THIS FILE IN APPLICATIONS OTHER THAN EXCHANGE | ||
* On modification in Exchange, forward the changes to all applications supporting Exchange | ||
*/ | ||
|
||
#include "stdbool.h" | ||
#include "stdint.h" | ||
|
||
#define RUN_APPLICATION 1 | ||
|
||
#define SIGN_TRANSACTION 2 | ||
|
||
#define CHECK_ADDRESS 3 | ||
|
||
#define GET_PRINTABLE_AMOUNT 4 | ||
|
||
/* | ||
* Amounts are stored as bytes, with a max size of 16 (see protobuf | ||
* specifications). Max 16B integer is 340282366920938463463374607431768211455 | ||
* in decimal, which is a 32-long char string. | ||
* The printable amount also contains spaces, the ticker symbol (with variable | ||
* size, up to 12 in Ethereum for instance) and a terminating null byte, so 50 | ||
* bytes total should be a fair maximum. | ||
*/ | ||
#define MAX_PRINTABLE_AMOUNT_SIZE 50 | ||
|
||
// structure that should be send to specific coin application to get address | ||
typedef struct check_address_parameters_s { | ||
// IN | ||
unsigned char* coin_configuration; | ||
unsigned char coin_configuration_length; | ||
uint8_t *coin_configuration; | ||
uint8_t coin_configuration_length; | ||
// serialized path, segwit, version prefix, hash used, dictionary etc. | ||
// fields and serialization format depends on spesific coin app | ||
unsigned char* address_parameters; | ||
unsigned char address_parameters_length; | ||
char* address_to_check; | ||
char* extra_id_to_check; | ||
uint8_t *address_parameters; | ||
uint8_t address_parameters_length; | ||
char *address_to_check; | ||
char *extra_id_to_check; | ||
// OUT | ||
int result; | ||
} check_address_parameters_t; | ||
|
||
// structure that should be send to specific coin application to get printable amount | ||
typedef struct get_printable_amount_parameters_s { | ||
// IN | ||
unsigned char* coin_configuration; | ||
unsigned char coin_configuration_length; | ||
unsigned char* amount; | ||
unsigned char amount_length; | ||
uint8_t *coin_configuration; | ||
uint8_t coin_configuration_length; | ||
uint8_t *amount; | ||
uint8_t amount_length; | ||
bool is_fee; | ||
// OUT | ||
char printable_amount[30]; | ||
// int result; | ||
char printable_amount[MAX_PRINTABLE_AMOUNT_SIZE]; | ||
} get_printable_amount_parameters_t; | ||
|
||
typedef struct create_transaction_parameters_s { | ||
unsigned char* coin_configuration; | ||
unsigned char coin_configuration_length; | ||
unsigned char* amount; | ||
unsigned char amount_length; | ||
unsigned char* fee_amount; | ||
unsigned char fee_amount_length; | ||
char* destination_address; | ||
char* destination_address_extra_id; | ||
// IN | ||
uint8_t *coin_configuration; | ||
uint8_t coin_configuration_length; | ||
uint8_t *amount; | ||
uint8_t amount_length; | ||
uint8_t *fee_amount; | ||
uint8_t fee_amount_length; | ||
char *destination_address; | ||
char *destination_address_extra_id; | ||
// OUT | ||
uint8_t result; | ||
} create_transaction_parameters_t; | ||
|
||
bool swap_str_to_u64(const uint8_t* src, size_t length, uint64_t* result); | ||
typedef struct libargs_s { | ||
unsigned int id; | ||
unsigned int command; | ||
unsigned int unused; | ||
union { | ||
check_address_parameters_t *check_address; | ||
create_transaction_parameters_t *create_transaction; | ||
get_printable_amount_parameters_t *get_printable_amount; | ||
}; | ||
} libargs_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
bool swap_str_to_u64(const uint8_t* src, size_t length, uint64_t* result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters