@@ -362,23 +362,20 @@ Transaction.prototype.signWithKeys = function(keys, outputs, type) {
362362 * Signs a P2SH output at some index with the given key
363363 */
364364Transaction . prototype . p2shsign = function ( index , script , key , type ) {
365- script = new Script ( script )
366- key = new ECKey ( key )
367365 type = type || SIGHASH_ALL
368- var hash = this . hashTransactionForSignature ( script , index , type ) ,
369- sig = key . sign ( hash ) . concat ( [ type ] )
370- return sig
366+ var hash = this . hashTransactionForSignature ( script , index , type )
367+ return key . sign ( hash ) . concat ( [ type ] )
371368}
372369
373370Transaction . prototype . setScriptSig = function ( index , script ) {
374371 this . ins [ index ] . script = script
375372}
376373
377- Transaction . prototype . validateSig = function ( index , script , sig , pub ) {
378- script = new Script ( script )
379- var hash = this . hashTransactionForSignature ( script , index , 1 )
380- return ecdsa . verify ( hash , convert . coerceToBytes ( sig ) ,
381- convert . coerceToBytes ( pub ) )
374+ Transaction . prototype . validateSig = function ( index , script , pub , sig , type ) {
375+ type = type || SIGHASH_ALL
376+ var hash = this . hashTransactionForSignature ( script , index , type )
377+
378+ return pub . verify ( hash , sig )
382379}
383380
384381Transaction . feePerKb = 20000
0 commit comments