Skip to content

Commit

Permalink
Merge pull request #19 from wh00hw/main
Browse files Browse the repository at this point in the history
add ZEC t-address
  • Loading branch information
xtruan authored Aug 9, 2023
2 parents eb9f6f4 + 4e7ebfd commit 114d0e0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions flipbip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -82,6 +83,7 @@ typedef enum {
FlipBipCoinBTC0,
FlipBipCoinETH60,
FlipBipCoinDOGE3,
FlipBipCoinZEC133,
} FlipBipCoin;

typedef enum {
Expand Down
15 changes: 15 additions & 0 deletions scenes/flipbip_scene_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum SubmenuIndex {
SubmenuIndexScene1BTC = 10,
SubmenuIndexScene1ETH,
SubmenuIndexScene1DOGE,
SubmenuIndexScene1ZEC,
SubmenuIndexScene1New,
SubmenuIndexScene1Import,
SubmenuIndexSettings,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 13 additions & 4 deletions views/flipbip_scene_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 114d0e0

Please sign in to comment.