stealth address to/from JSON

This commit is contained in:
Ryan X. Charles 2014-09-22 12:48:13 -07:00
parent 27fbdb42ad
commit 1bda566679
2 changed files with 28 additions and 0 deletions

View File

@ -26,6 +26,15 @@ StealthAddress.prototype.set = function(obj) {
return this;
};
StealthAddress.prototype.fromJSON = function(json) {
this.fromString(json);
return this;
};
StealthAddress.prototype.toJSON = function() {
return this.toString();
};
StealthAddress.prototype.fromStealthkey = function(stealthkey) {
this.set({
payloadPubkey: stealthkey.payloadKeypair.pubkey,

View File

@ -38,6 +38,25 @@ describe('StealthAddress', function() {
should.exist(sa);
});
describe('#fromJSON', function() {
it('should give a stealthkey address with the right pubkeys', function() {
var sa = new StealthAddress();
sa.fromJSON(addressString);
sa.payloadPubkey.toString().should.equal(stealthkey.payloadKeypair.pubkey.toString());
sa.scanPubkey.toString().should.equal(stealthkey.scanKeypair.pubkey.toString());
});
});
describe('#toJSON', function() {
it('should return this known address string', function() {
StealthAddress().fromJSON(addressString).toJSON().should.equal(addressString);
});
});
describe('#fromBuffer', function() {
it('should give a stealthkey address with the right pubkeys', function() {