@@ -312,15 +312,15 @@ Transaction.deserialize = function(buffer) {
312312 */
313313Transaction . 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 ] )
0 commit comments