Skip to content

Commit

Permalink
add to wallet.md and wallet.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shancht committed Jan 13, 2023
1 parent 3aeeb67 commit a2c61fb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/node/CATEGORIES/05-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,26 @@ interface wallet {
signMessage (address: string, message: string): Promise<string>
}
```
## encryptWallet

Encrypts the wallet for the first time using a custom ‘passphrase’. Transactions related to private keys will thereafter require a passphrase before execution.

To unlock the wallet, use [walletPassphrase](#walletPassphrase)

```ts title="client.wallet.encryptWallet()"
interface wallet {
encryptWallet (passphrase: string): Promise<string>
}
```

## walletPassphrase

Stores the wallet decryption key in memory for ‘timeout’ seconds. Calling `walletPassphrase` when wallet is unlocked will set a new unlock time that overrides the old setting.

To encrypt the wallet for the first time, use use [encryptWallet](#encryptWallet)

```ts title="client.wallet.walletPassphrase()"
interface wallet {
walletPassphrase (passphrase: string, timeout: number): Promise<string>
}
```
24 changes: 24 additions & 0 deletions packages/jellyfish-api-core/src/category/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,30 @@ export class Wallet {
async signMessage (address: string, message: string): Promise<string> {
return await this.client.call('signmessage', [address, message], 'number')
}

/**
* Encrypts the wallet for the first time using a custom ‘passphrase’.
* Transactions related to private keys will thereafter require a passphrase before execution.
* To unlock wallet, use 'walletpassphrase'
*
* @param {string} passphrase The wallet passphrase. Must be at least 1 character, but should be long.
* @return {Promise<string>}
*/
async encryptWallet (passphrase: string): Promise<string> {
return await this.client.call('encryptwallet', [passphrase], 'number')
}

/**
* Stores the wallet decryption key in memory for ‘timeout’ seconds.
* Calling 'walletpassphrase' when wallet is unlocked will set a new unlock time that overrides the old setting.
*
* @param {string} passphrase The wallet passphrase. Must be at least 1 character, but should be long.
* @param {number} timeout The time to keep the decryption key in seconds; capped at 100000000 (~3 years).
* @return {Promise<>}
*/
async walletPassphrase (passphrase: string, timeout: number): Promise<string> {
return await this.client.call('walletpassphrase', [passphrase, timeout], 'number')
}
}

export interface UTXO {
Expand Down

0 comments on commit a2c61fb

Please sign in to comment.