Skip to content

Commit

Permalink
Validate wallet after it's created
Browse files Browse the repository at this point in the history
  • Loading branch information
igordanilcenko committed Oct 15, 2024
1 parent 637661f commit 052d41d
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,7 @@ class WalletManager @Inject constructor(
baseNodeKeyFFI.destroy()
logger.i("baseNodeSync:addBaseNodePeer ${if (addBaseNodeResult) "success" else "failed"}")

try {
logger.i("baseNodeSync:wallet validation:start Tx and TXO validation")
walletValidationStatusMap.clear()
walletValidationStatusMap[WalletValidationType.TXO] = WalletValidationResult(wallet.startTXOValidation(), null)
walletValidationStatusMap[WalletValidationType.TX] = WalletValidationResult(wallet.startTxValidation(), null)
logger.i(
"baseNodeSync:wallet validation:started Tx and TXO validation with " +
"request keys: ${Gson().toJson(walletValidationStatusMap.map { it.value.requestKey })}"
)
} catch (e: Throwable) {
logger.i("baseNodeSync:wallet validation:error: ${e.message}")
walletValidationStatusMap.clear()
baseNodeStateHandler.updateSyncState(BaseNodeSyncState.Failed)
}
validateWallet()
}
break
} catch (e: Throwable) {
Expand Down Expand Up @@ -570,10 +557,33 @@ class WalletManager @Inject constructor(
}
}

validateWallet()

saveWalletAddressToSharedPrefs()
}
}

private fun validateWallet() {
applicationScope.launch(Dispatchers.IO) {
doOnWalletRunning { wallet ->
try {
logger.i("baseNodeSync:wallet validation:start Tx and TXO validation")
walletValidationStatusMap.clear()
walletValidationStatusMap[WalletValidationType.TXO] = WalletValidationResult(wallet.startTXOValidation(), null)
walletValidationStatusMap[WalletValidationType.TX] = WalletValidationResult(wallet.startTxValidation(), null)
logger.i(
"baseNodeSync:wallet validation:started Tx and TXO validation with " +
"request keys: ${Gson().toJson(walletValidationStatusMap.map { it.value.requestKey })}"
)
} catch (e: Throwable) {
logger.i("baseNodeSync:wallet validation:error: ${e.message}")
walletValidationStatusMap.clear()
baseNodeStateHandler.updateSyncState(BaseNodeSyncState.Failed)
}
}
}
}

private fun postTxNotification(tx: Tx) {
txReceivedNotificationDelayedAction?.dispose()
inboundTxEventNotificationTxs.add(tx)
Expand Down

0 comments on commit 052d41d

Please sign in to comment.