mirror of
https://github.com/luxfi/ledger-js.git
synced 2026-10-30 16:21:23 +00:00
A version written into a manifest is written into every manifest that wants it, which is how eslint came to exist in a hundred and four forms across this estate and how a package came to resolve twice at run time. The catalog moves the number out of the manifest: a manifest names the package, the workspace names the version. Four are held below their latest because the newer release cannot be used, and the reason is recorded rather than the version alone: @noble/hashes 2 renamed every subpath the web3 stack imports, @splinetool/runtime 2 depends on a package that was never published, @dynamic-labs 5.4.1 the same, and react-resizable-panels 3 points its types condition at the bundle.
@luxfi/hw-app-lux
Ledger Hardware Wallet JavaScript bindings for Lux, based on LedgerJS.
Using LedgerJS for Lux
Here is a sample app for Node:
const Transport = require("@ledgerhq/hw-transport-node-hid").default;
const Lux = require("@luxfi/hw-app-lux").default;
const getWalletId = async () => {
const lux = new Lux(await Transport.create());
return await lux.getWalletId();
};
const signHash = async () => {
const transport = await Transport.create();
const lux = new Lux(await Transport.create());
return await lux.signHash(
"44'/9000'/0'/0/0",
"0000000000000000000000000000000000000000000000000000000000000000"
);
};
const getVersion = async () => {
const lux = new Lux(await Transport.create());
return await lux.getAppConfiguration();
};
const getAddress = async () => {
const lux = new Lux(await Transport.create());
return await lux.getWalletPublicKey("44'/9000'/0'/1/0");
};
const doAll = async () => {
console.log(await getWalletId());
console.log(await getVersion());
console.log(await getAddress());
console.log(await signHash());
};
doAll().catch(err => console.log(err));
API
Table of Contents
Lux
Lux API for Ledger
Parameters
transportTransport<any>scrambleKeystring (optional, default"Lux")
Examples
import Lux from "@luxfi/hw-app-lux";
const lux = new Lux(transport);
getWalletPublicKey
Get Lux address for a given BIP-32 path.
Parameters
pathstring a path in BIP-32 format
Examples
const publicKey = await lux.getWalletPublicKey("44'/9000'/0'/0/0");
Returns Promise<string> an object with a public key.
signHash
Sign a 32-byte hash of transaction with a given BIP-32 path
Parameters
Examples
const signature = await lux.signHash("44'/9000'/0'/0/0", "0000000000000000000000000000000000000000000000000000000000000000");
Returns Promise<string> a signature as hex string.
getAppConfiguration
Get the version of the application installed on the hardware device.
Examples
console.log(await lux.getAppConfiguration());
produces something like
{
"version": "1.0.3",
"commit": "1234567",
"name": "Avax"
}
Returns Promise<{version: string, commit: string, name: string}> an object with a version.
getWalletId
Get the wallet identifier for the Ledger wallet. This value distinguishes different Ledger hardware devices which have different seeds.
Examples
console.log(await lux.getWalletId());
produces something like
abcdefgh