Struan Clark 1 год назад
Родитель
Сommit
7cafd8805b
3 измененных файлов с 18 добавлено и 25 удалено
  1. 6 6
      flipbip_coins.c
  2. 6 5
      flipbip_coins.h
  3. 6 14
      views/flipbip_scene_1.c

+ 6 - 6
flipbip_coins.c

@@ -5,12 +5,12 @@ const uint32_t COIN_INFO_ARRAY[NUM_COINS][COIN_INFO_SIZE] = {
     {0, 0x0488ade4, 0x0488b21e, 0x00, 0x80, CoinTypeBTC0},
     {0, 0x0488ade4, 0x0488b21e, 0x00, 0x80, CoinTypeBTC0},
     {60, 0x0488ade4, 0x0488b21e, 0x00, 0x80, CoinTypeETH60},
     {60, 0x0488ade4, 0x0488b21e, 0x00, 0x80, CoinTypeETH60},
     {3, 0x02fac398, 0x02facafd, 0x1e, 0x9e, CoinTypeBTC0},
     {3, 0x02fac398, 0x02facafd, 0x1e, 0x9e, CoinTypeBTC0},
-    {133, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, CoinTypeZEC133},
+    {133, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, CoinTypeBTC0},
 };
 };
 
 
-// coin_label, derivation_path, coin name
+// coin_label, derivation_path, coin_name, static_prefix
 const char* COIN_TEXT_ARRAY[NUM_COINS][COIN_TEXT_SIZE] = {
 const char* COIN_TEXT_ARRAY[NUM_COINS][COIN_TEXT_SIZE] = {
-    {"BTC", "m/44'/0'/0'/0", "bitcoin:"},
-    {"ETH", "m/44'/60'/0'/0", "ethereum:"},
-    {"DOGE", "m/44'/3'/0'/0", "dogecoin:"},
-    {"ZEC", "m/44'/133'/0'/0", "zcash:"}};
+    {"BTC", "m/44'/0'/0'/0", "bitcoin:", "_"},
+    {"ETH", "m/44'/60'/0'/0", "ethereum:", "_"},
+    {"DOGE", "m/44'/3'/0'/0", "dogecoin:", "_"},
+    {"ZEC", "m/44'/133'/0'/0", "zcash:", "t"}};

+ 6 - 5
flipbip_coins.h

@@ -21,10 +21,11 @@ typedef enum {
 // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
 // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
 extern const uint32_t COIN_INFO_ARRAY[NUM_COINS][COIN_INFO_SIZE];
 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
+#define COIN_TEXT_SIZE   4
+#define COIN_TEXT_LABEL  0
+#define COIN_TEXT_DERIV  1
+#define COIN_TEXT_NAME   2
+#define COIN_TEXT_PREFIX 3
 
 
-// coin_label, derivation_path, coin name
+// coin_label, derivation_path, coin_name, static_prefix
 extern const char* COIN_TEXT_ARRAY[NUM_COINS][COIN_TEXT_SIZE];
 extern const char* COIN_TEXT_ARRAY[NUM_COINS][COIN_TEXT_SIZE];

+ 6 - 14
views/flipbip_scene_1.c

@@ -120,8 +120,7 @@ static void flipbip_scene_1_init_address(
     hdnode_private_ckd(s_addr_node, addr_index);
     hdnode_private_ckd(s_addr_node, addr_index);
     hdnode_fill_public_key(s_addr_node);
     hdnode_fill_public_key(s_addr_node);
 
 
-    if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] ==
-       CoinTypeBTC0) { // BTC / DOGE style address
+    if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == CoinTypeBTC0) {
         // BTC / DOGE style address
         // BTC / DOGE style address
         ecdsa_get_address(
         ecdsa_get_address(
             s_addr_node->public_key,
             s_addr_node->public_key,
@@ -130,27 +129,20 @@ static void flipbip_scene_1_init_address(
             HASHER_SHA2D,
             HASHER_SHA2D,
             buf,
             buf,
             buflen);
             buflen);
+        // If prefix is set (not '_') then override beginning of addr_text
+        if(COIN_TEXT_ARRAY[coin_type][COIN_TEXT_PREFIX][0] != '_') {
+            addr_text[0] = COIN_TEXT_ARRAY[coin_type][COIN_TEXT_PREFIX][0];
+        }
         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);
 
 
-    } else if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == CoinTypeETH60) { // ETH
+    } else if(COIN_INFO_ARRAY[coin_type][COIN_INFO_ADDR_FMT] == CoinTypeETH60) {
         // ETH style address
         // ETH style address
         hdnode_get_ethereum_pubkeyhash(s_addr_node, (uint8_t*)buf);
         hdnode_get_ethereum_pubkeyhash(s_addr_node, (uint8_t*)buf);
         addr_text[0] = '0';
         addr_text[0] = '0';
         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_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],
-            HASHER_SHA2_RIPEMD,
-            HASHER_SHA2D,
-            buf,
-            buflen);
-        addr_text[0] = 't';
-        strcpy(addr_text, buf);
     }
     }
 
 
     // Clear the address node
     // Clear the address node