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

[Issue #32] Add BTCPay Server Support #46

Merged
merged 12 commits into from
Jul 7, 2019
Merged

[Issue #32] Add BTCPay Server Support #46

merged 12 commits into from
Jul 7, 2019

Conversation

raphBTC
Copy link
Member

@raphBTC raphBTC commented Jul 2, 2019

This PR enables support for BTCPay Server.

Description

  • Support new connection strings
  • Allow connection without certificate
  • Add Alert Dialog

Motivation and Context

Resolve issue: #32

How Has This Been Tested?

Set up a BTCPay Server instance to test the various connection strings/QR code.
If anyone has an instance running, would be happy for additional tests 👍

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.

@raphBTC raphBTC self-assigned this Jul 2, 2019
@@ -0,0 +1,49 @@
package zapsolutions.zap.connection.btcPay;

public class BTCPayConfiguration {
Copy link
Member Author

@raphBTC raphBTC Jul 2, 2019

Choose a reason for hiding this comment

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

I've only added the fields that we currently have in use.

Copy link
Contributor

Choose a reason for hiding this comment

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

"certificateThumbprint" and "ssl" should maybe also included.
If I understood it correct, having ssl=false would mean falling back to certificateThumbprint, which actually is still ssl, as it uses LNDs generated sslCertificate instead of letsencryt one.
This case would have to be implemented in the other files as well though.
@rockstardev can you maybe comment on this? Did I understood that correct and is this case acutally important or does it not happen anyway?

R.M added 2 commits July 7, 2019 10:00
# Conflicts:
#	app/src/main/java/zapsolutions/zap/connection/LndConnection.java
#	app/src/main/java/zapsolutions/zap/setup/ConnectRemoteNodeActivity.java
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values/strings.xml
@@ -33,7 +33,7 @@


<!-- Theme for the QR-Code scanner activity. -->
<style name="AppOverlayTheme" parent="@style/Theme.AppCompat.Light">
<style name="AppOverlayTheme" parent="@style/Theme.AppCompat">
Copy link
Member Author

Choose a reason for hiding this comment

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

@michaelWuensch The light theme converted the text in the checkbox to black on my site.

@@ -239,6 +239,8 @@
<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>
<string name="error_connection_wallet_locked">Bitte entsperre die Wallet.</string>
<string name="error_connection_btcpay_invalid_json">Die BTCPay Server Konfiguration hat eine ungültige JSON syntax.</string>
<string name="error_connection_btcpay_invalid_config">Die BTCPay Server Konfiguration enthält keine Konfiguration für BTC GRPC.</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

"Server Konfiguration" should be "Serverkonfiguration"

Copy link
Member Author

Choose a reason for hiding this comment

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

Those Germans and their concatenated nouns 😄

@@ -59,7 +60,7 @@ private void readSavedConnectionInfo() {
mConnectionInfo = connectionInfo.split(";");
ZapLog.debug(LOG_TAG, connectionInfo);

if (mConnectionInfo[2].equals("null")) {
if (mConnectionInfo[2].equals(BTCPayConfig.NO_CERT)) {
// BTC PAY (no cert, hex encoded macaroon)
mMacaroon = new MacaroonCallCredential(mConnectionInfo[3]);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the else part the macaroon actually has to be created like this:

        // LND Connect
        String macaroonBase64UrlString = mConnectionInfo[3];

        if (mConnectionInfo[2].equals("null")){
            mMacaroon = new MacaroonCallCredential(mConnectionInfo[3]);
        } else {
            byte[] macaroonBytes = BaseEncoding.base64Url().decode(macaroonBase64UrlString);
            String macaroon = BaseEncoding.base16().encode(macaroonBytes);
            mMacaroon = new MacaroonCallCredential(macaroon);
        }

This covers the case when we want to connect to a BtcPay with an lndconnect string.
In the future we will have to make sure that all our parsers already encode the macaroon in the same manner, so on the device the connection information is saved in the same format, no matter where it came from.
But this would require to reconnect the node after an update within the app.
One of the next things will probably Biometrics which will also require a reconnect. That's why I would wait with this refactor, so we need to do this only once.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I agree, we should try to move the persisted config to a general format.
Biometrics are optional, so they would only require a reconnect for people that will use them, right?

What we could do is to support a legacy version for a few releases and with time stop supporting it, e.g. when the user base drops to a certain percentage of that version.

@raphBTC raphBTC merged commit e925e72 into master Jul 7, 2019
@raphBTC raphBTC deleted the feature/32-btcpay branch July 7, 2019 17:37
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.

3 participants