convenience: Stealth(payloadKeypair, scanKeypair)

This commit is contained in:
Ryan X. Charles 2014-09-02 12:08:33 -07:00
parent 073ee0a0e4
commit 258dab9d6d
2 changed files with 20 additions and 3 deletions

View File

@ -6,11 +6,20 @@ var Hash = require('../hash');
var KDF = require('../kdf');
var base58check = require('../base58check');
var Stealthkey = function Stealthkey(obj) {
var Stealthkey = function Stealthkey(payloadKeypair, scanKeypair) {
if (!(this instanceof Stealthkey))
return new Stealthkey(obj);
if (obj)
return new Stealthkey(payloadKeypair, scanKeypair);
if (payloadKeypair instanceof Keypair) {
this.set({
payloadKeypair: payloadKeypair,
scanKeypair: scanKeypair
});
}
else if (payloadKeypair) {
var obj = payloadKeypair;
this.set(obj);
}
};
Stealthkey.prototype.set = function(obj) {

View File

@ -36,6 +36,14 @@ describe('Stealthkey', function() {
should.exist(stealthkey);
});
it('should create a new stealthkey with both keypairs in the constructor', function() {
var keypair1 = Keypair();
var keypair2 = Keypair();
var stealthkey = Stealthkey(keypair1, keypair2);
should.exist(stealthkey.payloadKeypair);
should.exist(stealthkey.scanKeypair);
});
describe('#set', function() {
it('should set payload key', function() {