Skip to content

Commit 1a7b0db

Browse files
committed
overwrite boolean
1 parent 5d626b8 commit 1a7b0db

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

flipbip.c

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ FlipBip* flipbip_app_alloc() {
4343
app->led = 1;
4444
app->bip39_strength = 2; // 256 bits (24 words)
4545
app->bip44_coin = 0; // 0 (BTC)
46+
app->overwrite_saved_seed = 0;
4647

4748
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu));
4849
app->flipbip_startscreen = flipbip_startscreen_alloc();

flipbip.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef struct {
2727
int led;
2828
int bip39_strength;
2929
int bip44_coin;
30+
int overwrite_saved_seed;
3031
} FlipBip;
3132

3233
typedef enum {

views/flipbip_scene_1.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
263263

264264
}
265265

266-
static void flipbip_scene_1_model_init(FlipBipScene1Model* const model, const int strength, const uint32_t coin) {
266+
static void flipbip_scene_1_model_init(FlipBipScene1Model* const model, const int strength, const uint32_t coin, const bool overwrite) {
267267

268268
model->page = 0;
269269
model->coin = coin;
@@ -273,8 +273,8 @@ static void flipbip_scene_1_model_init(FlipBipScene1Model* const model, const in
273273
char* mnemonic = malloc(256);
274274
memzero(mnemonic, 256);
275275

276-
// Check if the mnemonic key & data is already saved in persistent storage
277-
if (!flipbip_has_settings(true) && !flipbip_has_settings(false)) {
276+
// Check if the mnemonic key & data is already saved in persistent storage, or overwrite is true
277+
if (overwrite || (!flipbip_has_settings(true) && !flipbip_has_settings(false))) {
278278
// Generate a random mnemonic using trezor-crypto
279279
const char* mnemonic_gen = mnemonic_generate(strength);
280280
// Save the mnemonic to persistent storage
@@ -476,14 +476,17 @@ void flipbip_scene_1_enter(void* context) {
476476
uint32_t coin = 0; //FlipBipCoinBTC0 // BTC (0)
477477
if (coin_setting == FlipBipCoinETH60) coin = 60; // ETH (60)
478478

479+
// Overwrite the saved seed with a new one setting
480+
bool overwrite = app->overwrite_saved_seed != 0;
481+
479482
flipbip_play_happy_bump(app);
480483
flipbip_led_set_rgb(app, 255, 0, 0);
481484

482485
with_view_model(
483486
instance->view,
484487
FlipBipScene1Model * model,
485488
{
486-
flipbip_scene_1_model_init(model, strength, coin);
489+
flipbip_scene_1_model_init(model, strength, coin, overwrite);
487490
},
488491
true
489492
);

0 commit comments

Comments
 (0)