Struan Clark hai 1 ano
pai
achega
cca780822c
Modificáronse 5 ficheiros con 22 adicións e 22 borrados
  1. 1 1
      flipbip.c
  2. 4 4
      flipbip_coins.c
  3. 10 10
      flipbip_coins.h
  4. 2 2
      scenes/flipbip_scene_menu.c
  5. 5 5
      views/flipbip_scene_1.c

+ 1 - 1
flipbip.c

@@ -131,7 +131,7 @@ FlipBip* flipbip_app_alloc() {
     app->passphrase = FlipBipPassphraseOff;
 
     // Main menu
-    app->coin_type = FlipBipCoinBTC0; // 0 (BTC)
+    app->coin_type = CoinTypeBTC0; // 0 (BTC)
     app->overwrite_saved_seed = 0;
     app->import_from_mnemonic = 0;
     app->mnemonic_menu_text = MNEMONIC_MENU_DEFAULT;

+ 4 - 4
flipbip_coins.c

@@ -2,10 +2,10 @@
 
 // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
 const uint32_t COIN_INFO_ARRAY[NUM_COINS][COIN_INFO_SIZE] = {
-    {0, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0},
-    {60, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinETH60},
-    {3, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0},
-    {133, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, FlipBipCoinZEC133},
+    {0, 0x0488ade4, 0x0488b21e, 0x00, 0x80, CoinTypeBTC0},
+    {60, 0x0488ade4, 0x0488b21e, 0x00, 0x80, CoinTypeETH60},
+    {3, 0x02fac398, 0x02facafd, 0x1e, 0x9e, CoinTypeBTC0},
+    {133, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, CoinTypeZEC133},
 };
 
 // coin_name, derivation_path, coin name

+ 10 - 10
flipbip_coins.h

@@ -3,6 +3,13 @@
 
 #define NUM_COINS 4
 
+typedef enum {
+    CoinTypeBTC0,
+    CoinTypeETH60,
+    CoinTypeDOGE3,
+    CoinTypeZEC133,
+} CoinType;
+
 #define COIN_INFO_SIZE       6
 #define COIN_INFO_BIP44_COIN 0
 #define COIN_INFO_XPRV_VERS  1
@@ -11,20 +18,13 @@
 #define COIN_INFO_WIF_VERS   4
 #define COIN_INFO_ADDR_FMT   5
 
+// bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
+extern const uint32_t COIN_INFO_ARRAY[NUM_COINS][COIN_INFO_SIZE];
+
 #define COIN_TEXT_SIZE  3
 #define COIN_TEXT_LABEL 0
 #define COIN_TEXT_DERIV 1
 #define COIN_TEXT_NAME  2
 
-typedef enum {
-    FlipBipCoinBTC0,
-    FlipBipCoinETH60,
-    FlipBipCoinDOGE3,
-    FlipBipCoinZEC133,
-} FlipBipCoin;
-
-// bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
-extern const uint32_t COIN_INFO_ARRAY[NUM_COINS][COIN_INFO_SIZE];
-
 // coin_name, derivation_path
 extern const char* COIN_TEXT_ARRAY[NUM_COINS][COIN_TEXT_SIZE];

+ 2 - 2
scenes/flipbip_scene_menu.c

@@ -75,9 +75,9 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
         if(event.event < SubmenuIndexScene1New) {
             app->overwrite_saved_seed = 0;
             app->import_from_mnemonic = 0;
-            app->coin_type = event.event; // FlipBipCoin
+            app->coin_type = event.event; // CoinType
             scene_manager_set_scene_state(
-                app->scene_manager, FlipBipSceneMenu, event.event); // FlipBipCoin
+                app->scene_manager, FlipBipSceneMenu, event.event); // CoinType
             scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
             return true;
         } else if(event.event == SubmenuIndexScene1New) {

+ 5 - 5
views/flipbip_scene_1.c

@@ -121,7 +121,7 @@ static void flipbip_scene_1_init_address(
     hdnode_fill_public_key(s_addr_node);
 
     if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] ==
-       FlipBipCoinBTC0) { // BTC / DOGE style address
+       CoinTypeBTC0) { // BTC / DOGE style address
         // BTC / DOGE style address
         ecdsa_get_address(
             s_addr_node->public_key,
@@ -133,7 +133,7 @@ static void flipbip_scene_1_init_address(
         strcpy(addr_text, buf);
         //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen);
 
-    } else if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == FlipBipCoinETH60) { // ETH
+    } else if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == CoinTypeETH60) { // ETH
         // ETH style address
         hdnode_get_ethereum_pubkeyhash(s_addr_node, (uint8_t*)buf);
         addr_text[0] = '0';
@@ -141,7 +141,7 @@ static void flipbip_scene_1_init_address(
         // Convert the hash to a hex string
         flipbip_btox((uint8_t*)buf, 20, addr_text + 2);
 
-    } else if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == FlipBipCoinZEC133) { // ZEC
+    } else if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == CoinTypeZEC133) { // ZEC
         ecdsa_get_address(
             s_addr_node->public_key,
             COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_VERS],
@@ -294,7 +294,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
         flipbip_scene_1_draw_generic(model->xpub_extended, 20, false);
     } else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) {
         size_t line_len = 12;
-        if(model->coin_type == FlipBipCoinETH60) {
+        if(model->coin_type == CoinTypeETH60) {
             line_len = 14;
         }
         flipbip_scene_1_draw_generic(
@@ -585,7 +585,7 @@ void flipbip_scene_1_exit(void* context) {
         {
             model->page = PAGE_LOADING;
             model->strength = FlipBipStrength256;
-            model->coin_type = FlipBipCoinBTC0;
+            model->coin_type = CoinTypeBTC0;
             memzero(model->seed, 64);
             // if mnemonic_only is true, then we don't need to free the data here
             if(!model->mnemonic_only) {