Add API documentation
This commit is contained in:
@@ -4,13 +4,26 @@ import bs58 from 'bs58';
|
||||
import type {KeyPair} from 'tweetnacl';
|
||||
|
||||
/**
|
||||
* Base 58 encoded public key
|
||||
*
|
||||
* @typedef {string} PublicKey
|
||||
*/
|
||||
export type PublicKey = string;
|
||||
|
||||
/**
|
||||
* Represents an account key pair (public and secret keys).
|
||||
*/
|
||||
export class Account {
|
||||
_keypair: KeyPair;
|
||||
|
||||
/**
|
||||
* Create a new Account object
|
||||
*
|
||||
* If the secretKey parameter is not provided a new key pair is randomly
|
||||
* created for the account
|
||||
*
|
||||
* @param secretKey Secret key for the account
|
||||
*/
|
||||
constructor(secretKey: ?Buffer = null) {
|
||||
if (secretKey) {
|
||||
this._keypair = nacl.sign.keyPair.fromSecretKey(secretKey);
|
||||
@@ -19,10 +32,16 @@ export class Account {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The public key for this account
|
||||
*/
|
||||
get publicKey(): PublicKey {
|
||||
return bs58.encode(this._keypair.publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* The **unencrypted** secret key for this account
|
||||
*/
|
||||
get secretKey(): Buffer {
|
||||
return this._keypair.secretKey;
|
||||
}
|
||||
|
Reference in New Issue
Block a user