Skip to content

Commit 95455c3

Browse files
committed
eth compatibility!
1 parent a978a37 commit 95455c3

File tree

6 files changed

+108
-91
lines changed

6 files changed

+108
-91
lines changed

crypto/options.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
// support Ethereum operations
6565
#ifndef USE_ETHEREUM
66-
#define USE_ETHEREUM 0
66+
#define USE_ETHEREUM 1
6767
#endif
6868

6969
// support NEM operations
@@ -83,7 +83,7 @@
8383

8484
// support Keccak hashing
8585
#ifndef USE_KECCAK
86-
#define USE_KECCAK 0
86+
#define USE_KECCAK 1
8787
#endif
8888

8989
// add way how to mark confidential data

flipbip.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ FlipBip* flipbip_app_alloc() {
3838
view_dispatcher_set_custom_event_callback(app->view_dispatcher, flipbip_custom_event_callback);
3939
app->submenu = submenu_alloc();
4040

41+
// Settings
4142
app->haptic = 1;
42-
//app->speaker = 1;
4343
app->led = 1;
4444
app->bip39_strength = 2; // 256 bits (24 words)
45+
app->bip44_coin = 0; // 0 (BTC)
4546

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

flipbip.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ typedef struct {
2626
FlipBipScene1* flipbip_scene_1;
2727
// FlipBipScene2* flipbip_scene_2;
2828
int haptic;
29-
// int speaker;
3029
int led;
3130
int bip39_strength;
31+
int bip44_coin;
3232
} FlipBip;
3333

3434
typedef enum {
@@ -44,11 +44,6 @@ typedef enum {
4444
FlipBipHapticOn,
4545
} FlipBipHapticState;
4646

47-
// typedef enum {
48-
// FlipBipSpeakerOff,
49-
// FlipBipSpeakerOn,
50-
// } FlipBipSpeakerState;
51-
5247
typedef enum {
5348
FlipBipLedOff,
5449
FlipBipLedOn,
@@ -59,3 +54,8 @@ typedef enum {
5954
FlipBipStrength192,
6055
FlipBipStrength256,
6156
} FlipBipStrengthState;
57+
58+
typedef enum {
59+
FlipBipCoinBTC0,
60+
FlipBipCoinETH60,
61+
} FlipBipCoinState;

scenes/flipbip_scene_menu.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
1414
void flipbip_scene_menu_on_enter(void* context) {
1515
FlipBip* app = context;
1616

17-
submenu_add_item(app->submenu, "Generate wallet", SubmenuIndexScene1, flipbip_scene_menu_submenu_callback, app);
17+
if (app->bip44_coin == FlipBipCoinBTC0) { // BTC
18+
submenu_add_item(app->submenu, "Generate BTC wallet", SubmenuIndexScene1, flipbip_scene_menu_submenu_callback, app);
19+
}
20+
if (app->bip44_coin == FlipBipCoinETH60) { // ETH
21+
submenu_add_item(app->submenu, "Generate ETH wallet", SubmenuIndexScene1, flipbip_scene_menu_submenu_callback, app);
22+
}
1823
//submenu_add_item(app->submenu, "Scene 2", SubmenuIndexScene2, flipbip_scene_menu_submenu_callback, app);
1924
submenu_add_item(app->submenu, "Settings", SubmenuIndexSettings, flipbip_scene_menu_submenu_callback, app);
2025

scenes/flipbip_scene_settings.c

+28-28
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
// enum SettingsIndex {
55
// SettingsIndexBip39Strength = 10,
6+
// SettingsIndexBip44Coin,
67
// SettingsIndexHaptic,
78
// SettingsIndexValue1,
8-
// SettingsIndexValue2,
99
// };
1010

1111
const char* const haptic_text[2] = {
@@ -17,15 +17,6 @@ const uint32_t haptic_value[2] = {
1717
FlipBipHapticOn,
1818
};
1919

20-
// const char* const speaker_text[2] = {
21-
// "OFF",
22-
// "ON",
23-
// };
24-
// const uint32_t speaker_value[2] = {
25-
// FlipBipSpeakerOff,
26-
// FlipBipSpeakerOn,
27-
// };
28-
2920
const char* const led_text[2] = {
3021
"OFF",
3122
"ON",
@@ -46,20 +37,22 @@ const uint32_t bip39_strength_value[3] = {
4637
FlipBipStrength256,
4738
};
4839

40+
const char* const bip44_coin_text[2] = {
41+
"BTC",
42+
"ETH",
43+
};
44+
const uint32_t bip44_coin_value[2] = {
45+
FlipBipCoinBTC0,
46+
FlipBipCoinETH60,
47+
};
48+
4949
static void flipbip_scene_settings_set_haptic(VariableItem* item) {
5050
FlipBip* app = variable_item_get_context(item);
5151
uint8_t index = variable_item_get_current_value_index(item);
5252
variable_item_set_current_value_text(item, haptic_text[index]);
5353
app->haptic = haptic_value[index];
5454
}
5555

56-
// static void flipbip_scene_settings_set_speaker(VariableItem* item) {
57-
// FlipBip* app = variable_item_get_context(item);
58-
// uint8_t index = variable_item_get_current_value_index(item);
59-
// variable_item_set_current_value_text(item, speaker_text[index]);
60-
// app->speaker = speaker_value[index];
61-
// }
62-
6356
static void flipbip_scene_settings_set_led(VariableItem* item) {
6457
FlipBip* app = variable_item_get_context(item);
6558
uint8_t index = variable_item_get_current_value_index(item);
@@ -74,6 +67,13 @@ static void flipbip_scene_settings_set_bip39_strength(VariableItem* item) {
7467
app->bip39_strength = bip39_strength_value[index];
7568
}
7669

70+
static void flipbip_scene_settings_set_bip44_coin(VariableItem* item) {
71+
FlipBip* app = variable_item_get_context(item);
72+
uint8_t index = variable_item_get_current_value_index(item);
73+
variable_item_set_current_value_text(item, bip44_coin_text[index]);
74+
app->bip44_coin = bip44_coin_value[index];
75+
}
76+
7777
void flipbip_scene_settings_submenu_callback(void* context, uint32_t index) {
7878
FlipBip* app = context;
7979
view_dispatcher_send_custom_event(app->view_dispatcher, index);
@@ -95,6 +95,17 @@ void flipbip_scene_settings_on_enter(void* context) {
9595
variable_item_set_current_value_index(item, value_index);
9696
variable_item_set_current_value_text(item, bip39_strength_text[value_index]);
9797

98+
// BIP44 Coin
99+
item = variable_item_list_add(
100+
app->variable_item_list,
101+
"BIP44 Coin:",
102+
2,
103+
flipbip_scene_settings_set_bip44_coin,
104+
app);
105+
value_index = value_index_uint32(app->bip44_coin, bip44_coin_value, 2);
106+
variable_item_set_current_value_index(item, value_index);
107+
variable_item_set_current_value_text(item, bip44_coin_text[value_index]);
108+
98109
// Vibro on/off
99110
item = variable_item_list_add(
100111
app->variable_item_list,
@@ -106,17 +117,6 @@ void flipbip_scene_settings_on_enter(void* context) {
106117
variable_item_set_current_value_index(item, value_index);
107118
variable_item_set_current_value_text(item, haptic_text[value_index]);
108119

109-
// // Sound on/off
110-
// item = variable_item_list_add(
111-
// app->variable_item_list,
112-
// "Sound:",
113-
// 2,
114-
// flipbip_scene_settings_set_speaker,
115-
// app);
116-
// value_index = value_index_uint32(app->speaker, speaker_value, 2);
117-
// variable_item_set_current_value_index(item, value_index);
118-
// variable_item_set_current_value_text(item, speaker_text[value_index]);
119-
120120
// LED Effects on/off
121121
item = variable_item_list_add(
122122
app->variable_item_list,

0 commit comments

Comments
 (0)