convenience: Stealth(payloadKeypair, scanKeypair)
This commit is contained in:
parent
073ee0a0e4
commit
258dab9d6d
@ -6,11 +6,20 @@ var Hash = require('../hash');
|
|||||||
var KDF = require('../kdf');
|
var KDF = require('../kdf');
|
||||||
var base58check = require('../base58check');
|
var base58check = require('../base58check');
|
||||||
|
|
||||||
var Stealthkey = function Stealthkey(obj) {
|
var Stealthkey = function Stealthkey(payloadKeypair, scanKeypair) {
|
||||||
if (!(this instanceof Stealthkey))
|
if (!(this instanceof Stealthkey))
|
||||||
return new Stealthkey(obj);
|
return new Stealthkey(payloadKeypair, scanKeypair);
|
||||||
if (obj)
|
|
||||||
|
if (payloadKeypair instanceof Keypair) {
|
||||||
|
this.set({
|
||||||
|
payloadKeypair: payloadKeypair,
|
||||||
|
scanKeypair: scanKeypair
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (payloadKeypair) {
|
||||||
|
var obj = payloadKeypair;
|
||||||
this.set(obj);
|
this.set(obj);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Stealthkey.prototype.set = function(obj) {
|
Stealthkey.prototype.set = function(obj) {
|
||||||
|
|||||||
@ -36,6 +36,14 @@ describe('Stealthkey', function() {
|
|||||||
should.exist(stealthkey);
|
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() {
|
describe('#set', function() {
|
||||||
|
|
||||||
it('should set payload key', function() {
|
it('should set payload key', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user