Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle wallet sync error during startup #2090

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

holzeis
Copy link
Contributor

@holzeis holzeis commented Feb 23, 2024

Let the app start even if the wallet sync fails.

If the wallet sync fails the balance will be set to None, telling the UI that we were unable to determine the balance.

fixes: #2075

@holzeis holzeis self-assigned this Feb 23, 2024
@holzeis holzeis force-pushed the fix/catch-error-when-wallet-sync-fails branch 2 times, most recently from 179a336 to 95c60e5 Compare February 23, 2024 19:26
@holzeis holzeis requested a review from bonomat February 23, 2024 19:26
@holzeis holzeis force-pushed the fix/catch-error-when-wallet-sync-fails branch 2 times, most recently from 8e7f11f to 4d1cd9a Compare February 23, 2024 20:53
@holzeis holzeis force-pushed the fix/catch-error-when-wallet-sync-fails branch from 4d1cd9a to 1105e9b Compare February 26, 2024 07:32
@@ -369,10 +369,14 @@ pub fn run(seed_dir: String, runtime: &Runtime) -> Result<()> {
// TODO: This might not be necessary once we rewrite the on-chain wallet with bdk:1.0.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 We might want to hold off on this change until after #2094 is merged. We might not even need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will probably not need it for the on-chain sync. But the off-chain balance will definitely fail in regards to the linked issue, since the contract was not backed up breaking the restored app.

let on_chain_balance = self.inner.get_on_chain_balance()?;
let on_chain = on_chain_balance.confirmed + on_chain_balance.trusted_pending;
pub fn get_wallet_balances(&self) -> Balances {
let on_chain = match self.inner.get_on_chain_balance() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The on-chain balance will actually be infallible very soon :D

@@ -18,28 +18,35 @@ class _BalanceRowState extends State<BalanceRow> with SingleTickerProviderStateM
Widget build(BuildContext context) {
WalletChangeNotifier walletChangeNotifier = context.watch<WalletChangeNotifier>();

final offchainBalance = walletChangeNotifier.offChain()?.formatted() ?? "n/a";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Better than a zero or nothing at all.

I wonder if we should eventually use skeletons during loading and just display an error pop-up if some key data cannot be loaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should eventually use skeletons during loading and just display an error pop-up if some key data cannot be loaded.

Can you elaborate? I am not sure I completely follow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking about a nicer way to display information that is not yet available, and also information that we have failed to load.

In this case, showing a skeleton until the balance is available would be cool. But I'm not sure what would be the nicest way to display the fact that the balance could not be loaded. The label n/a is serviceable, but probably not the nicest.

Let the app start even if the wallet sync fails.
Better to let the app start with what balance information we can get, than without anything.
If the wallet sync on-chain or off-chain fails the corresponding wallet info is none, which will tell the user that we couldn't sync their balance.

Better than just showing 0.
@holzeis holzeis force-pushed the fix/catch-error-when-wallet-sync-fails branch from 1105e9b to 8b2625e Compare February 27, 2024 07:37
@holzeis holzeis added this pull request to the merge queue Feb 27, 2024
Merged via the queue into main with commit 8d9411f Feb 27, 2024
20 checks passed
@holzeis holzeis deleted the fix/catch-error-when-wallet-sync-fails branch February 27, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App still is crashing now after upgrading to 1.8.11 #2031 and only happens with my original restore phrase
3 participants