async updateBalances(flags) {
    const name = flags.name

    // Open the wallet data file.
    const filename = `${__dirname}/../../wallets/${name}.json`
    const walletInfo = appUtils.openWallet(filename)
    walletInfo.name = name

    console.log(`Existing balance: ${walletInfo.balance} BCH`)

    // Determine if this is a testnet wallet or a mainnet wallet.
    if (walletInfo.network === "testnet")
      this.BITBOX = new config.BCHLIB({ restURL: config.TESTNET_REST })

    console.log(`debug: walletInfo.nextAddress = ${walletInfo.nextAddress}`)

    // Query data on each address that has been generated by the wallet.
    //const addressData = await this.getAddressData(walletInfo)
    const addressData = await this.getAllAddressData(walletInfo)
    //console.log(`addressData: ${util.inspect(addressData)}`)

    // Update hasBalance array with non-zero balances.
    const hasBalance = this.generateHasBalance(addressData.addressData)
    // console.log(`hasBalance: ${JSON.stringify(hasBalance, null, 2)}`)

    // Sum all the balances in hasBalance to calculate total balance.
    const balance = this.sumConfirmedBalances(hasBalance, true)

    // Save the data to the wallet JSON file.
    walletInfo.balance = appUtils.eightDecimals(
      balance.totalConfirmed + balance.totalUnconfirmed
    )
    walletInfo.balanceConfirmed = balance.totalConfirmed
    walletInfo.balanceUnconfirmed = balance.totalUnconfirmed
    walletInfo.hasBalance = hasBalance
    walletInfo.SLPUtxos = addressData.slpUtxoData
    await appUtils.saveWallet(filename, walletInfo)

    return walletInfo
  }
// Update the balances in the wallet.
Update the balances in the wallet.
Update the balances in the wallet .
async updateBalances(flags) {
    const name = flags.name
    const filename = `${__dirname}/../../wallets/${name}.json`
    const walletInfo = appUtils.openWallet(filename)
    walletInfo.name = name
    console.log(`Existing balance: ${walletInfo.balance} BCH`)
    if (walletInfo.network === "testnet")
      this.BITBOX = new config.BCHLIB({ restURL: config.TESTNET_REST })
    console.log(`debug: walletInfo.nextAddress = ${walletInfo.nextAddress}`)
    const addressData = await this.getAllAddressData(walletInfo)
    const hasBalance = this.generateHasBalance(addressData.addressData)
    const balance = this.sumConfirmedBalances(hasBalance, true)
    walletInfo.balance = appUtils.eightDecimals(
      balance.totalConfirmed + balance.totalUnconfirmed
    )
    walletInfo.balanceConfirmed = balance.totalConfirmed
    walletInfo.balanceUnconfirmed = balance.totalUnconfirmed
    walletInfo.hasBalance = hasBalance
    walletInfo.SLPUtxos = addressData.slpUtxoData
    await appUtils.saveWallet(filename, walletInfo)
    return walletInfo
  }
async updateBalances ( flags ) { const name = flags . name const filename = ` ${ __dirname } ${ name } ` const walletInfo = appUtils . openWallet ( filename ) walletInfo . name = name console . log ( ` ${ walletInfo . balance } ` ) if ( walletInfo . network === "testnet" ) this . BITBOX = new config . BCHLIB ( { restURL : config . TESTNET_REST } ) console . log ( ` ${ walletInfo . nextAddress } ` ) const addressData = await this . getAllAddressData ( walletInfo ) const hasBalance = this . generateHasBalance ( addressData . addressData ) const balance = this . sumConfirmedBalances ( hasBalance , true ) walletInfo . balance = appUtils . eightDecimals ( balance . totalConfirmed + balance . totalUnconfirmed ) walletInfo . balanceConfirmed = balance . totalConfirmed walletInfo . balanceUnconfirmed = balance . totalUnconfirmed walletInfo . hasBalance = hasBalance walletInfo . SLPUtxos = addressData . slpUtxoData await appUtils . saveWallet ( filename , walletInfo ) return walletInfo }
Update the balances in the wallet.
Update the balances in the wallet .
// Open the wallet data file. // Determine if this is a testnet wallet or a mainnet wallet. // Query data on each address that has been generated by the wallet. //const addressData = await this.getAddressData(walletInfo) //console.log(`addressData: ${util.inspect(addressData)}`) // Update hasBalance array with non-zero balances. // console.log(`hasBalance: ${JSON.stringify(hasBalance, null, 2)}`) // Sum all the balances in hasBalance to calculate total balance. // Save the data to the wallet JSON file.