p2sh -> scripthash

more appealing and memorable name
This commit is contained in:
Ryan X. Charles 2014-09-01 12:06:18 -07:00
parent a0150f82ef
commit 6a26813955
3 changed files with 13 additions and 13 deletions

View File

@ -32,15 +32,15 @@ Address.prototype.fromString = function(str) {
if (version === constants['mainnet']['pubkeyhash']) {
this.networkstr = 'mainnet';
this.typestr = 'pubkeyhash';
} else if (version === constants['mainnet']['p2sh']) {
} else if (version === constants['mainnet']['scripthash']) {
this.networkstr = 'mainnet';
this.typestr = 'p2sh';
this.typestr = 'scripthash';
} else if (version === constants['testnet']['pubkeyhash']) {
this.networkstr = 'testnet';
this.typestr = 'pubkeyhash';
} else if (version === constants['testnet']['p2sh']) {
} else if (version === constants['testnet']['scripthash']) {
this.networkstr = 'testnet';
this.typestr = 'p2sh';
this.typestr = 'scripthash';
} else {
this.networkstr = 'unknown';
this.typestr = 'unknown';
@ -84,8 +84,8 @@ Address.prototype.validate = function() {
throw new Error('hash must be a buffer of 20 bytes');
if (this.networkstr !== 'mainnet' && this.networkstr !== 'testnet')
throw new Error('networkstr must be "mainnet" or "testnet"');
if (this.typestr !== 'pubkeyhash' && this.typestr !== 'p2sh')
throw new Error('typestr must be "pubkeyhash" or "p2sh"');
if (this.typestr !== 'pubkeyhash' && this.typestr !== 'scripthash')
throw new Error('typestr must be "pubkeyhash" or "scripthash"');
return this;
};

View File

@ -1,7 +1,7 @@
exports.mainnet = {
pubkeyhash: 0x00,
privkey: 0x80,
p2sh: 0x05,
scripthash: 0x05,
bip32pubkey: 0x0488b21e,
bip32privkey: 0x0488ade4,
};
@ -9,7 +9,7 @@ exports.mainnet = {
exports.testnet = {
pubkeyhash: 0x6f,
privkey: 0xef,
p2sh: 0xc4,
scripthash: 0xc4,
bip32pubkey: 0x043587cf,
bip32privkey: 0x04358394,
};

View File

@ -61,20 +61,20 @@ describe('Address', function() {
address.toString().should.equal('mm1X5M2QWyHVjn7txrF7mmtZDpjCXzoa98');
});
it('should derive from this known address string mainnet p2sh', function() {
it('should derive from this known address string mainnet scripthash', function() {
var address = new Address();
address.fromString(str);
address.networkstr = 'mainnet';
address.typestr = 'p2sh';
address.typestr = 'scripthash';
address.fromString(address.toString());
address.toString().should.equal('37BahqRsFrAd3qLiNNwLNV3AWMRD7itxTo');
});
it('should derive from this known address string testnet p2sh', function() {
it('should derive from this known address string testnet scripthash', function() {
var address = new Address();
address.fromString(str);
address.networkstr = 'testnet';
address.typestr = 'p2sh';
address.typestr = 'scripthash';
address.fromString(address.toString());
address.toString().should.equal('2MxjnmaMtsJfyFcyG3WZCzS2RihdNuWqeX4');
});
@ -148,7 +148,7 @@ describe('Address', function() {
address.typestr = 'unknown';
(function() {
address.validate();
}).should.throw('typestr must be "pubkeyhash" or "p2sh"');
}).should.throw('typestr must be "pubkeyhash" or "scripthash"');
});
});