From 6a26813955c8d687581388b8eef325bd249610c2 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Mon, 1 Sep 2014 12:06:18 -0700 Subject: [PATCH] p2sh -> scripthash more appealing and memorable name --- lib/address.js | 12 ++++++------ lib/constants.js | 4 ++-- test/address.js | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/address.js b/lib/address.js index 61399ad..43912c0 100644 --- a/lib/address.js +++ b/lib/address.js @@ -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; }; diff --git a/lib/constants.js b/lib/constants.js index 6191987..c64494d 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -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, }; diff --git a/test/address.js b/test/address.js index e18cf49..44dde17 100644 --- a/test/address.js +++ b/test/address.js @@ -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"'); }); });