Browse Source

convenience: Stealth(payloadKeypair, scanKeypair)

patch-2
Ryan X. Charles 10 years ago
parent
commit
258dab9d6d
  1. 15
      lib/expmt/stealthkey.js
  2. 8
      test/stealthkey.js

15
lib/expmt/stealthkey.js

@ -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) {

8
test/stealthkey.js

@ -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() {

Loading…
Cancel
Save