diff --git a/lib/expmt/stealth.js b/lib/expmt/stealth.js index c5fdaea3e..9fb48e100 100644 --- a/lib/expmt/stealth.js +++ b/lib/expmt/stealth.js @@ -6,12 +6,17 @@ var Hash = require('../hash'); var KDF = require('../kdf'); var base58check = require('../base58check'); -var Stealth = function Stealth(payloadKey, scanKey) { +var Stealth = function Stealth(obj) { if (!(this instanceof Stealth)) - return new Stealth(payloadKey, scanKey); + return new Stealth(obj); + if (obj) + this.set(obj); +}; - this.payloadKey = payloadKey; - this.scanKey = scanKey; +Stealth.prototype.set = function(obj) { + this.payloadKey = obj.payloadKey || this.payloadKey; + this.scanKey = obj.scanKey || this.scanKey; + return this; }; Stealth.prototype.fromAddressBuffer = function(buf) { diff --git a/test/test.stealth.js b/test/test.stealth.js index 6bacacdeb..138b16be9 100644 --- a/test/test.stealth.js +++ b/test/test.stealth.js @@ -36,6 +36,14 @@ describe('Stealth', function() { should.exist(stealth); }); + describe('#set', function() { + + it('should set payload key', function() { + should.exist(Stealth().set({payloadKey: stealth.payloadKey}).payloadKey); + }); + + }); + describe('#fromAddressBuffer', function() { it('should give a stealth address with the right pubkeys', function() {