hsd-ledger
This is a client library for ledger-app-hns. It uses primitives from hsd.
Install
$ git clone https://github.com/handshake-org/hsd-ledger.git
$ cd hsd-ledger
$ npm install
Usage
Node.js Library
When requiring hsd-ledger
as a dependency in your project, you MUST
also install hsd
, either globally (npm i -g hsd
) or require hsd
as a
sibling dependency along side hsd-ledger
. This is effectively how
peerDependencies
worked in npm version 4 through 6, but starting with npm v7,
those dependencies are installed, usually a second time, causing instanceof
checks to fail.
There are two ways to use this library to interact with a Ledger device:
- using HID from Node.js
- using WebUSB in the browser
Example usage can be found and run using the following files:
- examples/getAppVersion.js - Get the application version number.
- examples/getAccountXPUB.js - Get a BIP44 account xpub.
- examples/getXPUB.js - Get an arbitrary xpub.
- examples/getAddress.js - Get a BIP44 compliant address.
- examples/getPublicKey.js - Get a BIP44 compliant address.
- examples/signTransaction-p2pkh.js - Sign P2PKH transaction.
- examples/signTransaction-p2sh.js - Sign P2SH transaction.
- examples/webusb/index.js - WebUSB.
CLI
There is a CLI tool, in the bin
directory, that can interact with a Ledger
device and an hsd
full node. The docs are here.
Tests
Unit tests
$ npm test
End-to-end tests
For all end-to-end tests, a LOG_LEVEL
environment variable can be set
to control the log output. Possible log levels include: none
, info
,
warning
, debug
, error
, spam
.
Note: the end-to-end tests require a connected Ledger Nano S using the seed phrase:
abandon abandon abandon abandon abandon abandon
abandon abandon abandon abandon abandon about
Using Ledger Nano S
$ npm run test-hid
Using Ledger Nano S and hsd
$ npm run test-hsd
Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your code
to be distributed under the MIT license. You are also implicitly verifying that
all code is your original work. </legalese>
License
- Copyright (c) 2018, Boyma Fahnbulleh (MIT License).
This project is a fork of bledger.
bledger
- Copyright (c) 2018, The Bcoin Developers (MIT License).
See LICENSE for more info.