From a17208a549f4bfc014b96a5f2bbd83162983cae9 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sun, 15 Jun 2014 01:08:52 +1000 Subject: [PATCH] Transaction: rename key to privKey and standardize type check --- src/transaction.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index 8132bd2..f780df9 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -287,21 +287,21 @@ Transaction.fromHex = function(hex) { /** * Signs a pubKeyHash output at some index with the given key */ -Transaction.prototype.sign = function(index, key, hashType) { - var prevOutScript = key.pub.getAddress().toOutputScript() - var signature = this.signInput(index, prevOutScript, key, hashType) +Transaction.prototype.sign = function(index, privKey, hashType) { + var prevOutScript = privKey.pub.getAddress().toOutputScript() + var signature = this.signInput(index, prevOutScript, privKey, hashType) // FIXME: Assumed prior TX was pay-to-pubkey-hash - var scriptSig = scripts.pubKeyHashInput(signature, key.pub) + var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub) this.setInputScript(index, scriptSig) } -Transaction.prototype.signInput = function(index, prevOutScript, key, hashType) { +Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) { hashType = hashType || SIGHASH_ALL - assert(key instanceof ECKey, 'Invalid private key') + assert(privKey instanceof ECKey, 'Expected ECKey, got ' + privKey) var hash = this.hashForSignature(prevOutScript, index, hashType) - var signature = key.sign(hash) + var signature = privKey.sign(hash) var DERencoded = ecdsa.serializeSig(signature) return Buffer.concat([