From 4bca4c8bc98a6cfe31f2acf794a0c22a7ec0876f Mon Sep 17 00:00:00 2001 From: wh00hw Date: Tue, 8 Aug 2023 14:35:37 +0200 Subject: [PATCH 1/2] add ZEC t-address --- flipbip.h | 2 ++ scenes/flipbip_scene_menu.c | 15 +++++++++++++++ views/flipbip_scene_1.c | 17 +++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/flipbip.h b/flipbip.h index 9df002aaac1..ea1f7d441b0 100644 --- a/flipbip.h +++ b/flipbip.h @@ -20,6 +20,7 @@ #define COIN_BTC 0 #define COIN_DOGE 3 #define COIN_ETH 60 +#define COIN_ZEC 133 #define TEXT_BUFFER_SIZE 256 @@ -82,6 +83,7 @@ typedef enum { FlipBipCoinBTC0, FlipBipCoinETH60, FlipBipCoinDOGE3, + FlipBipCoinZEC133, } FlipBipCoin; typedef enum { diff --git a/scenes/flipbip_scene_menu.c b/scenes/flipbip_scene_menu.c index 04525909d26..0a4bf18c93b 100644 --- a/scenes/flipbip_scene_menu.c +++ b/scenes/flipbip_scene_menu.c @@ -5,6 +5,7 @@ enum SubmenuIndex { SubmenuIndexScene1BTC = 10, SubmenuIndexScene1ETH, SubmenuIndexScene1DOGE, + SubmenuIndexScene1ZEC, SubmenuIndexScene1New, SubmenuIndexScene1Import, SubmenuIndexSettings, @@ -38,6 +39,12 @@ void flipbip_scene_menu_on_enter(void* context) { SubmenuIndexScene1DOGE, flipbip_scene_menu_submenu_callback, app); + submenu_add_item( + app->submenu, + "View ZEC (t-addr) wallet", + SubmenuIndexScene1ZEC, + flipbip_scene_menu_submenu_callback, + app); submenu_add_item( app->submenu, "Regenerate wallet", @@ -101,6 +108,14 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) { app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1DOGE); scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); 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) { app->overwrite_saved_seed = 1; app->import_from_mnemonic = 0; diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index b7403d01851..142736515a9 100644 --- a/views/flipbip_scene_1.c +++ b/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 // 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_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 -const char* COIN_TEXT_ARRAY[3][3] = { +const char* COIN_TEXT_ARRAY[4][3] = { {"BTC", "m/44'/0'/0'/0", "bitcoin:"}, {"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 { View* view; @@ -146,6 +149,7 @@ static void flipbip_scene_1_init_address( // BTC / DOGE style address ecdsa_get_address( s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen); + strcpy(addr_text, buf); //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'; // Convert the hash to a hex string 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 From 4e7ebfde02e5c6709dbafbd324c25508b8778e37 Mon Sep 17 00:00:00 2001 From: wh00hw Date: Tue, 8 Aug 2023 14:48:46 +0200 Subject: [PATCH 2/2] update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 37aaf3c983f..4aaa6d19d80 100644 --- a/README.md +++ b/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'/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'/133'/0'/0` ZEC transparent address wallet - Similar features to: https://iancoleman.io/bip39/ - Saving wallets to SD card - Wallets are saved to SD card upon creation in `apps_data/flipbip`