stealth address to/from JSON
This commit is contained in:
parent
27fbdb42ad
commit
1bda566679
@ -26,6 +26,15 @@ StealthAddress.prototype.set = function(obj) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StealthAddress.prototype.fromJSON = function(json) {
|
||||||
|
this.fromString(json);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
StealthAddress.prototype.toJSON = function() {
|
||||||
|
return this.toString();
|
||||||
|
};
|
||||||
|
|
||||||
StealthAddress.prototype.fromStealthkey = function(stealthkey) {
|
StealthAddress.prototype.fromStealthkey = function(stealthkey) {
|
||||||
this.set({
|
this.set({
|
||||||
payloadPubkey: stealthkey.payloadKeypair.pubkey,
|
payloadPubkey: stealthkey.payloadKeypair.pubkey,
|
||||||
|
|||||||
@ -38,6 +38,25 @@ describe('StealthAddress', function() {
|
|||||||
should.exist(sa);
|
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() {
|
describe('#fromBuffer', function() {
|
||||||
|
|
||||||
it('should give a stealthkey address with the right pubkeys', function() {
|
it('should give a stealthkey address with the right pubkeys', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user