diff --git a/app/src/main/java/com/github/jvsena42/floresta/domain/bitcoin/WalletManager.kt b/app/src/main/java/com/github/jvsena42/floresta/domain/bitcoin/WalletManager.kt index 104390b..f5435b0 100644 --- a/app/src/main/java/com/github/jvsena42/floresta/domain/bitcoin/WalletManager.kt +++ b/app/src/main/java/com/github/jvsena42/floresta/domain/bitcoin/WalletManager.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch import org.bitcoindevkit.Address import org.bitcoindevkit.AddressInfo @@ -99,7 +99,7 @@ class WalletManager( ) walletRepository.saveMnemonic(mnemonic.toString()) - florestaRpc.loadDescriptor(descriptor.toString()).first() + florestaRpc.loadDescriptor(descriptor.toString()).firstOrNull() } suspend fun loadWallet(): Result { @@ -120,7 +120,7 @@ class WalletManager( connection = dbConnection ) - florestaRpc.loadDescriptor(descriptor.toString()).first() + florestaRpc.loadDescriptor(descriptor.toString()).firstOrNull() Log.d(TAG, "loadWallet: in network ${wallet.network()}") @@ -158,7 +158,7 @@ class WalletManager( changeDescriptor.toStringWithSecret() ) walletRepository.saveMnemonic(mnemonic.toString()) - florestaRpc.loadDescriptor(descriptor.toString()).first() + florestaRpc.loadDescriptor(descriptor.toString()).firstOrNull() } private suspend fun fullScan() { diff --git a/app/src/main/java/com/github/jvsena42/floresta/domain/floresta/FlorestaRpcImpl.kt b/app/src/main/java/com/github/jvsena42/floresta/domain/floresta/FlorestaRpcImpl.kt index a7dac0b..b4e78ec 100644 --- a/app/src/main/java/com/github/jvsena42/floresta/domain/floresta/FlorestaRpcImpl.kt +++ b/app/src/main/java/com/github/jvsena42/floresta/domain/floresta/FlorestaRpcImpl.kt @@ -9,6 +9,7 @@ import com.google.gson.Gson import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.flow import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.RequestBody.Companion.toRequestBody @@ -44,7 +45,7 @@ class FlorestaRpcImpl( Log.d(TAG, "loadDescriptor: loading initial block: ${result.result.ibd}") if (result.result.ibd) { delay(10.seconds) - loadDescriptor(descriptor).first() + loadDescriptor(descriptor).firstOrNull() } else { emit( sendJsonRpcRequest( @@ -56,7 +57,7 @@ class FlorestaRpcImpl( } }.onFailure { delay(30.seconds) - loadDescriptor(descriptor).first() + loadDescriptor(descriptor).firstOrNull() } } @@ -70,6 +71,7 @@ class FlorestaRpcImpl( arguments ).fold( onSuccess = { json -> + Log.d(TAG, "getPeerInfo: ") emit( Result.success( gson.fromJson(json.toString(), GetPeerInfoResponse::class.java)