Skip to content

Commit

Permalink
Merge pull request #206 from MyEtherWallet/devop/wallet-update
Browse files Browse the repository at this point in the history
reimplement chainid calculation and update for bitbox v5
  • Loading branch information
gamalielhere committed Dec 10, 2018
2 parents 9db79d3 + 113a535 commit 232061d
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 200 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

### Devop

- ChainID calculation refactoring and BitBox v5 support [#206](https://github.com/MyEtherWallet/MyEtherWallet/pull/206)
- Generate deterministic builds [#217](https://github.com/MyEtherWallet/MyEtherWallet/pull/217)
- Use token package [#183](https://github.com/MyEtherWallet/MyEtherWallet/pull/183)
- Update nonce properly on send and fetch, parse response properly [#185](https://github.com/MyEtherWallet/MyEtherWallet/pull/185)
Expand Down
13 changes: 12 additions & 1 deletion src/wallets/WalletInterface.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
getBufferFromHex,
getSignTransactionObject,
sanitizeHex
sanitizeHex,
calculateChainIdFromV
} from './utils';
import ethUtil from 'ethereumjs-util';
import ethTx from 'ethereumjs-tx';
Expand Down Expand Up @@ -65,7 +66,17 @@ class WalletInterface {
return new Promise((resolve, reject) => {
if (!this.isPubOnly) {
const tx = new ethTx(txParams);
const networkId = tx._chainId;
tx.sign(this.privateKey);
const signedChainId = calculateChainIdFromV(tx.v);
if (signedChainId !== networkId)
throw new Error(
'Invalid networkId signature returned. Expected: ' +
networkId +
', Got: ' +
signedChainId,
'InvalidNetworkId'
);
resolve(getSignTransactionObject(tx));
} else {
signer(txParams)
Expand Down
Loading

1 comment on commit 232061d

@mew-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.