@@ -3,7 +3,7 @@ var bcrypto = require('./crypto')
33var bufferutils = require ( './bufferutils' )
44var networks = require ( './networks' )
55var ops = require ( './opcodes' )
6- var scripts = require ( './scripts ' )
6+ var script = require ( './script ' )
77
88var ECPair = require ( './ecpair' )
99var ECSignature = require ( './ecsignature' )
@@ -12,29 +12,29 @@ var Transaction = require('./transaction')
1212function extractInput ( txIn ) {
1313 var redeemScript
1414 var scriptSig = txIn . script
15- var scriptSigChunks = scripts . decompile ( scriptSig )
15+ var scriptSigChunks = script . decompile ( scriptSig )
1616
1717 var prevOutScript
18- var prevOutType = scripts . classifyInput ( scriptSig , true )
18+ var prevOutType = script . classifyInput ( scriptSig , true )
1919 var scriptType
2020
2121 // Re-classify if scriptHash
2222 if ( prevOutType === 'scripthash' ) {
2323 redeemScript = scriptSigChunks . slice ( - 1 ) [ 0 ]
24- prevOutScript = scripts . scriptHashOutput ( bcrypto . hash160 ( redeemScript ) )
24+ prevOutScript = script . scriptHashOutput ( bcrypto . hash160 ( redeemScript ) )
2525
26- scriptSig = scripts . compile ( scriptSigChunks . slice ( 0 , - 1 ) )
26+ scriptSig = script . compile ( scriptSigChunks . slice ( 0 , - 1 ) )
2727 scriptSigChunks = scriptSigChunks . slice ( 0 , - 1 )
2828
29- scriptType = scripts . classifyInput ( scriptSig , true )
29+ scriptType = script . classifyInput ( scriptSig , true )
3030 } else {
3131 scriptType = prevOutType
3232 }
3333
3434 // pre-empt redeemScript decompilation
3535 var redeemScriptChunks
3636 if ( redeemScript ) {
37- redeemScriptChunks = scripts . decompile ( redeemScript )
37+ redeemScriptChunks = script . decompile ( redeemScript )
3838 }
3939
4040 // Extract hashType, pubKeys and signatures
@@ -46,7 +46,7 @@ function extractInput (txIn) {
4646 hashType = parsed . hashType
4747 pubKeys = scriptSigChunks . slice ( 1 )
4848 signatures = [ parsed . signature ]
49- prevOutScript = scripts . pubKeyHashOutput ( bcrypto . hash160 ( pubKeys [ 0 ] ) )
49+ prevOutScript = script . pubKeyHashOutput ( bcrypto . hash160 ( pubKeys [ 0 ] ) )
5050
5151 break
5252
@@ -147,8 +147,8 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu
147147
148148 var input = { }
149149 if ( prevOutScript ) {
150- var prevOutScriptChunks = scripts . decompile ( prevOutScript )
151- var prevOutType = scripts . classifyOutput ( prevOutScriptChunks )
150+ var prevOutScriptChunks = script . decompile ( prevOutScript )
151+ var prevOutType = script . classifyOutput ( prevOutScriptChunks )
152152
153153 // if we can, extract pubKey information
154154 switch ( prevOutType ) {
@@ -240,7 +240,7 @@ TransactionBuilder.prototype.__build = function (allowIncomplete) {
240240 switch ( scriptType ) {
241241 case 'pubkeyhash' :
242242 var pkhSignature = input . signatures [ 0 ] . toScriptSignature ( input . hashType )
243- scriptSig = scripts . pubKeyHashInput ( pkhSignature , input . pubKeys [ 0 ] )
243+ scriptSig = script . pubKeyHashInput ( pkhSignature , input . pubKeys [ 0 ] )
244244 break
245245
246246 case 'multisig' :
@@ -262,12 +262,12 @@ TransactionBuilder.prototype.__build = function (allowIncomplete) {
262262 }
263263
264264 var redeemScript = allowIncomplete ? undefined : input . redeemScript
265- scriptSig = scripts . multisigInput ( msSignatures , redeemScript )
265+ scriptSig = script . multisigInput ( msSignatures , redeemScript )
266266 break
267267
268268 case 'pubkey' :
269269 var pkSignature = input . signatures [ 0 ] . toScriptSignature ( input . hashType )
270- scriptSig = scripts . pubKeyInput ( pkSignature )
270+ scriptSig = script . pubKeyInput ( pkSignature )
271271 break
272272 }
273273 }
@@ -276,7 +276,7 @@ TransactionBuilder.prototype.__build = function (allowIncomplete) {
276276 if ( scriptSig ) {
277277 // wrap as scriptHash if necessary
278278 if ( input . prevOutType === 'scripthash' ) {
279- scriptSig = scripts . scriptHashInput ( scriptSig , input . redeemScript )
279+ scriptSig = script . scriptHashInput ( scriptSig , input . redeemScript )
280280 }
281281
282282 tx . setInputScript ( index , scriptSig )
@@ -318,14 +318,14 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
318318 if ( input . prevOutScript ) {
319319 if ( input . prevOutType !== 'scripthash' ) throw new Error ( 'PrevOutScript must be P2SH' )
320320
321- var scriptHash = scripts . decompile ( input . prevOutScript ) [ 1 ]
321+ var scriptHash = script . decompile ( input . prevOutScript ) [ 1 ]
322322 if ( ! bufferutils . equal ( scriptHash , bcrypto . hash160 ( redeemScript ) ) ) throw new Error ( 'RedeemScript does not match ' + scriptHash . toString ( 'hex' ) )
323323 }
324324
325- var scriptType = scripts . classifyOutput ( redeemScript )
325+ var scriptType = script . classifyOutput ( redeemScript )
326326 if ( ! canSignTypes [ scriptType ] ) throw new Error ( 'RedeemScript not supported (' + scriptType + ')' )
327327
328- var redeemScriptChunks = scripts . decompile ( redeemScript )
328+ var redeemScriptChunks = script . decompile ( redeemScript )
329329 var pubKeys = [ ]
330330 switch ( scriptType ) {
331331 case 'multisig' :
@@ -347,7 +347,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
347347
348348 // if we don't have a prevOutScript, generate a P2SH script
349349 if ( ! input . prevOutScript ) {
350- input . prevOutScript = scripts . scriptHashOutput ( bcrypto . hash160 ( redeemScript ) )
350+ input . prevOutScript = script . scriptHashOutput ( bcrypto . hash160 ( redeemScript ) )
351351 input . prevOutType = 'scripthash'
352352 }
353353
@@ -365,7 +365,7 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
365365
366366 // we know nothin' Jon Snow, assume pubKeyHash
367367 } else {
368- input . prevOutScript = scripts . pubKeyHashOutput ( bcrypto . hash160 ( keyPair . getPublicKeyBuffer ( ) ) )
368+ input . prevOutScript = script . pubKeyHashOutput ( bcrypto . hash160 ( keyPair . getPublicKeyBuffer ( ) ) )
369369 input . prevOutType = 'pubkeyhash'
370370 input . pubKeys = [ kpPubKey ]
371371 input . scriptType = input . prevOutType
0 commit comments