Browse Source

Merge pull request #432 from bitcoinjs/various

Various cleanup
hk-custom-address
Daniel Cousens 10 years ago
parent
commit
0c8c0e3f38
  1. 2
      src/ecsignature.js
  2. 1
      src/message.js
  3. 3
      src/networks.js
  4. 6
      src/transaction.js

2
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)),

1
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')

3
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,

6
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)

Loading…
Cancel
Save