From 6b4bc4c49c243a32bd6b360b41d025e94122b5bc Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Thu, 28 Aug 2014 17:00:34 -0700 Subject: [PATCH] Stealth.prototype.set --- lib/expmt/stealth.js | 13 +++++++++---- test/test.stealth.js | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) 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() {