convenience: StealthAddress(str) or StealthAddress(buf)
This commit is contained in:
parent
36fd6b2d9c
commit
48ae69cab0
@ -2,12 +2,21 @@ var Stealthkey = require('./stealthkey');
|
|||||||
var Base58check = require('../base58check');
|
var Base58check = require('../base58check');
|
||||||
var Pubkey = require('../pubkey');
|
var Pubkey = require('../pubkey');
|
||||||
|
|
||||||
var StealthAddress = function StealthAddress(obj) {
|
var StealthAddress = function StealthAddress(addrstr) {
|
||||||
if (!(this instanceof StealthAddress))
|
if (!(this instanceof StealthAddress))
|
||||||
return new StealthAddress(obj);
|
return new StealthAddress(addrstr);
|
||||||
|
|
||||||
if (obj)
|
if (typeof addrstr === 'string') {
|
||||||
|
this.fromString(addrstr)
|
||||||
|
}
|
||||||
|
else if (Buffer.isBuffer(addrstr)) {
|
||||||
|
var buf = addrstr;
|
||||||
|
this.fromBuffer(buf);
|
||||||
|
}
|
||||||
|
else if (addrstr) {
|
||||||
|
var obj = addrstr;
|
||||||
this.set(obj);
|
this.set(obj);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StealthAddress.prototype.set = function(obj) {
|
StealthAddress.prototype.set = function(obj) {
|
||||||
|
|||||||
@ -32,6 +32,10 @@ describe('StealthAddress', function() {
|
|||||||
should.exist(sa);
|
should.exist(sa);
|
||||||
sa = StealthAddress();
|
sa = StealthAddress();
|
||||||
should.exist(sa);
|
should.exist(sa);
|
||||||
|
sa = StealthAddress(addressString);
|
||||||
|
should.exist(sa);
|
||||||
|
sa = StealthAddress(Base58check.decode(addressString));
|
||||||
|
should.exist(sa);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#fromBuffer', function() {
|
describe('#fromBuffer', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user