Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Useful error messages on connecting, unlock wallet #45

Merged

Conversation

michaelWuensch
Copy link
Contributor

@michaelWuensch michaelWuensch commented Jul 2, 2019

Description

This PR has 2 main parts:

  • it introduces a new feature: Unlocking wallets.
  • it improves error messages

Motivation and Context

Zap should be easy to use. Right now there are bad error messages that are not really helpful if the connection can not be established.
This PR tries to make the process of connection a lot more simpler by providing useful information.
Furthermore it is now possible to access a locked wallet and unlock it from within the app.

How Has This Been Tested?

It was tested with lnd 0.6.1-beta, Samsung S9, API 29

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the Contribution document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- unlock wallet
- timeout for info request
- catch errors on certificate and macaroon
- useful error messages with solution suggestions.
@michaelWuensch michaelWuensch self-assigned this Jul 2, 2019
@michaelWuensch
Copy link
Contributor Author

Issues this is linked to: #17 #32 #37

@michaelWuensch michaelWuensch changed the title Usefull error messages on lndconnect string parsing, unlock wallet Useful error messages on connecting, unlock wallet Jul 3, 2019
- this is only a temporary solution, which deserves a better solution in a separate PR
@michaelWuensch
Copy link
Contributor Author

A few updates to this PR:

  • I have now refactored the lndconnect string parsing. The logic moved from the activity to its own class and unit test have been added for the parsing.
  • I added a "retry" button that is visible when vaild connection data was provided, but still no connection can be established (LND not running, no internet connection, etc.). So now you don't have to restart the app.
  • "Wrong Password" is now shown if a wrong password was used to unlock the wallet.
  • A loading spinner was added for the loading screen to emphasize something is happening.
  • Missing translations were added (Loading, unlock wallet)

app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
mWalletConnectedLayout.setVisibility(View.GONE);
mWalletNotConnectedLayout.setVisibility(View.GONE);
mLoadingWalletLayout.setVisibility(View.VISIBLE);
Wallet.getInstance().isLNDReachable();
Copy link
Member

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 rename this function, since its not clearly expressing that it is used to establish a connection.
I know it is implicit but maybe we can make it more clear.
In this specific usecase for example, when one is "retrying" you would expect to do something like connect or establishConnection, so a call to check for reachability could be a bit misleading.
(e.g. we split the function into a connect() and a isReachable() where possible both do the same or even connect() is internally just calling isReachable().)
Just a minor thing but maybe you feel the same.

app/src/test/java/android/util/Log.java Outdated Show resolved Hide resolved
app/src/main/java/zapsolutions/zap/util/Wallet.java Outdated Show resolved Hide resolved
- increased wallet unlock delay to 10
- added error constants for WalletLoadedListener interface
- reworked LndConnectString parser
- created a more reuseable LndConnectionConfig class
- changed gradle option for unit tests
- typo fixes
- added inernet connection hint to the timeout error
<string name="error_qr_code_result_null">QR-Code konnte nicht gelesen werden, bitte versuch es noch einmal.</string>
<string name="error_connection_unsupported_format">Dieses Format wird leider nicht ünterstützt.\nBitte verwende das lndconnect Format.\n\nlndconnect://...</string>
Copy link
Member

Choose a reason for hiding this comment

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

ünterstützt 😃

<string name="error_connection_invalid_host_or_port">Der angegebene Host oder Port is ungültig.</string>
<string name="error_connection_invalid_macaroon2">Zugriff verweigert!\n\nDas Macaroon ist ungültig.</string>
<string name="error_connection_server_unreachable">Zeitüberschreitung.\nDer Server ist nicht erreichbar.\n\n- Bitte stelle sicher, dass du eine gute Internetverbindung hast\n\n- Überprüfe ob der Server läuft und unter folgender IP-Adresse erreichbar ist:\n\n%1$s</string>
<string name="error_connection_lnd_unavailable">Die Verbindung zum LND kann nicht hergestellt werden.\n\n- stelle sicher, dass der LND deamon auf dem server läuft.\n\n- stelle sicher, dass Port forwarding aktiviert ist. (Port: %1$s)\n\n- stelle sicher, dass das Zertifikat gültig ist.</string>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe capitalize Server

@@ -1405,7 +1495,14 @@ public void unregisterWalletLoadedListener(WalletLoadedListener listener) {
}

public interface WalletLoadedListener {
void onWalletLoadedUpdated(boolean success, String error);

int ERROR_LOCKED = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍

Copy link
Member

@raphBTC raphBTC left a comment

Choose a reason for hiding this comment

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

@raphBTC raphBTC mentioned this pull request Jul 6, 2019
9 tasks
@michaelWuensch michaelWuensch merged commit 28f0f2b into LN-Zap:master Jul 6, 2019
@michaelWuensch michaelWuensch deleted the feature/ConnectionErrorHandling branch July 6, 2019 23:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants