Skip to content

Commit

Permalink
write QR codes for addresses to file
Browse files Browse the repository at this point in the history
  • Loading branch information
xtruan committed Mar 13, 2023
1 parent 8d2de88 commit 99adebd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 3 additions & 4 deletions helpers/flipbip_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
#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: ";
"Message: "; // 37 chars + 1 null

const size_t FILE_HLEN = 4;
const size_t FILE_KLEN = 256;
Expand Down Expand Up @@ -125,8 +124,8 @@ bool flipbip_save_settings(
path = FLIPBIP_DAT_PATH;
path_bak = FLIPBIP_DAT_PATH_BAK;
} else {
char path_buf[32] = {0};
strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER);
char path_buf[48] = {0};
strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); // 22
strcpy(path_buf + strlen(path_buf), "/");
strcpy(path_buf + strlen(path_buf), file_name);
path = path_buf;
Expand Down
11 changes: 10 additions & 1 deletion views/flipbip_scene_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const char* TEXT_INFO = "-Scroll pages with up/down-"
"p8+) Receive Addresses ";

#define TEXT_SAVE_QR "Save QR"
#define TEXT_QRFILE_EXT ".qrcode" // 7 chars + 1 null

// bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
const uint32_t COIN_INFO_ARRAY[3][6] = {
Expand Down Expand Up @@ -445,10 +446,18 @@ static int flipbip_scene_1_model_init(
model->node = node;

// Initialize addresses
for(int a = 0; a < NUM_ADDRS; a++) {
for(uint8_t a = 0; a < NUM_ADDRS; a++) {
model->recv_addresses[a] = malloc(MAX_ADDR_LEN);
memzero(model->recv_addresses[a], MAX_ADDR_LEN);
flipbip_scene_1_init_address(model->recv_addresses[a], node, coin_info[5], a);

// Save QR code file
char name[14] = {0};
strcpy(name, COIN_TEXT_ARRAY[coin][0]);
const unsigned char addr_num[1] = {a};
flipbip_btox(addr_num, 1, name + strlen(name));
strcpy(name + strlen(name), TEXT_QRFILE_EXT);
flipbip_save_qrfile(COIN_TEXT_ARRAY[coin][2], model->recv_addresses[a], name);
}

model->page = PAGE_INFO;
Expand Down

0 comments on commit 99adebd

Please sign in to comment.