1import Transport from '@ledgerhq/hw-transport-u2f';
2import Eth from '@ledgerhq/hw-app-eth';
4export const LEDGER_LEGACY_PATH = "m/44'/60'/0'/x";
5export const LEDGER_LIVE_PATH = "m/44'/60'/x'/0/0";
7export const chopHdPrefix = str =>
8 str.slice(0, 2) === 'm/' ? str.slice(2) : str;
9export const addHdPrefix = str => (str.slice(0, 2) === 'm/' ? str : 'm/' + str);
11export const ledgerSignTransaction = async (txn, hdpath) => {
12 const transport = await Transport.create();
13 const eth = new Eth(transport);
15 const path = chopHdPrefix(hdpath);
16 const serializedTx = txn.serialize().toString('hex');
17 const sig = await eth.signTransaction(path, serializedTx);
19 txn.v = Buffer.from(sig.v, 'hex');
20 txn.r = Buffer.from(sig.r, 'hex');
21 txn.s = Buffer.from(sig.s, 'hex');
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