@@ -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,20 +1625,23 @@ Wallet.prototype.updateIndex = function(index, callback) {
16251625 } ) ;
16261626}
16271627
1628- Wallet . prototype . deriveAddresses = function ( index , amount , isChange , cosigner ) {
1629- preconditions . checkArgument ( cosigner ) ;
1628+ Wallet . prototype . deriveAddresses = function ( index , amount , isChange , copayerIndex ) {
1629+ preconditions . checkArgument ( amount ) ;
1630+ preconditions . shouldBeDefined ( copayerIndex ) ;
16301631
16311632 var ret = new Array ( amount ) ;
16321633 for ( var i = 0 ; i < amount ; i ++ ) {
1633- ret [ i ] = this . publicKeyRing . getAddress ( index + i , isChange , cosigner ) . toString ( ) ;
1634+ ret [ i ] = this . publicKeyRing . getAddress ( index + i , isChange , copayerIndex ) . toString ( ) ;
16341635 }
16351636 return ret ;
16361637}
16371638
16381639// This function scans the publicKeyRing branch starting at index @start and reports the index with last activity,
16391640// using a scan window of @gap . The argument @change defines the branch to scan: internal or external.
16401641// Returns -1 if no activity is found in range.
1641- 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 ) ;
16421645 var scanIndex = start ;
16431646 var lastActive = - 1 ;
16441647 var hasActivity = false ;
@@ -1648,7 +1651,7 @@ Wallet.prototype.indexDiscovery = function(start, change, cosigner, gap, cb) {
16481651 function _do ( next ) {
16491652 // Optimize window to minimize the derivations.
16501653 var scanWindow = ( lastActive == - 1 ) ? gap : gap - ( scanIndex - lastActive ) + 1 ;
1651- var addresses = self . deriveAddresses ( scanIndex , scanWindow , change , cosigner ) ;
1654+ var addresses = self . deriveAddresses ( scanIndex , scanWindow , change , copayerIndex ) ;
16521655 self . blockchain . checkActivity ( addresses , function ( err , actives ) {
16531656 if ( err ) throw err ;
16541657
0 commit comments