Skip to content

Commit

Permalink
update apps
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Aug 13, 2023
1 parent fdb62b1 commit 800482e
Show file tree
Hide file tree
Showing 25 changed files with 128 additions and 455 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The goal of this project is to see how much crypto functionality can be brought
- 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 (by @wh00hw)
- 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
6 changes: 2 additions & 4 deletions application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ App(
stack_size=3 * 1024,
order=10,
fap_icon="flipbip_10px.png",
fap_icon_assets="icons",
fap_icon_assets_symbol="flipbip",
fap_private_libs=[
Lib(
name="crypto",
Expand All @@ -19,6 +17,6 @@ App(
fap_category="Tools",
fap_author="Struan Clark (xtruan)",
fap_weburl="https://github.com/xtruan/FlipBIP",
fap_version=(1, 11),
fap_description="Crypto wallet tools for Flipper",
fap_version=(1, 13),
fap_description="Crypto wallet for Flipper",
)
47 changes: 23 additions & 24 deletions flipbip.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma GCC optimize("-Os")

#include "flipbip.h"
#include "helpers/flipbip_file.h"
#include "helpers/flipbip_haptic.h"
// From: lib/crypto
#include <memzero.h>
#include <bip39.h>

#define MNEMONIC_MENU_DEFAULT "Import mnemonic seed"
#define MNEMONIC_MENU_SUCCESS "Import seed (success)"
#define MNEMONIC_MENU_FAILURE "Import seed (failed!)"

bool flipbip_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
FlipBip* app = context;
Expand Down Expand Up @@ -42,6 +43,7 @@ static void text_input_callback(void* context) {
// reset input state
app->input_state = FlipBipTextInputDefault;
handled = true;
// switch back to settings view
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
} else if(app->input_state == FlipBipTextInputMnemonic) {
if(app->import_from_mnemonic == 1) {
Expand All @@ -56,11 +58,13 @@ static void text_input_callback(void* context) {
status = FlipBipStatusSaveError; // 12 = save error

if(status == FlipBipStatusSuccess) {
app->mnemonic_menu_text = MNEMONIC_MENU_SUCCESS;
//notification_message(app->notification, &sequence_blink_cyan_100);
flipbip_play_happy_bump(app);
//flipbip_play_happy_bump(app);
} else {
app->mnemonic_menu_text = MNEMONIC_MENU_FAILURE;
//notification_message(app->notification, &sequence_blink_red_100);
flipbip_play_long_bump(app);
//flipbip_play_long_bump(app);
}

memzero(app->import_mnemonic_text, TEXT_BUFFER_SIZE);
Expand All @@ -70,7 +74,9 @@ static void text_input_callback(void* context) {
// reset input state
app->input_state = FlipBipTextInputDefault;
handled = true;
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
// exit scene 1 instance that's being used for text input and go back to menu
scene_manager_previous_scene(app->scene_manager);
//view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
}
}

Expand All @@ -79,19 +85,20 @@ static void text_input_callback(void* context) {
memzero(app->input_text, TEXT_BUFFER_SIZE);
// reset input state
app->input_state = FlipBipTextInputDefault;
// something went wrong, switch to menu view
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
}
}

FlipBip* flipbip_app_alloc() {
FlipBip* app = malloc(sizeof(FlipBip));
app->gui = furi_record_open(RECORD_GUI);
app->notification = furi_record_open(RECORD_NOTIFICATION);
//app->notification = furi_record_open(RECORD_NOTIFICATION);

//Turn backlight on, believe me this makes testing your app easier
notification_message(app->notification, &sequence_display_backlight_on);
// Turn backlight on, believe me this makes testing your app easier
//notification_message(app->notification, &sequence_display_backlight_on);

//Scene additions
// Scene additions
app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(app->view_dispatcher);

Expand All @@ -105,26 +112,20 @@ FlipBip* flipbip_app_alloc() {
app->submenu = submenu_alloc();

// Settings
app->haptic = FlipBipHapticOn;
app->led = FlipBipLedOn;
app->bip39_strength = FlipBipStrength256; // 256 bits (24 words)
app->passphrase = FlipBipPassphraseOff;

// Main menu
app->bip44_coin = FlipBipCoinBTC0; // 0 (BTC)
app->overwrite_saved_seed = 0;
app->import_from_mnemonic = 0;
app->mnemonic_menu_text = MNEMONIC_MENU_DEFAULT;

// Text input
app->input_state = FlipBipTextInputDefault;

view_dispatcher_add_view(
app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu));
app->flipbip_startscreen = flipbip_startscreen_alloc();
view_dispatcher_add_view(
app->view_dispatcher,
FlipBipViewIdStartscreen,
flipbip_startscreen_get_view(app->flipbip_startscreen));
app->flipbip_scene_1 = flipbip_scene_1_alloc();
view_dispatcher_add_view(
app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1));
Expand All @@ -141,13 +142,13 @@ FlipBip* flipbip_app_alloc() {
(void*)app,
app->input_text,
TEXT_BUFFER_SIZE,
//clear default text
// clear default text
true);
text_input_set_header_text(app->text_input, "Input");
//text_input_set_header_text(app->text_input, "Input");
view_dispatcher_add_view(
app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input));

//End Scene Additions
// End Scene Additions

return app;
}
Expand All @@ -171,7 +172,7 @@ void flipbip_app_free(FlipBip* app) {
furi_record_close(RECORD_GUI);

app->gui = NULL;
app->notification = NULL;
//app->notification = NULL;

//Remove whatever is left
memzero(app, sizeof(FlipBip));
Expand All @@ -190,9 +191,7 @@ int32_t flipbip_app(void* p) {

view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

scene_manager_next_scene(
app->scene_manager, FlipBipSceneStartscreen); //Start with start screen
//scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //if you want to directly start with Menu
scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //Start with menu

furi_hal_power_suppress_charge_enter();

Expand Down
23 changes: 6 additions & 17 deletions flipbip.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,35 @@
#include <gui/gui.h>
#include <input/input.h>
#include <stdlib.h>
#include <notification/notification_messages.h>
//#include <notification/notification_messages.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
#include <gui/scene_manager.h>
#include <gui/modules/variable_item_list.h>
#include <gui/modules/text_input.h>
#include "scenes/flipbip_scene.h"
#include "views/flipbip_startscreen.h"
#include "views/flipbip_scene_1.h"

#define FLIPBIP_VERSION "v1.11.0"
#define FLIPBIP_VERSION "v1.13"

#define COIN_BTC 0
#define COIN_DOGE 3
#define COIN_ETH 60
#define COIN_ZEC 133

#define TEXT_BUFFER_SIZE 256

typedef struct {
Gui* gui;
NotificationApp* notification;
// NotificationApp* notification;
ViewDispatcher* view_dispatcher;
Submenu* submenu;
SceneManager* scene_manager;
VariableItemList* variable_item_list;
TextInput* text_input;
FlipBipStartscreen* flipbip_startscreen;
FlipBipScene1* flipbip_scene_1;
char* mnemonic_menu_text;
// Settings options
int haptic;
int led;
int bip39_strength;
int passphrase;
// Main menu options
Expand All @@ -57,16 +55,6 @@ typedef enum {
FlipBipViewIdTextInput,
} FlipBipViewId;

typedef enum {
FlipBipHapticOff,
FlipBipHapticOn,
} FlipBipHapticState;

typedef enum {
FlipBipLedOff,
FlipBipLedOn,
} FlipBipLedState;

typedef enum {
FlipBipStrength128,
FlipBipStrength192,
Expand All @@ -82,6 +70,7 @@ typedef enum {
FlipBipCoinBTC0,
FlipBipCoinETH60,
FlipBipCoinDOGE3,
FlipBipCoinZEC133,
} FlipBipCoin;

typedef enum {
Expand Down
6 changes: 0 additions & 6 deletions helpers/flipbip_custom_event.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#pragma once

typedef enum {
FlipBipCustomEventStartscreenUp,
FlipBipCustomEventStartscreenDown,
FlipBipCustomEventStartscreenLeft,
FlipBipCustomEventStartscreenRight,
FlipBipCustomEventStartscreenOk,
FlipBipCustomEventStartscreenBack,
FlipBipCustomEventScene1Up,
FlipBipCustomEventScene1Down,
FlipBipCustomEventScene1Left,
Expand Down
35 changes: 0 additions & 35 deletions helpers/flipbip_haptic.c

This file was deleted.

7 changes: 0 additions & 7 deletions helpers/flipbip_haptic.h

This file was deleted.

39 changes: 0 additions & 39 deletions helpers/flipbip_led.c

This file was deleted.

2 changes: 0 additions & 2 deletions helpers/flipbip_led.h

This file was deleted.

27 changes: 0 additions & 27 deletions helpers/flipbip_speaker.c

This file was deleted.

4 changes: 0 additions & 4 deletions helpers/flipbip_speaker.h

This file was deleted.

1 change: 1 addition & 0 deletions lib/crypto/CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Oleg Andreev <[email protected]>
mog <[email protected]>
John Dvorak <[email protected]>
Christian Reitter <[email protected]>
Struan Clark <[email protected]>
2 changes: 2 additions & 0 deletions lib/crypto/bip32.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <string.h>

#include "address.h"
#if USE_NEM
#include "aes/aes.h"
#endif
#include "base58.h"
#include "bignum.h"
#include "bip32.h"
Expand Down
1 change: 1 addition & 0 deletions lib/crypto/memzero.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void memzero(void* const pnt, const size_t len) {
SecureZeroMemory(pnt, len);
#elif defined(HAVE_MEMSET_S)
memset_s(pnt, (rsize_t)len, 0, (rsize_t)len);
// REMOVED - Flipper Zero does not have this function
// #elif defined(HAVE_EXPLICIT_BZERO)
// explicit_bzero(pnt, len);
#elif defined(HAVE_EXPLICIT_MEMSET)
Expand Down
Loading

0 comments on commit 800482e

Please sign in to comment.