solana/web3.js/src/account.js

22 lines
429 B
JavaScript
Raw Normal View History

2018-08-22 17:03:50 -07:00
import nacl from 'tweetnacl';
import bs58 from 'bs58';
export class Account {
constructor(secretKey: ?Buffer = null) {
if (secretKey) {
this._keypair = nacl.sign.keyPair.fromSecretKey(secretKey);
} else {
this._keypair = nacl.sign.keyPair();
}
}
get publicKey(): string {
return bs58.encode(this._keypair.publicKey);
}
get secretKey(): string {
return this._keypair.secretKey;
}
}