ledger-stellar-sdk
Version:
Ledger Hardware Wallet Stellar JavaScript bindings.
91 lines • 3.52 kB
TypeScript
/// <reference types="node" />
import type Transport from "@ledgerhq/hw-transport";
/**
* @typedef {object} Signature
* @property {Buffer} signature - The signature
*/
/**
* @typedef {object} PublicKey
* @property {string} publicKey - Encoded public key
* @property {Buffer} rawPublicKey - Raw public key
*/
/**
* @typedef {object} AppConfiguration
* @property {string} version - The version of the Stellar app installed on the device
* @property {boolean} hashSigningEnabled - Whether hash signing is enabled
*/
/**
* Ledger Hardware Wallet Stellar JavaScript bindings.
*/
export default class Stellar {
private transport;
/**
* @param {Transport} transport - The Ledger transport to use
* @param {string} [scrambleKey=w0w] - A string that will be used to scramble the device communication
* @example
* ```typescript
* import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
* import LedgerStellarApi from "ledger-stellar-sdk";
*
* const transport = await TransportWebUSB.create();
* const stellar = new LedgerStellarApi(transport);
* ```
*/
constructor(transport: Transport, scrambleKey?: string);
/**
* Get Stellar public key for a given account index.
*
* @param {number} accountIndex - It is part of key derivation path: `m/44'/148'/accountIndex'`
* @param {boolean} [display=false] - If set to "true", the public key will be displayed on the Ledger device and the user will be asked to confirm, otherwise it will not
* @returns {PublicKey} an object with a publicKey and rawPublicKey.
* @example
* ```typescript
* const response = stellar.getPublicKey(0, true)
* ```
*/
getPublicKey(accountIndex: number, display?: boolean): Promise<{
publicKey: string;
rawPublicKey: Buffer;
}>;
/**
* Sign the given transaction.
*
* @param {number} accountIndex - It is part of key derivation path: `m/44'/148'/accountIndex'`
* @param {Buffer} transaction - The transaction to sign. It consists of network id and transaction envelope, if you are using `stellar-sdk`, you can use `transaction.signatureBase()` to get the value
* @returns {Signature} the signature
*/
signTransaction(accountIndex: number, transaction: Buffer): Promise<{
signature: Buffer;
}>;
/**
* Sign the given hash.
*
* It is intended for signing transactions not supported by the Ledger Stellar
* app and should be avoided as much as possible.
*
* @param {number} accountIndex - It is part of key derivation path: `m/44'/148'/accountIndex'`
* @param {string|Buffer} hash - The hash to sign
* @returns {Signature} the signature
* @example
* ```typescript
* const response = stellar.signHash(0, "4b480b455a7ee154c33651819e3ce2ceb6bcd9dda78887777c4d2718c5cd04cd")
* ```
*/
signHash(accountIndex: number, hash: Buffer | string): Promise<{
signature: Buffer;
}>;
/**
* Get the configuration of the Ledger Stellar app installed on the hardware device.
*
* @returns {AppConfiguration} an object with the version and the flag to indicate whether hash signing is enabled
* @example
* ```typescript
* const response = await stellar.getAppConfiguration();
* ```
*/
getAppConfiguration(): Promise<{
readonly version: string;
readonly hashSigningEnabled: boolean;
}>;
}
//# sourceMappingURL=index.d.ts.map