mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-27 01:48:17 +00:00
Handle edge cases for ethereum txs.
Treat the case where a field is omitted identical to the case where an empty array is given. In particular - data_length == 0 is allowed now and identical to giving no data. - nonce can be omitted to indicate nonce value 0. I still do not allow to omit gas_limit and gas_price; gas_limit cannot be zero and transactions with zero gas_price will not be mined. You can still set it explicitly to zero by giving the empty array, though. See trezor/trezor-mcu#143.
This commit is contained in:
parent
505df38a84
commit
f36cf5c10c
@ -383,7 +383,7 @@ static void layoutEthereumFee(const uint8_t *value, uint32_t value_len,
|
|||||||
|
|
||||||
static bool ethereum_signing_check(EthereumSignTx *msg)
|
static bool ethereum_signing_check(EthereumSignTx *msg)
|
||||||
{
|
{
|
||||||
if (!msg->has_nonce || !msg->has_gas_price || !msg->has_gas_limit) {
|
if (!msg->has_gas_price || !msg->has_gas_limit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,13 +418,10 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
|
|||||||
msg->data_initial_chunk.size = 0;
|
msg->data_initial_chunk.size = 0;
|
||||||
if (!msg->has_to)
|
if (!msg->has_to)
|
||||||
msg->to.size = 0;
|
msg->to.size = 0;
|
||||||
|
if (!msg->has_nonce)
|
||||||
|
msg->nonce.size = 0;
|
||||||
|
|
||||||
if (msg->has_data_length) {
|
if (msg->has_data_length && msg->data_length > 0) {
|
||||||
if (msg->data_length == 0) {
|
|
||||||
fsm_sendFailure(FailureType_Failure_Other, "Invalid data length provided");
|
|
||||||
ethereum_signing_abort();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!msg->has_data_initial_chunk || msg->data_initial_chunk.size == 0) {
|
if (!msg->has_data_initial_chunk || msg->data_initial_chunk.size == 0) {
|
||||||
fsm_sendFailure(FailureType_Failure_Other, "Data length provided, but no initial chunk");
|
fsm_sendFailure(FailureType_Failure_Other, "Data length provided, but no initial chunk");
|
||||||
ethereum_signing_abort();
|
ethereum_signing_abort();
|
||||||
|
Loading…
Reference in New Issue
Block a user