Skip to content

Commit

Permalink
Merge pull request #1538 from getAlby/feat/576_lndhub-connector
Browse files Browse the repository at this point in the history
feat(connector): add general lndhub connector #576
  • Loading branch information
escapedcat authored Oct 4, 2022
2 parents 49705ab + ede1bec commit e36e253
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 24 deletions.
39 changes: 28 additions & 11 deletions src/app/router/connectorRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import galoyBitcoinBeach from "/static/assets/icons/galoy_bitcoin_beach.png";
import galoyBitcoinJungle from "/static/assets/icons/galoy_bitcoin_jungle.png";
import lnbits from "/static/assets/icons/lnbits.png";
import lnd from "/static/assets/icons/lnd.png";
import lndhub from "/static/assets/icons/lndhub.png";
import lndhubBlueWallet from "/static/assets/icons/lndhub_bluewallet.png";
import lndhubGo from "/static/assets/icons/lndhub_go.png";
import mynode from "/static/assets/icons/mynode.png";
import raspiblitz from "/static/assets/icons/raspiblitz.png";
import start9 from "/static/assets/icons/start9.png";
Expand Down Expand Up @@ -54,16 +55,6 @@ function getConnectorRoutes() {
),
logo: lnd,
},
{
path: "lnd-hub",
element: <ConnectLndHub />,
title: i18n.t("choose_connector.lndhub.title", translationI18nNamespace),
description: i18n.t(
"choose_connector.lndhub.description",
translationI18nNamespace
),
logo: lndhub,
},
{
path: "lnbits",
element: <ConnectLnbits />,
Expand All @@ -74,6 +65,32 @@ function getConnectorRoutes() {
),
logo: lnbits,
},
{
path: "lnd-hub-go",
element: <ConnectLndHub lndHubType="lndhub_go" />,
title: i18n.t(
"choose_connector.lndhub_go.title",
translationI18nNamespace
),
description: i18n.t(
"choose_connector.lndhub_go.description",
translationI18nNamespace
),
logo: lndhubGo,
},
{
path: "lnd-hub-bluewallet",
element: <ConnectLndHub />,
title: i18n.t(
"choose_connector.lndhub_bluewallet.title",
translationI18nNamespace
),
description: i18n.t(
"choose_connector.lndhub_bluewallet.description",
translationI18nNamespace
),
logo: lndhubBlueWallet,
},
{
path: "eclair",
element: <ConnectEclair />,
Expand Down
12 changes: 9 additions & 3 deletions src/app/screens/connectors/ConnectLndHub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import utils from "~/common/lib/utils";

export default function ConnectLndHub() {
export type Props = {
lndHubType?: "lndhub_bluewallet" | "lndhub_go";
};

export default function ConnectLndHub({
lndHubType = "lndhub_bluewallet",
}: Props) {
const navigate = useNavigate();
const { t } = useTranslation("translation", {
keyPrefix: "choose_connector.lndhub",
keyPrefix: `choose_connector.${lndHubType}`,
});
const [formData, setFormData] = useState({
uri: "",
Expand Down Expand Up @@ -48,7 +54,7 @@ export default function ConnectLndHub() {
const password = match[2];
const url = match[3].replace(/\/$/, "");
const account = {
name: "LNDHub",
name: lndHubType === "lndhub_bluewallet" ? "Bluewallet" : "LNDHub",
config: {
login,
password,
Expand Down
21 changes: 18 additions & 3 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,28 @@
"connection_failed": "Connection failed. Are your LND credentials correct?"
}
},
"lndhub": {
"title": "LNDHub (Bluewallet)",
"lndhub_bluewallet": {
"title": "Bluewallet",
"description": "Connect to your Bluewallet mobile wallet",
"page": {
"title": "Connect to LNDHub (BlueWallet)",
"title": "Connect to BlueWallet",
"description": "In BlueWallet, choose the wallet you want to connect, open it, click on \"...\", click on Export/Backup to display the QR code and scan it with your webcam."
},
"uri": {
"label": "BlueWallet Export URI"
},
"errors": {
"invalid_uri": "Invalid BlueWallet URI",
"connection_failed": "Connection failed. Is your BlueWallet URI correct?"
}
},
"lndhub_go": {
"title": "LNDHub",
"description": "Connect to your LNDHub account",
"page": {
"title": "Connect to LNDHub",
"description": "Input your LNDHub credential URI here or scan the QR code with your webcam."
},
"uri": {
"label": "LNDHub Export URI"
},
Expand Down
File renamed without changes
Binary file added static/assets/icons/lndhub_go.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions tests/e2e/001-createWallets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ test.describe("Create or connect wallets", () => {
test("successfully connects to BlueWallet", async () => {
const { browser, page, $document } = await commonCreateWalletUserCreate();

// click at "LNDHub (BlueWallet)"
const createNewWalletButton = await getByText(
$document,
"LNDHub (Bluewallet)"
);
// click at "BlueWallet"
const createNewWalletButton = await getByText($document, "Bluewallet");
createNewWalletButton.click();

await findByText($document, "Connect to LNDHub (BlueWallet)");
await findByText($document, "Connect to BlueWallet");

const lndHubUrl =
"lndhub://c269ebb962f1a94f9c29:f6f16f35e935edc05ee7@https://lndhub.io";
const lndUrlField = await getByLabelText($document, "LNDHub Export URI");
const lndUrlField = await getByLabelText(
$document,
"BlueWallet Export URI"
);
await lndUrlField.type(lndHubUrl);

await commonCreateWalletSuccessCheck({ page, $document });
Expand Down

0 comments on commit e36e253

Please sign in to comment.