Stealth.prototype.set

This commit is contained in:
Ryan X. Charles 2014-08-28 17:00:34 -07:00
parent 0ca390d45b
commit 6b4bc4c49c
2 changed files with 17 additions and 4 deletions

View File

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

View File

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