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

support 32bits chainId with the latest Ledger app #1979

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/scripts/uiFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ uiFuncs.signTxTrezor = function(rawTx, txData, callback) {
);
}
uiFuncs.signTxLedger = function(app, eTx, rawTx, txData, old, callback) {
eTx.raw[6] = Buffer.from([rawTx.chainId]);
eTx.raw[6] = rawTx.chainId;
eTx.raw[7] = eTx.raw[8] = 0;
var toHash = old ? eTx.raw.slice(0, 6) : eTx.raw;
var txToSign = ethUtil.rlp.encode(toHash);
Expand All @@ -69,7 +69,17 @@ uiFuncs.signTxLedger = function(app, eTx, rawTx, txData, old, callback) {
});
return;
}
rawTx.v = "0x" + result['v'];
var v = result['v'].toString(16);
if (!old) {
// EIP155 support. check/recalc signature v value.
var rv = parseInt(v, 16);
var cv = rawTx.chainId * 2 + 35;
if (rv !== cv && (rv & cv) !== rv) {
cv += 1; // add signature v bit.
}
v = cv.toString(16);
}
rawTx.v = "0x" + v;
rawTx.r = "0x" + result['r'];
rawTx.s = "0x" + result['s'];
eTx = new ethUtil.Tx(rawTx);
Expand Down