Skip to content

Commit c9ddd18

Browse files
authored
fix(legacy): fix Polkadot signing issues (#172)
1 parent cb6e8dd commit c9ddd18

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

legacy/firmware/polkadot.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static bool layoutPolkadotSign(char *signer) {
133133

134134
static bool get_signer_address(const PolkadotSignTx *msg, const HDNode *node,
135135
char *address) {
136-
uint16_t addressType = 0;
136+
uint16_t addressType = 42;
137137
if (!strncmp(msg->network, "polkadot", 8)) {
138138
addressType = 0;
139139
} else if (!strncmp(msg->network, "kusama", 6)) {
@@ -146,8 +146,6 @@ static bool get_signer_address(const PolkadotSignTx *msg, const HDNode *node,
146146
addressType = 126;
147147
} else if (!strncmp(msg->network, "manta", 5)) {
148148
addressType = 77;
149-
} else {
150-
return false;
151149
}
152150
polkadot_get_address_from_public_key(node->public_key + 1, address,
153151
addressType);
@@ -162,7 +160,7 @@ bool polkadot_sign_tx(const PolkadotSignTx *msg, const HDNode *node,
162160
layoutHome();
163161
return false;
164162
}
165-
163+
memzero(polkadot_network, sizeof(polkadot_network));
166164
memcpy(polkadot_network, msg->network, strlen(msg->network) + 1);
167165
parser_error_t ret = polkadot_tx_parse(msg->raw_tx.bytes, msg->raw_tx.size);
168166
if (ret == parser_unexpected_callIndex) {

legacy/firmware/polkadot/parser_impl.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,5 @@ parser_error_t _polkadot_readTx(parser_context_t *c, parser_tx_t *v,
3333
return parser_unexpected_value;
3434
}
3535
}
36-
if (c->offset < c->bufferLen) {
37-
return parser_unexpected_unparsed_bytes;
38-
}
39-
40-
if (c->offset > c->bufferLen) {
41-
return parser_unexpected_buffer_end;
42-
}
4336
return parser_ok;
4437
}

legacy/firmware/polkadot/parser_impl_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ uint16_t _getAddressType() { return __address_type; }
343343
uint16_t _detectAddressType(const parser_context_t *c) {
344344
(void)c;
345345
memset(__polkadot_ticker, 0, sizeof(__polkadot_ticker));
346+
memcpy(__polkadot_ticker, " UNKN", 5);
347+
__polkadot_decimal = 0;
346348
if (!strncmp(polkadot_network, "polkadot", 8)) {
347349
__polkadot_decimal = COIN_AMOUNT_DECIMAL_PLACES;
348350
memcpy(__polkadot_ticker, COIN_TICKER, 4);
@@ -368,7 +370,7 @@ uint16_t _detectAddressType(const parser_context_t *c) {
368370
memcpy(__polkadot_ticker, MANTA_COIN_TICKER, 6);
369371
return 77;
370372
}
371-
373+
memcpy(polkadot_network, "unkn Chain", 11);
372374
return 42;
373375
}
374376

0 commit comments

Comments
 (0)