|
|
@@ -3,12 +3,9 @@
|
|
|
#include <furi_hal.h>
|
|
|
#include <input/input.h>
|
|
|
#include <gui/elements.h>
|
|
|
-//#include <dolphin/dolphin.h>
|
|
|
#include <storage/storage.h>
|
|
|
#include <string.h>
|
|
|
-#include "flipbip_icons.h"
|
|
|
-#include "../helpers/flipbip_haptic.h"
|
|
|
-#include "../helpers/flipbip_led.h"
|
|
|
+//#include "flipbip_icons.h"
|
|
|
#include "../helpers/flipbip_string.h"
|
|
|
#include "../helpers/flipbip_file.h"
|
|
|
// From: /lib/crypto
|
|
|
@@ -43,7 +40,7 @@
|
|
|
#define TEXT_NEW_WALLET "New wallet"
|
|
|
#define TEXT_DEFAULT_COIN "Coin"
|
|
|
#define TEXT_RECEIVE_ADDRESS "receive address:"
|
|
|
-#define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0"
|
|
|
+// #define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0"
|
|
|
const char* TEXT_INFO = "-Scroll pages with up/down-"
|
|
|
"p1,2) BIP39 Mnemonic/Seed"
|
|
|
"p3) BIP32 Root Key "
|
|
|
@@ -55,16 +52,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;
|
|
|
@@ -98,7 +98,7 @@ static CONFIDENTIAL char* s_disp_text4 = NULL;
|
|
|
static CONFIDENTIAL char* s_disp_text5 = NULL;
|
|
|
static CONFIDENTIAL char* s_disp_text6 = NULL;
|
|
|
// Derivation path text
|
|
|
-static const char* s_derivation_text = TEXT_DEFAULT_DERIV;
|
|
|
+static const char* s_derivation_text = TEXT_DEFAULT_COIN; // TEXT_DEFAULT_DERIV;
|
|
|
// Warning text
|
|
|
static bool s_warn_insecure = false;
|
|
|
#define WARN_INSECURE_TEXT_1 "Recommendation:"
|
|
|
@@ -147,7 +147,6 @@ static void flipbip_scene_1_init_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);
|
|
|
|
|
|
} else if(coin_info[5] == FlipBipCoinETH60) { // ETH
|
|
|
@@ -157,6 +156,12 @@ 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) { // ZEC
|
|
|
+ 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
|
|
|
@@ -311,7 +316,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
|
|
|
canvas_set_font(canvas, FontPrimary);
|
|
|
canvas_draw_str(canvas, 2, 10, TEXT_LOADING);
|
|
|
canvas_draw_str(canvas, 7, 30, s_derivation_text);
|
|
|
- canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36);
|
|
|
+ // canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36);
|
|
|
if(s_warn_insecure) {
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
canvas_draw_str(canvas, 2, 50, WARN_INSECURE_TEXT_1);
|
|
|
@@ -654,9 +659,12 @@ void flipbip_scene_1_enter(void* context) {
|
|
|
s_derivation_text = TEXT_NEW_WALLET;
|
|
|
}
|
|
|
|
|
|
- flipbip_play_happy_bump(app);
|
|
|
+ // Wait a beat to allow the display time to update to the loading screen
|
|
|
+ furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
|
|
|
+
|
|
|
+ //flipbip_play_happy_bump(app);
|
|
|
//notification_message(app->notification, &sequence_blink_cyan_100);
|
|
|
- flipbip_led_set_rgb(app, 255, 0, 0);
|
|
|
+ //flipbip_led_set_rgb(app, 255, 0, 0);
|
|
|
|
|
|
with_view_model(
|
|
|
instance->view,
|
|
|
@@ -669,7 +677,8 @@ void flipbip_scene_1_enter(void* context) {
|
|
|
|
|
|
// nonzero status, free the mnemonic
|
|
|
if(status != FlipBipStatusSuccess) {
|
|
|
- memzero((void*)model->mnemonic, strlen(model->mnemonic));
|
|
|
+ // calling strlen on mnemonic here can cause a crash, don't.
|
|
|
+ // it wasn't loaded properly anyways, no need to zero the memory
|
|
|
free((void*)model->mnemonic);
|
|
|
}
|
|
|
|
|
|
@@ -677,15 +686,15 @@ void flipbip_scene_1_enter(void* context) {
|
|
|
if(status == FlipBipStatusSaveError) {
|
|
|
model->mnemonic = "ERROR:,Save error";
|
|
|
model->page = PAGE_MNEMONIC;
|
|
|
- flipbip_play_long_bump(app);
|
|
|
+ //flipbip_play_long_bump(app);
|
|
|
} else if(status == FlipBipStatusLoadError) {
|
|
|
model->mnemonic = "ERROR:,Load error";
|
|
|
model->page = PAGE_MNEMONIC;
|
|
|
- flipbip_play_long_bump(app);
|
|
|
+ //flipbip_play_long_bump(app);
|
|
|
} else if(status == FlipBipStatusMnemonicCheckError) {
|
|
|
model->mnemonic = "ERROR:,Mnemonic check error";
|
|
|
model->page = PAGE_MNEMONIC;
|
|
|
- flipbip_play_long_bump(app);
|
|
|
+ //flipbip_play_long_bump(app);
|
|
|
}
|
|
|
|
|
|
// s_busy = false;
|