add address validation convenience function

This commit is contained in:
Ryan X. Charles 2014-08-28 15:22:03 -07:00
parent f52e679f93
commit 6b7592d67b
2 changed files with 14 additions and 0 deletions

View File

@ -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';

View File

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