Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the version of an app a coin parameter #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/btchip_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define MAX_OUTPUT_TO_CHECK 200
#define MAX_COIN_ID 13
#define MAX_SHORT_COIN_ID 5
#define MAX_APP_VERSION_LEN 6

#define MAGIC_TRUSTED_INPUT 0x32
#define MAGIC_DEV_KEY 0x01
Expand Down Expand Up @@ -164,6 +165,8 @@ struct btchip_context_s {
unsigned char coinIdLength;
/** Current short Coin ID length */
unsigned char shortCoinIdLength;
/** Current coin app version */
unsigned char app_version[MAX_APP_VERSION_LEN];

/** Non protected transaction context */

Expand Down Expand Up @@ -280,6 +283,10 @@ typedef struct btchip_altcoin_config_s {
const char* coinid; // used coind id for message signature prefix
const char* name; // for ux displays
const char* name_short; // for unit in ux displays
const char* app_version; // for app version display in "about" menu
unsigned char app_major_version; // for get_firmware API call
unsigned char app_minor_version; // for get_firmware API call
unsigned char app_patch_version; // for get_firmware API call
const char* native_segwit_prefix; // null if no segwit prefix
unsigned int forkid;
btchip_coin_kind_t kind;
Expand Down
6 changes: 3 additions & 3 deletions src/btchip_apdu_get_firmware_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@

void get_firmware_version(unsigned char *buffer) {
buffer[0] = ARCH_ID;
buffer[1] = LEDGER_MAJOR_VERSION;
buffer[2] = LEDGER_MINOR_VERSION;
buffer[3] = LEDGER_PATCH_VERSION;
buffer[1] = G_coin_config->app_major_version;
buffer[2] = G_coin_config->app_minor_version;
buffer[3] = G_coin_config->app_patch_version;
buffer[4] = 1;
buffer[5] = TCS_LOADER_PATCH_VERSION;
}
Expand Down
4 changes: 3 additions & 1 deletion src/btchip_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ void btchip_context_init() {
strlen(PIC(G_coin_config->name_short));
os_memmove(btchip_context_D.shortCoinId, PIC(G_coin_config->name_short),
btchip_context_D.shortCoinIdLength);

os_memmove(btchip_context_D.app_version, PIC(G_coin_config->app_version),
strlen(PIC(G_coin_config->app_version)));

SB_CHECK(N_btchip.bkp.config.operationMode);
}
if (!N_btchip.storageInitialized) {
Expand Down
12 changes: 11 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ unsigned int ui_idle_blue_button(unsigned int button_mask,
const ux_menu_entry_t menu_main[];

const ux_menu_entry_t menu_about[] = {
{NULL, NULL, 0, NULL, "Version", APPVERSION, 0, 0},
{NULL, NULL, 0, NULL, "Version", btchip_context_D.app_version, 0, 0},
{menu_main, NULL, 1, &C_nanos_icon_back, "Back", NULL, 61, 40},
UX_MENU_END};

Expand Down Expand Up @@ -2462,6 +2462,10 @@ btchip_altcoin_config_t const C_coin_config = {
.coinid = COIN_COINID,
.name = COIN_COINID_NAME,
.name_short = COIN_COINID_SHORT,
.app_version = APPVERSION,
.app_major_version = LEDGER_MAJOR_VERSION,
.app_minor_version = LEDGER_MINOR_VERSION,
.app_patch_version = LEDGER_PATCH_VERSION,
#ifdef COIN_NATIVE_SEGWIT_PREFIX
.native_segwit_prefix = COIN_NATIVE_SEGWIT_PREFIX,
#endif // COIN_NATIVE_SEGWIT_PREFIX
Expand All @@ -2485,6 +2489,8 @@ __attribute__((section(".boot"))) int main(int arg0) {
strcpy(name, COIN_COINID_NAME);
unsigned char name_short[sizeof(COIN_COINID_SHORT)];
strcpy(name_short, COIN_COINID_SHORT);
unsigned char app_version[sizeof(APPVERSION)];
strcpy(app_version, APPVERSION);
#ifdef COIN_NATIVE_SEGWIT_PREFIX
unsigned char native_segwit_prefix[sizeof(COIN_NATIVE_SEGWIT_PREFIX)];
strcpy(native_segwit_prefix, COIN_NATIVE_SEGWIT_PREFIX);
Expand All @@ -2494,6 +2500,10 @@ __attribute__((section(".boot"))) int main(int arg0) {
coin_config.coinid = coinid;
coin_config.name = name;
coin_config.name_short = name_short;
coin_config.app_version = app_version;
coin_config.app_major_version = LEDGER_MAJOR_VERSION;
coin_config.app_minor_version = LEDGER_MINOR_VERSION;
coin_config.app_patch_version = LEDGER_PATCH_VERSION;
#ifdef COIN_NATIVE_SEGWIT_PREFIX
coin_config.native_segwit_prefix = native_segwit_prefix;
#endif // #ifdef COIN_NATIVE_SEGWIT_PREFIX
Expand Down