add address validation convenience function
This commit is contained in:
parent
f52e679f93
commit
6b7592d67b
|
@ -10,6 +10,12 @@ function Address(obj) {
|
|||
this.set(obj);
|
||||
};
|
||||
|
||||
Address.validate = function(addrstr) {
|
||||
var address = new Address().fromString(addrstr);
|
||||
address.validate();
|
||||
return this;
|
||||
};
|
||||
|
||||
Address.prototype.set = function(obj) {
|
||||
this.hashbuf = obj.hashbuf || this.hashbuf || null;
|
||||
this.networkstr = obj.networkstr || this.networkstr || 'mainnet';
|
||||
|
|
|
@ -12,6 +12,14 @@ describe('Address', function() {
|
|||
should.exist(address);
|
||||
});
|
||||
|
||||
describe('@validate', function() {
|
||||
|
||||
it('should validate this valid address string', function() {
|
||||
should.exist(Address.validate(str))
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#fromPubkey', function() {
|
||||
|
||||
it('should make this address from a compressed pubkey', function() {
|
||||
|
|
Loading…
Reference in New Issue