Renames p2shsign to signScriptSig

This commit is contained in:
Daniel Cousens 2014-04-26 03:50:41 +10:00
parent fbf8211cab
commit 8ad8f6f169
2 changed files with 9 additions and 12 deletions

View file

@ -312,15 +312,15 @@ Transaction.deserialize = function(buffer) {
*/
Transaction.prototype.sign = function(index, key, type, network) {
assert(key instanceof ECKey)
type = type || SIGHASH_ALL
network = network || Network.bitcoin
var address = key.pub.getAddress(network.pubKeyHash)
var script = Script.createOutputScript(address, network)
var hash = this.hashTransactionForSignature(script, index, type)
var sig = key.sign(hash).concat([type])
var scriptSig = Script.createInputScript(sig, key.pub)
// FIXME: Assumed prior TX was pay-to-pubkey-hash
var script = Script.createOutputScript(address, network)
var signature = this.signScriptSig(index, script, key, type)
var scriptSig = Script.createInputScript(signature, key.pub)
this.setScriptSig(index, scriptSig)
}
@ -358,10 +358,7 @@ Transaction.prototype.signWithKeys = function(keys, outputs, type) {
}
}
/**
* Signs a P2SH output at some index with the given key
*/
Transaction.prototype.p2shsign = function(index, script, key, type) {
Transaction.prototype.signScriptSig = function(index, script, key, type) {
type = type || SIGHASH_ALL
var hash = this.hashTransactionForSignature(script, index, type)
return key.sign(hash).concat([type])

View file

@ -221,7 +221,7 @@ describe('Transaction', function() {
})
})
describe('p2shsign', function() {
describe('signScriptSig', function() {
var tx = new Transaction()
tx.addInput('deadbeefcafe', 0)
tx.addOutput('mrCDrCybB6J1vRfbwM5hemdJz73FwDBC8r', 1, network.testnet)
@ -236,8 +236,8 @@ describe('Transaction', function() {
var pubKeyBuffers = pubKeys.map(function(q) { return q.toBuffer() })
var redeemScript = Script.createMultisigOutputScript(2, pubKeyBuffers)
var signatures = privKeys.map(function(eck) {
return tx.p2shsign(0, redeemScript, eck)
var signatures = privKeys.map(function(privKey) {
return tx.signScriptSig(0, redeemScript, privKey)
})
var scriptSig = Script.createP2SHMultisigScriptSig(signatures, redeemScript)