mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
implement GetAddress.show_display
This commit is contained in:
parent
63c6d046d1
commit
e5d55967a0
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,3 +4,6 @@
|
||||
[submodule "trezor-common"]
|
||||
path = trezor-common
|
||||
url = https://github.com/trezor/trezor-common.git
|
||||
[submodule "trezor-qrenc"]
|
||||
path = trezor-qrenc
|
||||
url = https://github.com/trezor/trezor-qrenc.git
|
||||
|
@ -44,6 +44,7 @@ CFLAGS += $(OPTFLAGS) \
|
||||
-I$(TOP_DIR) \
|
||||
-I$(TOP_DIR)/gen \
|
||||
-I$(TOP_DIR)/trezor-crypto \
|
||||
-I$(TOP_DIR)/trezor-qrenc
|
||||
|
||||
ifdef APPVER
|
||||
CFLAGS += -DAPPVER=$(APPVER)
|
||||
|
@ -35,6 +35,8 @@ OBJS += ../trezor-crypto/aeskey.o
|
||||
OBJS += ../trezor-crypto/aestab.o
|
||||
OBJS += ../trezor-crypto/aes_modes.o
|
||||
|
||||
OBJS += ../trezor-qrenc/qr_encode.o
|
||||
|
||||
OBJS += protob/pb_decode.o
|
||||
OBJS += protob/pb_encode.o
|
||||
OBJS += protob/messages.pb.o
|
||||
@ -43,9 +45,9 @@ OBJS += protob/types.pb.o
|
||||
|
||||
include ../Makefile.include
|
||||
|
||||
# CFLAGS += -fstack-protector -fstack-protector-all
|
||||
CFLAGS += -Wno-sequence-point
|
||||
CFLAGS += -Iprotob -DPB_FIELD_16BIT=1
|
||||
CFLAGS += -DQR_MAX_VERSION=0
|
||||
CFLAGS += -DDEBUG_LINK=0
|
||||
CFLAGS += -DDEBUG_LOG=0
|
||||
CFLAGS += -DSCM_REVISION='"$(shell git rev-parse HEAD | sed 's:\(..\):\\x\1:g')"'
|
||||
|
@ -478,6 +478,15 @@ void fsm_msgGetAddress(GetAddress *msg)
|
||||
|
||||
ecdsa_get_address(node->public_key, coin->address_type, resp->address);
|
||||
|
||||
if (msg->has_show_display && msg->show_display) {
|
||||
layoutAddress(resp->address);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_Address, true)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Show address cancelled");
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
msg_write(MessageType_MessageType_Address, resp);
|
||||
layoutHome();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "bitmaps.h"
|
||||
#include "string.h"
|
||||
#include "util.h"
|
||||
#include "qr_encode.h"
|
||||
|
||||
void *layoutLast = layoutHome;
|
||||
|
||||
@ -251,3 +252,55 @@ void layoutCipherKeyValue(bool encrypt, const char *key)
|
||||
encrypt ? "Encrypt?" : "Decrypt?",
|
||||
str[0], str[1], str[2], str[3], NULL, NULL);
|
||||
}
|
||||
|
||||
void layoutAddress(const char *address)
|
||||
{
|
||||
oledSwipeLeft();
|
||||
layoutLast = layoutAddress;
|
||||
|
||||
static unsigned char bitdata[QR_MAX_BITDATA];
|
||||
int a, i, j;
|
||||
int side = qr_encode(QR_LEVEL_M, 0, address, 0, bitdata);
|
||||
|
||||
if (side > 0 && side <= 29) {
|
||||
oledInvert(0, 0, (side + 2) * 2, (side + 2) * 2);
|
||||
for (i = 0; i < side; i++) {
|
||||
for (j = 0; j< side; j++) {
|
||||
a = i * side + j;
|
||||
if (bitdata[a / 8] & (1 << (7 - a % 8))) {
|
||||
oledClearPixel(2 + i * 2, 2 + j * 2);
|
||||
oledClearPixel(3 + i * 2, 2 + j * 2);
|
||||
oledClearPixel(2 + i * 2, 3 + j * 2);
|
||||
oledClearPixel(3 + i * 2, 3 + j * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int len = strlen(address);
|
||||
char str[4][10];
|
||||
memset(str, 0, sizeof(str));
|
||||
|
||||
strlcpy(str[0], (char *)address, 10);
|
||||
if (len > 9) {
|
||||
strlcpy(str[1], (char *)address + 9, 10);
|
||||
}
|
||||
if (len > 18) {
|
||||
strlcpy(str[2], (char *)address + 18, 10);
|
||||
}
|
||||
if (len > 27) {
|
||||
strlcpy(str[3], (char *)address + 27, 10);
|
||||
}
|
||||
|
||||
oledDrawString(68, 0 * 9, str[0]);
|
||||
oledDrawString(68, 1 * 9, str[1]);
|
||||
oledDrawString(68, 2 * 9, str[2]);
|
||||
oledDrawString(68, 3 * 9, str[3]);
|
||||
|
||||
static const char *btnYes = "Continue";
|
||||
oledDrawString(OLED_WIDTH - fontCharWidth('}') - 1, OLED_HEIGHT - 8, "}");
|
||||
oledDrawString(OLED_WIDTH - fontStringWidth(btnYes) - fontCharWidth('}') - 3, OLED_HEIGHT - 8, btnYes);
|
||||
oledInvert(OLED_WIDTH - fontStringWidth(btnYes) - fontCharWidth('}') - 4, OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1);
|
||||
|
||||
oledRefresh();
|
||||
}
|
||||
|
@ -33,5 +33,6 @@ void layoutFeeOverThreshold(const CoinType *coin, uint64_t fee, uint32_t kb);
|
||||
void layoutSignMessage(const uint8_t *msg, uint32_t len);
|
||||
void layoutVerifyMessage(const uint8_t *msg, uint32_t len);
|
||||
void layoutCipherKeyValue(bool encrypt, const char *key);
|
||||
void layoutAddress(const char *address);
|
||||
|
||||
#endif
|
||||
|
@ -126,9 +126,10 @@ const pb_field_t PublicKey_fields[3] = {
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t GetAddress_fields[3] = {
|
||||
const pb_field_t GetAddress_fields[4] = {
|
||||
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, GetAddress, address_n, address_n, 0),
|
||||
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, GetAddress, coin_name, address_n, &GetAddress_coin_name_default),
|
||||
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, GetAddress, show_display, coin_name, 0),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
|
@ -298,6 +298,8 @@ typedef struct _GetAddress {
|
||||
uint32_t address_n[8];
|
||||
bool has_coin_name;
|
||||
char coin_name[17];
|
||||
bool has_show_display;
|
||||
bool show_display;
|
||||
} GetAddress;
|
||||
|
||||
typedef struct _GetEntropy {
|
||||
@ -551,6 +553,7 @@ extern const char SimpleSignTx_coin_name_default[17];
|
||||
#define FirmwareUpload_payload_tag 1
|
||||
#define GetAddress_address_n_tag 1
|
||||
#define GetAddress_coin_name_tag 2
|
||||
#define GetAddress_show_display_tag 3
|
||||
#define GetEntropy_size_tag 1
|
||||
#define GetPublicKey_address_n_tag 1
|
||||
#define LoadDevice_mnemonic_tag 1
|
||||
@ -625,7 +628,7 @@ extern const pb_field_t GetEntropy_fields[2];
|
||||
extern const pb_field_t Entropy_fields[2];
|
||||
extern const pb_field_t GetPublicKey_fields[2];
|
||||
extern const pb_field_t PublicKey_fields[3];
|
||||
extern const pb_field_t GetAddress_fields[3];
|
||||
extern const pb_field_t GetAddress_fields[4];
|
||||
extern const pb_field_t Address_fields[2];
|
||||
extern const pb_field_t WipeDevice_fields[1];
|
||||
extern const pb_field_t LoadDevice_fields[8];
|
||||
@ -675,7 +678,7 @@ extern const pb_field_t DebugLinkLog_fields[4];
|
||||
#define Entropy_size 1027
|
||||
#define GetPublicKey_size 48
|
||||
#define PublicKey_size (121 + HDNodeType_size)
|
||||
#define GetAddress_size 67
|
||||
#define GetAddress_size 69
|
||||
#define Address_size 37
|
||||
#define WipeDevice_size 0
|
||||
#define LoadDevice_size (320 + HDNodeType_size)
|
||||
|
@ -50,7 +50,8 @@ typedef enum _ButtonRequestType {
|
||||
ButtonRequestType_ButtonRequest_WipeDevice = 6,
|
||||
ButtonRequestType_ButtonRequest_ProtectCall = 7,
|
||||
ButtonRequestType_ButtonRequest_SignTx = 8,
|
||||
ButtonRequestType_ButtonRequest_FirmwareCheck = 9
|
||||
ButtonRequestType_ButtonRequest_FirmwareCheck = 9,
|
||||
ButtonRequestType_ButtonRequest_Address = 10
|
||||
} ButtonRequestType;
|
||||
|
||||
typedef enum _PinMatrixRequestType {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ce8e99465ea1fbcbdc5e7b477cfdab73244a444d
|
||||
Subproject commit 5bbe684c1068bd9cb6d24b12da5e216feb74351d
|
1
trezor-qrenc
Submodule
1
trezor-qrenc
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit dfcfd702be6d0c1bc3f035001fba20f5336f308b
|
Loading…
Reference in New Issue
Block a user