1import Transport from '@ledgerhq/hw-transport-u2f';
2import Eth from '@ledgerhq/hw-app-eth';
4const LEDGER_LEGACY_PATH = "m/44'/60'/0'/x";
5const LEDGER_LIVE_PATH = "m/44'/60'/x'/0/0";
7const chopHdPrefix = str => (str.slice(0, 2) === 'm/' ? str.slice(2) : str);
9const ledgerSignTransaction = async (txn, hdpath) => {
10 const transport = await Transport.create();
11 const eth = new Eth(transport);
13 const path = chopHdPrefix(hdpath);
14 const serializedTx = txn.serialize().toString('hex');
15 const sig = await eth.signTransaction(path, serializedTx);
17 txn.v = Buffer.from(sig.v, 'hex');
18 txn.r = Buffer.from(sig.r, 'hex');
19 txn.s = Buffer.from(sig.s, 'hex');
24export { LEDGER_LIVE_PATH, LEDGER_LEGACY_PATH, ledgerSignTransaction };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list