@@ -1611,12 +1611,12 @@ Wallet.prototype.updateIndexes = function(callback) {
16111611Wallet . prototype . updateIndex = function ( index , callback ) {
16121612 var self = this ;
16131613 var SCANN_WINDOW = 20 ;
1614- self . indexDiscovery ( index . changeIndex , true , index . cosigner , SCANN_WINDOW , function ( err , changeIndex ) {
1614+ self . indexDiscovery ( index . changeIndex , true , index . copayerIndex , SCANN_WINDOW , function ( err , changeIndex ) {
16151615 if ( err ) return callback ( err ) ;
16161616 if ( changeIndex != - 1 )
16171617 index . changeIndex = changeIndex + 1 ;
16181618
1619- self . indexDiscovery ( index . receiveIndex , false , index . cosigner , SCANN_WINDOW , function ( err , receiveIndex ) {
1619+ self . indexDiscovery ( index . receiveIndex , false , index . copayerIndex , SCANN_WINDOW , function ( err , receiveIndex ) {
16201620 if ( err ) return callback ( err ) ;
16211621 if ( receiveIndex != - 1 )
16221622 index . receiveIndex = receiveIndex + 1 ;
@@ -1625,18 +1625,23 @@ Wallet.prototype.updateIndex = function(index, callback) {
16251625 } ) ;
16261626}
16271627
1628- Wallet . prototype . deriveAddresses = function ( index , amout , isChange , cosigner ) {
1629- var ret = new Array ( amout ) ;
1630- for ( var i = 0 ; i < amout ; i ++ ) {
1631- ret [ i ] = this . publicKeyRing . getAddress ( index + i , isChange , cosigner ) . toString ( ) ;
1628+ Wallet . prototype . deriveAddresses = function ( index , amount , isChange , copayerIndex ) {
1629+ preconditions . checkArgument ( amount ) ;
1630+ preconditions . shouldBeDefined ( copayerIndex ) ;
1631+
1632+ var ret = new Array ( amount ) ;
1633+ for ( var i = 0 ; i < amount ; i ++ ) {
1634+ ret [ i ] = this . publicKeyRing . getAddress ( index + i , isChange , copayerIndex ) . toString ( ) ;
16321635 }
16331636 return ret ;
16341637}
16351638
16361639// This function scans the publicKeyRing branch starting at index @start and reports the index with last activity,
16371640// using a scan window of @gap . The argument @change defines the branch to scan: internal or external.
16381641// Returns -1 if no activity is found in range.
1639- Wallet . prototype . indexDiscovery = function ( start , change , cosigner , gap , cb ) {
1642+ Wallet . prototype . indexDiscovery = function ( start , change , copayerIndex , gap , cb ) {
1643+ preconditions . shouldBeDefined ( copayerIndex ) ;
1644+ preconditions . checkArgument ( gap ) ;
16401645 var scanIndex = start ;
16411646 var lastActive = - 1 ;
16421647 var hasActivity = false ;
@@ -1646,7 +1651,7 @@ Wallet.prototype.indexDiscovery = function(start, change, cosigner, gap, cb) {
16461651 function _do ( next ) {
16471652 // Optimize window to minimize the derivations.
16481653 var scanWindow = ( lastActive == - 1 ) ? gap : gap - ( scanIndex - lastActive ) + 1 ;
1649- var addresses = self . deriveAddresses ( scanIndex , scanWindow , change , cosigner ) ;
1654+ var addresses = self . deriveAddresses ( scanIndex , scanWindow , change , copayerIndex ) ;
16501655 self . blockchain . checkActivity ( addresses , function ( err , actives ) {
16511656 if ( err ) throw err ;
16521657
0 commit comments