async loadFromDisk(password) {
    try {
      let data = await AsyncStorage.getItem('data');
      if (password) {
        data = this.decryptData(data, password);
        if (data) {
          // password is good, cache it
          this.cachedPassword = password;
        }
      }
      if (data !== null) {
        data = JSON.parse(data);
        if (!data.wallets) return false;
        let wallets = data.wallets;
        for (let key of wallets) {
          // deciding which type is wallet and instatiating correct object
          let tempObj = JSON.parse(key);
          let unserializedWallet;
          switch (tempObj.type) {
            case SegwitBech32Wallet.type:
              unserializedWallet = SegwitBech32Wallet.fromJson(key);
              break;
            case SegwitP2SHWallet.type:
              unserializedWallet = SegwitP2SHWallet.fromJson(key);
              break;
            case WatchOnlyWallet.type:
              unserializedWallet = WatchOnlyWallet.fromJson(key);
              break;
            case HDLegacyP2PKHWallet.type:
              unserializedWallet = HDLegacyP2PKHWallet.fromJson(key);
              break;
            case HDSegwitP2SHWallet.type:
              unserializedWallet = HDSegwitP2SHWallet.fromJson(key);
              break;
            case HDLegacyBreadwalletWallet.type:
              unserializedWallet = HDLegacyBreadwalletWallet.fromJson(key);
              break;
            case LightningCustodianWallet.type:
              /** @type {LightningCustodianWallet} */
              unserializedWallet = LightningCustodianWallet.fromJson(key);
              let lndhub = false;
              try {
                lndhub = await AsyncStorage.getItem(AppStorage.LNDHUB);
              } catch (Error) {
                console.warn(Error);
              }
              if (lndhub) {
                console.log('using', lndhub, 'for lndhub wallet');
                unserializedWallet.setBaseURI(lndhub);
              } else {
                unserializedWallet.setBaseURI();
                console.log('using default uri for for lndhub wallet:', unserializedWallet.baseURI);
              }
              unserializedWallet.init();
              break;
            case LegacyWallet.type:
            default:
              unserializedWallet = LegacyWallet.fromJson(key);
              break;
          }
          // done
          if (!this.wallets.some(wallet => wallet.getSecret() === unserializedWallet.secret)) {
            this.wallets.push(unserializedWallet);
            this.tx_metadata = data.tx_metadata;
          }
        }
        return true;
      } else {
        return false; // failed loading data or loading/decryptin data
      }
    } catch (error) {
      return false;
    }
  }
/**
   * Loads from storage all wallets and
   * maps them to `this.wallets`
   *
   * @param password If present means storage must be decrypted before usage
   * @returns {Promise.<boolean>}
   */
Loads from storage all wallets and
maps them to `this.wallets`

@param password If present means storage must be decrypted before usage
@returns {Promise.}
Loads from storage all wallets and maps them to ` this . wallets ` @param password If present means storage must be decrypted before usage @returns { Promise . }
async loadFromDisk(password) {
    try {
      let data = await AsyncStorage.getItem('data');
      if (password) {
        data = this.decryptData(data, password);
        if (data) {
          this.cachedPassword = password;
        }
      }
      if (data !== null) {
        data = JSON.parse(data);
        if (!data.wallets) return false;
        let wallets = data.wallets;
        for (let key of wallets) {
          let tempObj = JSON.parse(key);
          let unserializedWallet;
          switch (tempObj.type) {
            case SegwitBech32Wallet.type:
              unserializedWallet = SegwitBech32Wallet.fromJson(key);
              break;
            case SegwitP2SHWallet.type:
              unserializedWallet = SegwitP2SHWallet.fromJson(key);
              break;
            case WatchOnlyWallet.type:
              unserializedWallet = WatchOnlyWallet.fromJson(key);
              break;
            case HDLegacyP2PKHWallet.type:
              unserializedWallet = HDLegacyP2PKHWallet.fromJson(key);
              break;
            case HDSegwitP2SHWallet.type:
              unserializedWallet = HDSegwitP2SHWallet.fromJson(key);
              break;
            case HDLegacyBreadwalletWallet.type:
              unserializedWallet = HDLegacyBreadwalletWallet.fromJson(key);
              break;
            case LightningCustodianWallet.type:
              unserializedWallet = LightningCustodianWallet.fromJson(key);
              let lndhub = false;
              try {
                lndhub = await AsyncStorage.getItem(AppStorage.LNDHUB);
              } catch (Error) {
                console.warn(Error);
              }
              if (lndhub) {
                console.log('using', lndhub, 'for lndhub wallet');
                unserializedWallet.setBaseURI(lndhub);
              } else {
                unserializedWallet.setBaseURI();
                console.log('using default uri for for lndhub wallet:', unserializedWallet.baseURI);
              }
              unserializedWallet.init();
              break;
            case LegacyWallet.type:
            default:
              unserializedWallet = LegacyWallet.fromJson(key);
              break;
          }
          if (!this.wallets.some(wallet => wallet.getSecret() === unserializedWallet.secret)) {
            this.wallets.push(unserializedWallet);
            this.tx_metadata = data.tx_metadata;
          }
        }
        return true;
      } else {
        return false; 
      }
    } catch (error) {
      return false;
    }
  }
async loadFromDisk ( password ) { try { let data = await AsyncStorage . getItem ( 'data' ) ; if ( password ) { data = this . decryptData ( data , password ) ; if ( data ) { this . cachedPassword = password ; } } if ( data !== null ) { data = JSON . parse ( data ) ; if ( ! data . wallets ) return false ; let wallets = data . wallets ; for ( let key of wallets ) { let tempObj = JSON . parse ( key ) ; let unserializedWallet ; switch ( tempObj . type ) { case SegwitBech32Wallet . type : unserializedWallet = SegwitBech32Wallet . fromJson ( key ) ; break ; case SegwitP2SHWallet . type : unserializedWallet = SegwitP2SHWallet . fromJson ( key ) ; break ; case WatchOnlyWallet . type : unserializedWallet = WatchOnlyWallet . fromJson ( key ) ; break ; case HDLegacyP2PKHWallet . type : unserializedWallet = HDLegacyP2PKHWallet . fromJson ( key ) ; break ; case HDSegwitP2SHWallet . type : unserializedWallet = HDSegwitP2SHWallet . fromJson ( key ) ; break ; case HDLegacyBreadwalletWallet . type : unserializedWallet = HDLegacyBreadwalletWallet . fromJson ( key ) ; break ; case LightningCustodianWallet . type : unserializedWallet = LightningCustodianWallet . fromJson ( key ) ; let lndhub = false ; try { lndhub = await AsyncStorage . getItem ( AppStorage . LNDHUB ) ; } catch ( Error ) { console . warn ( Error ) ; } if ( lndhub ) { console . log ( 'using' , lndhub , 'for lndhub wallet' ) ; unserializedWallet . setBaseURI ( lndhub ) ; } else { unserializedWallet . setBaseURI ( ) ; console . log ( 'using default uri for for lndhub wallet:' , unserializedWallet . baseURI ) ; } unserializedWallet . init ( ) ; break ; case LegacyWallet . type : default : unserializedWallet = LegacyWallet . fromJson ( key ) ; break ; } if ( ! this . wallets . some ( wallet => wallet . getSecret ( ) === unserializedWallet . secret ) ) { this . wallets . push ( unserializedWallet ) ; this . tx_metadata = data . tx_metadata ; } } return true ; } else { return false ; } } catch ( error ) { return false ; } }
Loads from storage all wallets and
 maps them to `this.wallets`
Loads from storage all wallets and maps them to ` this . wallets `
// password is good, cache it // deciding which type is wallet and instatiating correct object /** @type {LightningCustodianWallet} */ // done // failed loading data or loading/decryptin data