Skip to content

Commit 8ad8f6f

Browse files
committed
Renames p2shsign to signScriptSig
1 parent fbf8211 commit 8ad8f6f

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/transaction.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,15 @@ Transaction.deserialize = function(buffer) {
312312
*/
313313
Transaction.prototype.sign = function(index, key, type, network) {
314314
assert(key instanceof ECKey)
315-
type = type || SIGHASH_ALL
316315
network = network || Network.bitcoin
317316

318317
var address = key.pub.getAddress(network.pubKeyHash)
318+
319+
// FIXME: Assumed prior TX was pay-to-pubkey-hash
319320
var script = Script.createOutputScript(address, network)
320-
var hash = this.hashTransactionForSignature(script, index, type)
321-
var sig = key.sign(hash).concat([type])
322-
var scriptSig = Script.createInputScript(sig, key.pub)
321+
var signature = this.signScriptSig(index, script, key, type)
323322

323+
var scriptSig = Script.createInputScript(signature, key.pub)
324324
this.setScriptSig(index, scriptSig)
325325
}
326326

@@ -358,10 +358,7 @@ Transaction.prototype.signWithKeys = function(keys, outputs, type) {
358358
}
359359
}
360360

361-
/**
362-
* Signs a P2SH output at some index with the given key
363-
*/
364-
Transaction.prototype.p2shsign = function(index, script, key, type) {
361+
Transaction.prototype.signScriptSig = function(index, script, key, type) {
365362
type = type || SIGHASH_ALL
366363
var hash = this.hashTransactionForSignature(script, index, type)
367364
return key.sign(hash).concat([type])

test/transaction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe('Transaction', function() {
221221
})
222222
})
223223

224-
describe('p2shsign', function() {
224+
describe('signScriptSig', function() {
225225
var tx = new Transaction()
226226
tx.addInput('deadbeefcafe', 0)
227227
tx.addOutput('mrCDrCybB6J1vRfbwM5hemdJz73FwDBC8r', 1, network.testnet)
@@ -236,8 +236,8 @@ describe('Transaction', function() {
236236
var pubKeyBuffers = pubKeys.map(function(q) { return q.toBuffer() })
237237
var redeemScript = Script.createMultisigOutputScript(2, pubKeyBuffers)
238238

239-
var signatures = privKeys.map(function(eck) {
240-
return tx.p2shsign(0, redeemScript, eck)
239+
var signatures = privKeys.map(function(privKey) {
240+
return tx.signScriptSig(0, redeemScript, privKey)
241241
})
242242

243243
var scriptSig = Script.createP2SHMultisigScriptSig(signatures, redeemScript)

0 commit comments

Comments
 (0)