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 b64dc87..104390b 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,6 +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.launch import org.bitcoindevkit.Address import org.bitcoindevkit.AddressInfo @@ -98,7 +99,7 @@ class WalletManager( ) walletRepository.saveMnemonic(mnemonic.toString()) - florestaRpc.loadDescriptor(descriptor.toString()) + florestaRpc.loadDescriptor(descriptor.toString()).first() } suspend fun loadWallet(): Result { @@ -119,7 +120,7 @@ class WalletManager( connection = dbConnection ) - florestaRpc.loadDescriptor(descriptor.toString()) + florestaRpc.loadDescriptor(descriptor.toString()).first() Log.d(TAG, "loadWallet: in network ${wallet.network()}") @@ -157,7 +158,7 @@ class WalletManager( changeDescriptor.toStringWithSecret() ) walletRepository.saveMnemonic(mnemonic.toString()) - florestaRpc.loadDescriptor(descriptor.toString()) + florestaRpc.loadDescriptor(descriptor.toString()).first() } 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 f14321b..a7dac0b 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 @@ -41,9 +41,10 @@ class FlorestaRpcImpl( arguments.put(descriptor) getBlockchainInfo().first().onSuccess { result -> + Log.d(TAG, "loadDescriptor: loading initial block: ${result.result.ibd}") if (result.result.ibd) { delay(10.seconds) - loadDescriptor(descriptor) + loadDescriptor(descriptor).first() } else { emit( sendJsonRpcRequest( @@ -55,7 +56,7 @@ class FlorestaRpcImpl( } }.onFailure { delay(30.seconds) - loadDescriptor(descriptor) + loadDescriptor(descriptor).first() } }