1import Transport from '@ledgerhq/hw-transport-u2f'
2import Eth from '@ledgerhq/hw-app-eth'
4const LEDGER_BASE_PATH = "44'/60'/0'/0/0"
6const chopHdPrefix = str =>
7 str.slice(0, 2) === "m/"
11const 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