Skip to content

Commit

Permalink
fix: collect descriptor result
Browse files Browse the repository at this point in the history
  • Loading branch information
jvsena42 committed Oct 28, 2024
1 parent 9607995 commit cb8560d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,7 +99,7 @@ class WalletManager(
)

walletRepository.saveMnemonic(mnemonic.toString())
florestaRpc.loadDescriptor(descriptor.toString())
florestaRpc.loadDescriptor(descriptor.toString()).first()
}

suspend fun loadWallet(): Result<Unit> {
Expand All @@ -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()}")

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -55,7 +56,7 @@ class FlorestaRpcImpl(
}
}.onFailure {
delay(30.seconds)
loadDescriptor(descriptor)
loadDescriptor(descriptor).first()
}
}

Expand Down

0 comments on commit cb8560d

Please sign in to comment.