Просмотр исходного кода

Merge pull request #19 from wh00hw/main

add ZEC t-address
Struan 2 лет назад
Родитель
Сommit
114d0e0680
4 измененных файлов с 31 добавлено и 4 удалено
  1. 1 0
      README.md
  2. 2 0
      flipbip.h
  3. 15 0
      scenes/flipbip_scene_menu.c
  4. 13 4
      views/flipbip_scene_1.c

+ 1 - 0
README.md

@@ -42,6 +42,7 @@ The application will be compiled and copied onto your device
   - Generation of offline `m/44'/0'/0'/0` BTC wallet
   - Generation of offline `m/44'/0'/0'/0` BTC wallet
   - Generation of offline `m/44'/60'/0'/0` ETH wallet (coded from the $SPORK Castle of ETHDenver 2023!)
   - Generation of offline `m/44'/60'/0'/0` ETH wallet (coded from the $SPORK Castle of ETHDenver 2023!)
   - Generation of offline `m/44'/3'/0'/0` DOGE wallet
   - Generation of offline `m/44'/3'/0'/0` DOGE wallet
+  - Generation of offline `m/44'/133'/0'/0` ZEC transparent address wallet
   - Similar features to: https://iancoleman.io/bip39/
   - Similar features to: https://iancoleman.io/bip39/
 - Saving wallets to SD card
 - Saving wallets to SD card
   - Wallets are saved to SD card upon creation in `apps_data/flipbip`
   - Wallets are saved to SD card upon creation in `apps_data/flipbip`

+ 2 - 0
flipbip.h

@@ -20,6 +20,7 @@
 #define COIN_BTC 0
 #define COIN_BTC 0
 #define COIN_DOGE 3
 #define COIN_DOGE 3
 #define COIN_ETH 60
 #define COIN_ETH 60
+#define COIN_ZEC 133
 
 
 #define TEXT_BUFFER_SIZE 256
 #define TEXT_BUFFER_SIZE 256
 
 
@@ -82,6 +83,7 @@ typedef enum {
     FlipBipCoinBTC0,
     FlipBipCoinBTC0,
     FlipBipCoinETH60,
     FlipBipCoinETH60,
     FlipBipCoinDOGE3,
     FlipBipCoinDOGE3,
+    FlipBipCoinZEC133,
 } FlipBipCoin;
 } FlipBipCoin;
 
 
 typedef enum {
 typedef enum {

+ 15 - 0
scenes/flipbip_scene_menu.c

@@ -5,6 +5,7 @@ enum SubmenuIndex {
     SubmenuIndexScene1BTC = 10,
     SubmenuIndexScene1BTC = 10,
     SubmenuIndexScene1ETH,
     SubmenuIndexScene1ETH,
     SubmenuIndexScene1DOGE,
     SubmenuIndexScene1DOGE,
+    SubmenuIndexScene1ZEC,
     SubmenuIndexScene1New,
     SubmenuIndexScene1New,
     SubmenuIndexScene1Import,
     SubmenuIndexScene1Import,
     SubmenuIndexSettings,
     SubmenuIndexSettings,
@@ -38,6 +39,12 @@ void flipbip_scene_menu_on_enter(void* context) {
             SubmenuIndexScene1DOGE,
             SubmenuIndexScene1DOGE,
             flipbip_scene_menu_submenu_callback,
             flipbip_scene_menu_submenu_callback,
             app);
             app);
+        submenu_add_item(
+            app->submenu,
+            "View ZEC (t-addr) wallet",
+            SubmenuIndexScene1ZEC,
+            flipbip_scene_menu_submenu_callback,
+            app);
         submenu_add_item(
         submenu_add_item(
             app->submenu,
             app->submenu,
             "Regenerate wallet",
             "Regenerate wallet",
@@ -101,6 +108,14 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
                 app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1DOGE);
                 app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1DOGE);
             scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
             scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
             return true;
             return true;
+        } else if(event.event == SubmenuIndexScene1ZEC) {
+            app->overwrite_saved_seed = 0;
+            app->import_from_mnemonic = 0;
+            app->bip44_coin = FlipBipCoinZEC133;
+            scene_manager_set_scene_state(
+                app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1ZEC);
+            scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
+            return true;
         } else if(event.event == SubmenuIndexScene1New) {
         } else if(event.event == SubmenuIndexScene1New) {
             app->overwrite_saved_seed = 1;
             app->overwrite_saved_seed = 1;
             app->import_from_mnemonic = 0;
             app->import_from_mnemonic = 0;

+ 13 - 4
views/flipbip_scene_1.c

@@ -55,16 +55,19 @@ const char* TEXT_INFO = "-Scroll pages with up/down-"
 #define TEXT_QRFILE_EXT ".qrcode" // 7 chars + 1 null
 #define TEXT_QRFILE_EXT ".qrcode" // 7 chars + 1 null
 
 
 // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
 // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
-const uint32_t COIN_INFO_ARRAY[3][6] = {
+const uint32_t COIN_INFO_ARRAY[4][6] = {
     {COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0},
     {COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0},
     {COIN_ETH, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinETH60},
     {COIN_ETH, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinETH60},
-    {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0}};
+    {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0},
+    {COIN_ZEC, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, FlipBipCoinZEC133},
+};
 
 
 // coin_name, derivation_path
 // coin_name, derivation_path
-const char* COIN_TEXT_ARRAY[3][3] = {
+const char* COIN_TEXT_ARRAY[4][3] = {
     {"BTC", "m/44'/0'/0'/0", "bitcoin:"},
     {"BTC", "m/44'/0'/0'/0", "bitcoin:"},
     {"ETH", "m/44'/60'/0'/0", "ethereum:"},
     {"ETH", "m/44'/60'/0'/0", "ethereum:"},
-    {"DOGE", "m/44'/3'/0'/0", "dogecoin:"}};
+    {"DOGE", "m/44'/3'/0'/0", "dogecoin:"},
+    {"ZEC", "m/44'/133'/0'/0", "zcash:"}};
 
 
 struct FlipBipScene1 {
 struct FlipBipScene1 {
     View* view;
     View* view;
@@ -146,6 +149,7 @@ static void flipbip_scene_1_init_address(
         // BTC / DOGE style address
         // BTC / DOGE style address
         ecdsa_get_address(
         ecdsa_get_address(
             s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen);
             s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen);
+        
         strcpy(addr_text, buf);
         strcpy(addr_text, buf);
 
 
         //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen);
         //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen);
@@ -157,6 +161,11 @@ static void flipbip_scene_1_init_address(
         addr_text[1] = 'x';
         addr_text[1] = 'x';
         // Convert the hash to a hex string
         // Convert the hash to a hex string
         flipbip_btox((uint8_t*)buf, 20, addr_text + 2);
         flipbip_btox((uint8_t*)buf, 20, addr_text + 2);
+    } else if(coin_info[5] == FlipBipCoinZEC133) { // ETH
+        ecdsa_get_address(
+            s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen);
+        addr_text[0] = 't';
+        strcpy(addr_text, buf);
     }
     }
 
 
     // Clear the address node
     // Clear the address node