Skip to content

Commit

Permalink
moving qr file stuff to file class
Browse files Browse the repository at this point in the history
  • Loading branch information
xtruan committed Mar 12, 2023
1 parent f8f744e commit 8d2de88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
16 changes: 16 additions & 0 deletions helpers/flipbip_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
#define FLIPBIP_KEY_PATH FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME)
#define FLIPBIP_KEY_PATH_BAK FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME_BAK)

#define TEXT_QRFILE_EXT ".qrcode"
const char* TEXT_QRFILE = "Filetype: QRCode\n"
"Version: 0\n"
"Message: ";

const size_t FILE_HLEN = 4;
const size_t FILE_KLEN = 256;
const size_t FILE_SLEN = 512;
Expand Down Expand Up @@ -166,6 +171,17 @@ bool flipbip_save_settings(
return ret;
}

bool flipbip_save_qrfile(
const char* qr_msg_prefix,
const char* qr_msg_content,
const char* file_name) {
char qr_buf[90] = {0};
strcpy(qr_buf, TEXT_QRFILE);
strcpy(qr_buf + strlen(qr_buf), qr_msg_prefix);
strcpy(qr_buf + strlen(qr_buf), qr_msg_content);
return flipbip_save_settings(qr_buf, FlipBipFileOther, file_name, false);
}

bool flipbip_load_settings_secure(char* settings) {
const size_t dlen = FILE_HLEN + FILE_SLEN + 1;

Expand Down
5 changes: 5 additions & 0 deletions helpers/flipbip_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ bool flipbip_save_settings(
const char* file_name,
const bool append);

bool flipbip_save_qrfile(
const char* qr_msg_prefix,
const char* qr_msg_content,
const char* file_name);

bool flipbip_load_settings_secure(char* settings);
bool flipbip_save_settings_secure(const char* settings);
11 changes: 0 additions & 11 deletions views/flipbip_scene_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ const char* TEXT_INFO = "-Scroll pages with up/down-"
"p8+) Receive Addresses ";

#define TEXT_SAVE_QR "Save QR"
#define TEXT_QRFILE_EXT "address.qrcode"
const char* TEXT_QRFILE = "Filetype: QRCode\n"
"Version: 0\n"
"Message: ";

// bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
const uint32_t COIN_INFO_ARRAY[3][6] = {
Expand Down Expand Up @@ -523,13 +519,6 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) {
FlipBipScene1Model * model,
{
if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) {
char qrbuf[90] = {0};
strcpy(qrbuf, TEXT_QRFILE);
strcpy(qrbuf + strlen(qrbuf), COIN_TEXT_ARRAY[model->coin][2]);
strcpy(
qrbuf + strlen(qrbuf),
model->recv_addresses[model->page - PAGE_ADDR_BEGIN]);
flipbip_save_settings(qrbuf, FlipBipFileOther, TEXT_QRFILE_EXT, false);
}
},
true);
Expand Down

0 comments on commit 8d2de88

Please sign in to comment.