Skip to content

Commit

Permalink
Merge pull request #21 from xtruan/dev/reduce-fap-size
Browse files Browse the repository at this point in the history
Reduce FAP size
  • Loading branch information
xtruan authored Aug 11, 2023
2 parents 927f45d + b426b69 commit 5026eb0
Show file tree
Hide file tree
Showing 35 changed files with 102 additions and 452 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- develop

env:
firmware_version: '0.86.1'
firmware_version: '0.88.0'

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'

env:
firmware_version: '0.86.1'
firmware_version: '0.88.0'

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build](https://github.com/xtruan/FlipBIP/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/xtruan/FlipBIP/actions/workflows/build.yml)

## Crypto toolkit for Flipper Zero
- Last built against `0.86.1` Flipper Zero firmware release
- Last built against `0.88.0` Flipper Zero firmware release
- Using Trezor crypto libs from `core/v2.5.3` release
- Included in [RogueMaster Custom Firmware](https://github.com/RogueMaster/flipperzero-firmware-wPlugins)
- NOTE: This app uses very close to the maximum Flipper Zero RAM. If you get `furi_check failed` on launch, try running again!
Expand Down Expand Up @@ -43,7 +43,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
- 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, 12),
fap_description="Crypto wallet tools for Flipper",
fap_version=(1, 13),
fap_description="Crypto wallet for Flipper",
)
45 changes: 23 additions & 22 deletions flipbip.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#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 @@ -40,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 @@ -54,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 @@ -68,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 @@ -77,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 @@ -103,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 @@ -139,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 @@ -169,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 @@ -188,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
21 changes: 4 additions & 17 deletions flipbip.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
#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.12.0"
#define FLIPBIP_VERSION "v1.13"

#define COIN_BTC 0
#define COIN_DOGE 3
Expand All @@ -26,17 +25,15 @@

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 @@ -58,16 +55,6 @@ typedef enum {
FlipBipViewIdTextInput,
} FlipBipViewId;

typedef enum {
FlipBipHapticOff,
FlipBipHapticOn,
} FlipBipHapticState;

typedef enum {
FlipBipLedOff,
FlipBipLedOn,
} FlipBipLedState;

typedef enum {
FlipBipStrength128,
FlipBipStrength192,
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.

Binary file removed icons/Auth_62x31.png
Binary file not shown.
Binary file removed icons/ButtonCenter_7x7.png
Binary file not shown.
Binary file removed icons/ButtonDown_10x5.png
Binary file not shown.
Binary file removed icons/ButtonLeftSmall_3x5.png
Binary file not shown.
Binary file removed icons/ButtonLeft_4x7.png
Binary file not shown.
Binary file removed icons/ButtonRightSmall_3x5.png
Binary file not shown.
Binary file removed icons/ButtonRight_4x7.png
Binary file not shown.
Binary file removed icons/ButtonUp_10x5.png
Binary file not shown.
Binary file removed icons/Keychain_39x36.png
Binary file not shown.
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
Loading

0 comments on commit 5026eb0

Please sign in to comment.