network: always use lowercase
This commit is contained in:
parent
b68b1d5da4
commit
553ade1208
8 changed files with 26 additions and 26 deletions
|
@ -11,7 +11,7 @@ function findScriptTypeByVersion(queryVersion) {
|
|||
var version = network[versionName]
|
||||
|
||||
if (version === queryVersion) {
|
||||
return versionName.toLowerCase()
|
||||
return versionName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ Address.fromOutputScript = function(script, network) {
|
|||
var type = scripts.classifyOutput(script)
|
||||
|
||||
if (type === 'pubkeyhash') {
|
||||
return new Address(script.chunks[2], network.pubKeyHash)
|
||||
return new Address(script.chunks[2], network.pubkeyhash)
|
||||
|
||||
} else if (type === 'scripthash') {
|
||||
return new Address(script.chunks[1], network.scriptHash)
|
||||
return new Address(script.chunks[1], network.scripthash)
|
||||
}
|
||||
|
||||
assert(false, type + ' has no matching Address')
|
||||
|
|
|
@ -32,7 +32,7 @@ ECPubKey.fromHex = function(hex) {
|
|||
ECPubKey.prototype.getAddress = function(network) {
|
||||
network = network || networks.bitcoin
|
||||
|
||||
return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
|
||||
return new Address(crypto.hash160(this.toBuffer()), network.pubkeyhash)
|
||||
}
|
||||
|
||||
ECPubKey.prototype.verify = function(hash, signature) {
|
||||
|
|
|
@ -13,7 +13,7 @@ var ecurve = require('ecurve')
|
|||
var ecparams = ecurve.getCurveByName('secp256k1')
|
||||
|
||||
function magicHash(message, network) {
|
||||
var magicPrefix = new Buffer(network.magicPrefix)
|
||||
var magicPrefix = new Buffer(network.magicprefix)
|
||||
var messageBuffer = new Buffer(message)
|
||||
var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
|
||||
bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0)
|
||||
|
|
|
@ -2,43 +2,43 @@
|
|||
// Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
|
||||
module.exports = {
|
||||
bitcoin: {
|
||||
magicPrefix: '\x18Bitcoin Signed Message:\n',
|
||||
magicprefix: '\x18Bitcoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
pubkeyhash: 0x00,
|
||||
scripthash: 0x05,
|
||||
wif: 0x80
|
||||
},
|
||||
dogecoin: {
|
||||
magicPrefix: '\x19Dogecoin Signed Message:\n',
|
||||
magicprefix: '\x19Dogecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x02facafd,
|
||||
private: 0x02fac398
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x16,
|
||||
pubkeyhash: 0x1e,
|
||||
scripthash: 0x16,
|
||||
wif: 0x9e
|
||||
},
|
||||
litecoin: {
|
||||
magicPrefix: '\x19Litecoin Signed Message:\n',
|
||||
magicprefix: '\x19Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x019da462,
|
||||
private: 0x019d9cfe
|
||||
},
|
||||
pubKeyHash: 0x30,
|
||||
scriptHash: 0x05,
|
||||
pubkeyhash: 0x30,
|
||||
scripthash: 0x05,
|
||||
wif: 0xb0
|
||||
},
|
||||
testnet: {
|
||||
magicPrefix: '\x18Bitcoin Signed Message:\n',
|
||||
magicprefix: '\x18Bitcoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
pubkeyhash: 0x6f,
|
||||
scripthash: 0xc4,
|
||||
wif: 0xef
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ describe('Bitcoin-core', function() {
|
|||
|
||||
assert.equal(address.hash.toString('hex'), hex)
|
||||
if (params.addrType === 'pubkey') {
|
||||
assert.equal(address.version, network.pubKeyHash)
|
||||
assert.equal(address.version, network.pubkeyhash)
|
||||
|
||||
} else if (params.addrType === 'script') {
|
||||
assert.equal(address.version, network.scriptHash)
|
||||
assert.equal(address.version, network.scripthash)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -68,10 +68,10 @@ describe('Bitcoin-core', function() {
|
|||
// base58_keys_invalid
|
||||
describe('Address', function() {
|
||||
var allowedNetworks = [
|
||||
networks.bitcoin.pubKeyHash,
|
||||
networks.bitcoin.scriptHash,
|
||||
networks.testnet.pubKeyHash,
|
||||
networks.testnet.scriptHash
|
||||
networks.bitcoin.pubkeyhash,
|
||||
networks.bitcoin.scripthash,
|
||||
networks.testnet.pubkeyhash,
|
||||
networks.testnet.scripthash
|
||||
]
|
||||
|
||||
base58_keys_invalid.forEach(function(f) {
|
||||
|
|
|
@ -72,7 +72,7 @@ describe('ECPubKey', function() {
|
|||
var pubKey = new ECPubKey(Q)
|
||||
var address = pubKey.getAddress(networks.testnet)
|
||||
|
||||
assert.equal(address.version, networks.testnet.pubKeyHash)
|
||||
assert.equal(address.version, networks.testnet.pubkeyhash)
|
||||
assert.equal(address.hash.toString('hex'), fixtures.compressed.hash160)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -204,7 +204,7 @@ describe('HDNode', function() {
|
|||
var hd = HDNode.fromBase58(f.master.base58)
|
||||
hd.network = networks.testnet
|
||||
|
||||
assert.equal(hd.getAddress().version, networks.testnet.pubKeyHash)
|
||||
assert.equal(hd.getAddress().version, networks.testnet.pubkeyhash)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ describe('Scripts', function() {
|
|||
var redeemScript = scripts.multisigOutput(2, pubKeys)
|
||||
|
||||
var hash160 = crypto.hash160(new Buffer(redeemScript.buffer))
|
||||
var multisigAddress = new Address(hash160, networks.bitcoin.scriptHash)
|
||||
var multisigAddress = new Address(hash160, networks.bitcoin.scripthash)
|
||||
|
||||
assert.equal(multisigAddress.toString(), '32vYjxBb7pHJJyXgNk8UoK3BdRDxBzny2v')
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue