/**
* Retrieves an existing wallet from the database using its UUID.
*
- * @param {string} id - Entered by user when the wallet was initially created
+ * @param {string} id - Generated when the wallet was created or imported
* @returns {Wallet} Restored locked Wallet
*/
static restore (id: string): Promise<Wallet>
get mnemonic (): string | undefined
/** Set when calling `create()` and self-destructs after the first read. */
get seed (): string | undefined
- constructor (type: WalletType)
+ constructor (type: WalletType, id?: string)
/**
* Retrieves an account from a wallet using its child key derivation function.
* Defaults to the first account at index 0.
* @param {(Block)} block - Block data to be hashed and signed
* @returns {Promise<string>} Hexadecimal-formatted 64-byte signature
*/
- sign (index: number, block: Block): Promise<string>
+ sign (index: number, block: Block): Promise<Uint8Array<ArrayBuffer>>
+ /**
+ * Signs a block using the private key of the account at the wallet index
+ * specified. The signature is appended to the signature field of the block
+ * before being returned. The wallet must be unlocked prior to signing.
+ *
+ * @param {number} index - Account to use for signing
+ * @param {(Block)} block - Block data to be hashed and signed
+ * @returns {Promise<string>} Hexadecimal-formatted 64-byte signature
+ */
+ sign (index: number, block: Block, format: 'hex'): Promise<string>
/**
* Unlocks the wallet using the same password as used prior to lock it.
*
get status (): DeviceStatus
private constructor ()
/**
+ * Gets the public key for an account from the Ledger device.
+ *
+ * @param {number[]} indexes - Indexes of the accounts
+ * @returns {Promise<Account>}
+ */
+ account (index: number): Promise<Account>
+ /**
+ * Retrieves accounts from a wallet using its child key derivation function.
+ * Defaults to the first account at index 0.
+ *
+ * The returned object will have keys corresponding with the requested range
+ * of account indexes. The value of each key will be the Account derived for
+ * that index in the wallet.
+ *
+ * ```
+ * console.log(await wallet.accounts(5))
+ * // outputs sixth account of the wallet
+ * // {
+ * // 5: {
+ * // privateKey: <...>,
+ * // index: 5
+ * // }
+ * // }
+ * ```
+ *
+ * @param {number} from - Start index of secret keys. Default: 0
+ * @param {number} to - End index of secret keys. Default: `from`
+ * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts
+ */
+ accounts (from?: number, to?: number): Promise<AccountList>
+ /**
* Check if the Nano app is currently open and set device status accordingly.
*
* @returns Device status as follows:
* Sign a block with the Ledger device.
*
* @param {number} index - Account number
- * @param {Block} block - Block data to sign
+ * @param {object} block - Block data to sign
* @returns {Promise<string>} Signature
*/
- sign (index: number, block: Block, frontier?: Block): Promise<string>
+ sign (index: number, block: Block): Promise<Uint8Array<ArrayBuffer>>
+ /**
+ * Sign a block with the Ledger device.
+ *
+ * @param {number} index - Account number
+ * @param {object} block - Block data to sign
+ * @returns {Promise<string>} Signature
+ */
+ sign (index: number, block: Block, format?: 'hex', frontier?: Block): Promise<string>
/**
* Attempts to connect to the Ledger device.
*
* Update cache from raw block data. Suitable for offline use.
*
* @param {number} index - Account number
- * @param {Block} block - JSON-formatted block data
+ * @param {object} block - JSON-formatted block data
*/
updateCache (index: number, block: Block): Promise<LedgerResponse>
/**
* @returns Status, process name, and version
*/
version (): Promise<LedgerVersionResponse>
- /**
- * Gets the public key for an account from the Ledger device.
- *
- * @param {number[]} indexes - Indexes of the accounts
- * @returns {Promise<Account>}
- */
- ckd (indexes: number[]): Promise<KeyPair[]>
}
/**