Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
fixed rlp_length for chain_id > 255
Browse files Browse the repository at this point in the history
  • Loading branch information
hackmod committed Jul 17, 2018
1 parent 277a01a commit c581715
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion firmware/ethereum.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,11 @@ 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 = 0;
if (msg->has_chain_id) {
length = chain_id < 0x80 ? 0: 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);
}
Expand Down

0 comments on commit c581715

Please sign in to comment.