From 6fbdecc39dbf8371dba977f80cc6c637aa31afaa Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 11 Aug 2015 16:38:57 +1000 Subject: [PATCH 1/4] networks: remove pchMessageStart chain parameter --- src/networks.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/networks.js b/src/networks.js index d694bf7..60690ff 100644 --- a/src/networks.js +++ b/src/networks.js @@ -3,7 +3,6 @@ module.exports = { bitcoin: { - magic: 0xd9b4bef9, messagePrefix: '\x18Bitcoin Signed Message:\n', bip32: { public: 0x0488b21e, @@ -15,7 +14,6 @@ module.exports = { dustThreshold: 546 // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162 }, testnet: { - magic: 0xd9b4bef9, messagePrefix: '\x18Bitcoin Signed Message:\n', bip32: { public: 0x043587cf, @@ -27,7 +25,6 @@ module.exports = { dustThreshold: 546 }, litecoin: { - magic: 0xd9b4bef9, messagePrefix: '\x19Litecoin Signed Message:\n', bip32: { public: 0x019da462, From 9d1c610c08809272f50d0d8753cb618b91518d6e Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 10 Aug 2015 19:12:42 +1000 Subject: [PATCH 2/4] Transaction: capitalize Buffer constants --- src/transaction.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index 63705fa..95cd2be 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -177,7 +177,7 @@ Transaction.prototype.clone = function () { return newTx } -var one = new Buffer('0000000000000000000000000000000000000000000000000000000000000001', 'hex') +var ONE = new Buffer('0000000000000000000000000000000000000000000000000000000000000001', 'hex') /** * Hash transaction for signing a specific input. @@ -195,7 +195,7 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT assert(inIndex >= 0, 'Invalid vin index') // https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L29 - if (inIndex >= this.ins.length) return one + if (inIndex >= this.ins.length) return ONE var txTmp = this.clone() @@ -225,7 +225,7 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT // only lock-in the txOut payee at same index as txIn // https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L60 - if (nOut >= this.outs.length) return one + if (nOut >= this.outs.length) return ONE txTmp.outs = txTmp.outs.slice(0, nOut + 1) From 64657eb81fad66f89487f23bca0de3dd91cc499b Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 7 Aug 2015 16:12:17 +1000 Subject: [PATCH 3/4] ECSignature: further avoidance of assert --- src/ecsignature.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ecsignature.js b/src/ecsignature.js index cbf9f81..151e962 100644 --- a/src/ecsignature.js +++ b/src/ecsignature.js @@ -71,7 +71,7 @@ ECSignature.parseScriptSignature = function (buffer) { var hashType = buffer.readUInt8(buffer.length - 1) var hashTypeMod = hashType & ~0x80 - assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType ' + hashType) + if (hashTypeMod <= 0x00 || hashTypeMod >= 0x04) throw new Error('Invalid hashType ' + hashType) return { signature: ECSignature.fromDER(buffer.slice(0, -1)), From 47364293a9f38aecf89bfab41bb01f781fd6a458 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 11 Aug 2015 16:13:40 +1000 Subject: [PATCH 4/4] message: remove old TODO --- src/message.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/message.js b/src/message.js index b2c584c..75a3e2e 100644 --- a/src/message.js +++ b/src/message.js @@ -30,7 +30,6 @@ function sign (keyPair, message, network) { return signature.toCompact(i, keyPair.compressed) } -// TODO: network could be implied from address function verify (address, signature, message, network) { if (!Buffer.isBuffer(signature)) { signature = new Buffer(signature, 'base64')