diff --git a/firmware/ethereum.c b/firmware/ethereum.c index 87b7f529da..a5cf7a32a7 100644 --- a/firmware/ethereum.c +++ b/firmware/ethereum.c @@ -568,7 +568,8 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node) rlp_length += rlp_calculate_length(1, tx_type); } if (chain_id) { - rlp_length += rlp_calculate_length(1, chain_id); + int length = chain_id < 0x100 ? 1: chain_id < 0x10000 ? 2: chain_id < 0x1000000 ? 3 : 4; + rlp_length += rlp_calculate_length(length, chain_id); rlp_length += rlp_calculate_length(0, 0); rlp_length += rlp_calculate_length(0, 0); }