@@ -38,12 +38,13 @@ Bitcoin.Wallet = (function () {
3838 if ( "string" === typeof pubs ) {
3939 pubs = pubs . split ( ',' ) ;
4040 }
41+ var i ;
4142 if ( Array . isArray ( pubs ) && keys . length == pubs . length ) {
42- for ( var i = 0 ; i < keys . length ; i ++ ) {
43+ for ( i = 0 ; i < keys . length ; i ++ ) {
4344 this . addKey ( keys [ i ] , pubs [ i ] ) ;
4445 }
4546 } else {
46- for ( var i = 0 ; i < keys . length ; i ++ ) {
47+ for ( i = 0 ; i < keys . length ; i ++ ) {
4748 this . addKey ( keys [ i ] ) ;
4849 }
4950 }
@@ -131,11 +132,14 @@ Bitcoin.Wallet = (function () {
131132 Wallet . prototype . process = function ( tx ) {
132133 if ( this . txIndex [ tx . hash ] ) return ;
133134
135+ var j ;
136+ var k ;
137+ var hash ;
134138 // Gather outputs
135- for ( var j = 0 ; j < tx . outs . length ; j ++ ) {
139+ for ( j = 0 ; j < tx . outs . length ; j ++ ) {
136140 var txout = new TransactionOut ( tx . outs [ j ] ) ;
137- var hash = Crypto . util . bytesToBase64 ( txout . script . simpleOutPubKeyHash ( ) ) ;
138- for ( var k = 0 ; k < this . addressHashes . length ; k ++ ) {
141+ hash = Crypto . util . bytesToBase64 ( txout . script . simpleOutPubKeyHash ( ) ) ;
142+ for ( k = 0 ; k < this . addressHashes . length ; k ++ ) {
139143 if ( this . addressHashes [ k ] === hash ) {
140144 this . unspentOuts . push ( { tx : tx , index : j , out : txout } ) ;
141145 break ;
@@ -144,11 +148,11 @@ Bitcoin.Wallet = (function () {
144148 }
145149
146150 // Remove spent outputs
147- for ( var j = 0 ; j < tx . ins . length ; j ++ ) {
151+ for ( j = 0 ; j < tx . ins . length ; j ++ ) {
148152 var txin = new TransactionIn ( tx . ins [ j ] ) ;
149153 var pubkey = txin . script . simpleInPubKey ( ) ;
150- var hash = Crypto . util . bytesToBase64 ( Bitcoin . Util . sha256ripe160 ( pubkey ) ) ;
151- for ( var k = 0 ; k < this . addressHashes . length ; k ++ ) {
154+ hash = Crypto . util . bytesToBase64 ( Bitcoin . Util . sha256ripe160 ( pubkey ) ) ;
155+ for ( k = 0 ; k < this . addressHashes . length ; k ++ ) {
152156 if ( this . addressHashes [ k ] === hash ) {
153157 for ( var l = 0 ; l < this . unspentOuts . length ; l ++ ) {
154158 if ( txin . outpoint . hash == this . unspentOuts [ l ] . tx . hash &&
@@ -178,7 +182,8 @@ Bitcoin.Wallet = (function () {
178182 var selectedOuts = [ ] ;
179183 var txValue = sendValue . add ( feeValue ) ;
180184 var availableValue = BigInteger . ZERO ;
181- for ( var i = 0 ; i < this . unspentOuts . length ; i ++ ) {
185+ var i ;
186+ for ( i = 0 ; i < this . unspentOuts . length ; i ++ ) {
182187 selectedOuts . push ( this . unspentOuts [ i ] ) ;
183188 availableValue = availableValue . add ( Bitcoin . Util . valueToBigInt ( this . unspentOuts [ i ] . out . value ) ) ;
184189
@@ -194,7 +199,7 @@ Bitcoin.Wallet = (function () {
194199
195200 var sendTx = new Bitcoin . Transaction ( ) ;
196201
197- for ( var i = 0 ; i < selectedOuts . length ; i ++ ) {
202+ for ( i = 0 ; i < selectedOuts . length ; i ++ ) {
198203 sendTx . addInput ( selectedOuts [ i ] . tx , selectedOuts [ i ] . index ) ;
199204 }
200205
@@ -205,13 +210,13 @@ Bitcoin.Wallet = (function () {
205210
206211 var hashType = 1 ; // SIGHASH_ALL
207212
208- for ( var i = 0 ; i < sendTx . ins . length ; i ++ ) {
213+ for ( i = 0 ; i < sendTx . ins . length ; i ++ ) {
209214 var hash = sendTx . hashTransactionForSignature ( selectedOuts [ i ] . out . script , i , hashType ) ;
210215 var pubKeyHash = selectedOuts [ i ] . out . script . simpleOutPubKeyHash ( ) ;
211216 var signature = this . signWithKey ( pubKeyHash , hash ) ;
212217
213218 // Append hash type
214- signature . push ( parseInt ( hashType ) ) ;
219+ signature . push ( parseInt ( hashType , 10 ) ) ;
215220
216221 sendTx . ins [ i ] . script = Script . createInputScript ( signature , this . getPubKeyFromHash ( pubKeyHash ) ) ;
217222 }
0 commit comments