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

Replace citadel with nirvati #3281

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/app/router/connectorRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ConnectVoltage from "~/app/screens/connectors/ConnectVoltage";
import ConnectCommando from "../screens/connectors/ConnectCommando";
import albyhub from "/static/assets/icons/albyhub.png";
import btcpay from "/static/assets/icons/btcpay.svg";
import citadel from "/static/assets/icons/citadel.png";
import citadel from "/static/assets/icons/citadel.svg";
import core_ln from "/static/assets/icons/core_ln.svg";
import eclair from "/static/assets/icons/eclair.jpg";
import galoyBitcoinJungle from "/static/assets/icons/galoy_bitcoin_jungle.png";
Expand All @@ -33,6 +33,7 @@ import lnbits from "/static/assets/icons/lnbits.png";
import lnd from "/static/assets/icons/lnd.png";
import lndhubGo from "/static/assets/icons/lndhub_go.png";
import mynode from "/static/assets/icons/mynode.png";
import nirvati from "/static/assets/icons/nirvati.svg";
import nwc from "/static/assets/icons/nwc.svg";
import raspiblitz from "/static/assets/icons/raspiblitz.png";
import startos from "/static/assets/icons/startos.png";
Expand Down Expand Up @@ -204,12 +205,12 @@ function getDistribution(key: string): ConnectorRoute {

const distributionMap: { [key: string]: { logo: string; children: Route[] } } =
{
citadel: {
logo: citadel,
nirvati: {
logo: nirvati,
children: [
connectorMap["citadel"],
//connectorMap["citadel"],
connectorMap["lnc"],
connectorMap["commando"],
//connectorMap["commando"],
connectorMap["lnbits"],
],
},
Expand Down Expand Up @@ -264,7 +265,7 @@ function getConnectorRoutes(): ConnectorRoute[] {
getDistribution("startos"),
getDistribution("raspiblitz"),
getDistribution("mynode"),
getDistribution("citadel"),
getDistribution("nirvati"),
connectorMap["btcpay"],
connectorMap["voltage"],
connectorMap[galoyPaths.blink],
Expand Down
98 changes: 58 additions & 40 deletions src/app/screens/connectors/ConnectCitadel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,74 @@ import { useNavigate } from "react-router-dom";
import PasswordViewAdornment from "~/app/components/PasswordViewAdornment";
import toast from "~/app/components/Toast";
import msg from "~/common/lib/msg";
import logo from "/static/assets/icons/citadel.png";
import utils from "~/common/lib/utils";
import logo from "/static/assets/icons/citadel.svg";

const initialFormData = {
url: "",
macaroon: "",
};

export default function ConnectCitadel() {
const navigate = useNavigate();
const { t } = useTranslation("translation", {
keyPrefix: "choose_connector.citadel",
});
const [passwordViewVisible, setPasswordViewVisible] = useState(false);
const [formData, setFormData] = useState({
password: "",
url: "",
});
const [formData, setFormData] = useState(initialFormData);
const [loading, setLoading] = useState(false);
const [hasTorSupport, setHasTorSupport] = useState(false);
const [lndconnectUrlVisible, setLndconnectUrlVisible] = useState(false);

function handleChange(event: React.ChangeEvent<HTMLInputElement>) {
setFormData({
...formData,
[event.target.name]: event.target.value.trim(),
});
function handleLndconnectUrl(event: React.ChangeEvent<HTMLInputElement>) {
try {
const lndconnectUrl = event.target.value.trim();
let lndconnect = new URL(lndconnectUrl);
lndconnect.protocol = "http:";
lndconnect = new URL(lndconnect.toString());
const url = `https://${lndconnect.host}${lndconnect.pathname}`;
let macaroon = lndconnect.searchParams.get("macaroon") || "";
macaroon = utils.urlSafeBase64ToHex(macaroon);
// const cert = lndconnect.searchParams.get("cert"); // TODO: handle LND certs with the native connector
setFormData({
...formData,
url,
macaroon,
});
} catch (e) {
console.error("invalid lndconnect string", e);
}
}

function getConnectorType() {
if (formData.url.match(/\.onion/i) && !hasTorSupport) {
return "nativecitadel";
return "nativelnd";
}
return "citadel";
// default to LND
return "lnd";
}

async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
setLoading(true);
const { password, url } = formData;
/** The URL with an http:// in front if the protocol is missing */
const fullUrl =
url.startsWith("http://") || url.startsWith("https://")
? url
: `http://${url}`;
const { url, macaroon } = formData;
const account = {
name: "Citadel",
config: {
url: fullUrl,
password,
macaroon,
url,
},
connector: getConnectorType(),
};

try {
let validation;
// TODO: for native connectors we currently skip the validation because it is too slow (booting up Tor etc.)
if (account.connector === "nativecitadel") {
if (account.connector === "nativelnd") {
validation = { valid: true, error: "" };
} else {
validation = await msg.request("validateAccount", account);
}

if (validation.valid) {
const addResult = await msg.request("addAccount", account);
if (addResult.accountId) {
Expand All @@ -73,7 +86,10 @@ export default function ConnectCitadel() {
}
} else {
toast.error(
<ConnectionErrorToast message={validation.error as string} />
<ConnectionErrorToast
message={validation.error as string}
link={`${formData.url}/v1/getinfo`}
/>
);
}
} catch (e) {
Expand Down Expand Up @@ -101,38 +117,40 @@ export default function ConnectCitadel() {
/>
</h1>
}
description={t("page.instructions")}
description={
<Trans
i18nKey={"page.instructions"}
t={t}
// eslint-disable-next-line react/jsx-key
components={[<strong></strong>, <br />]}
/>
}
logo={logo}
submitLoading={loading}
submitDisabled={formData.password === "" || formData.url === ""}
submitDisabled={formData.url === "" || formData.macaroon === ""}
onSubmit={handleSubmit}
// fixMe: fix link when screen is publicly accessible
image="https://cdn.getalby-assets.com/connector-guides/citadel.png"
>
<div className="mb-6">
<div className="mt-6">
<TextField
label={t("password.label")}
id="password"
id="lndconnect"
type={lndconnectUrlVisible ? "text" : "password"}
autoComplete="new-password"
type={passwordViewVisible ? "text" : "password"}
autoFocus={true}
label={t("rest_url.label")}
placeholder={t("rest_url.placeholder")}
onChange={handleLndconnectUrl}
required
onChange={handleChange}
autoFocus={true}
endAdornment={
<PasswordViewAdornment
onChange={(passwordView) => {
setPasswordViewVisible(passwordView);
setLndconnectUrlVisible(passwordView);
}}
/>
}
/>
</div>
<TextField
label={t("url.label")}
id="url"
placeholder={t("url.placeholder")}
value={formData.url}
required
onChange={handleChange}
/>
{formData.url.match(/\.onion/i) && (
<div className="mt-6">
<CompanionDownloadInfo
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
},
"citadel": {
"page": {
"title": "Připojení k uzlu <0>Citadel</0>",
"instructions": "Aktuálně nefunguje v případě, že máte zapnutou dvoufaktorovou autentizaci (2FA)."
"title": "Připojení k uzlu <0>Citadel</0>"
},
"password": {
"label": "Heslo k Citadel"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/da/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@
},
"citadel": {
"page": {
"title": "Opret forbindelse til <0>Citadel</0> node",
"instructions": "Dette virker i øjeblikket ikke, hvis 2FA er slået til."
"title": "Opret forbindelse til <0>Citadel</0> node"
},
"password": {
"label": "Citadel adgangskode"
Expand Down
1 change: 0 additions & 1 deletion src/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
"description": "Verbinden mit deiner externen Lightning Wallet oder Node",
"citadel": {
"page": {
"instructions": "Das funktioniert aktuell nicht, wenn 2FA ausgewählt ist.",
"title": "Verbinden mit <0>Citadel</0> Node"
},
"password": {
Expand Down
18 changes: 9 additions & 9 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in src/i18n/locales/en/translation.json

View workflow job for this annotation

GitHub Actions / Check source translation file for changes

Translation source translation.choose_connector.citadel.page.instructions has changed

Consider running `node scripts/remove-outdated-translations.js translation.choose_connector.citadel.page.instructions` to reset existing translations.
"translation": {
"welcome": {
"set_password": {
Expand Down Expand Up @@ -149,16 +149,16 @@
"title": "Citadel",
"page": {
"title": "Connect to <0>Citadel</0> node",
"instructions": "This currently doesn't work if 2FA is enabled."
"instructions": "1. In the Citadel section of your Nirvati dashboard go to <0>Connect wallet</0><1/>2. Select <0>Alby (Tor)</0> or <0>Alby (Local Network)</0> mode<1/>3. Copy the <0>lndconnect URL</0> and paste it below"
},
"password": {
"label": "Citadel Password"
},
"url": {
"label": "Citadel URL",
"placeholder": "http://citadel.local"
"rest_url": {
"label": "lndconnect REST URL",
"placeholder": "lndconnect://yournode:8080?..."
}
},
"nirvati": {
"title": "Nirvati"
},
"umbrel": {
"title": "Umbrel",
"page": {
Expand Down Expand Up @@ -366,8 +366,8 @@
"umbrel": {
"name": "Umbrel"
},
"citadel": {
"name": "Citadel"
"nirvati": {
"name": "Nirvati"
},
"btcpay": {
"name": "BTCPay"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/eo/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
},
"citadel": {
"page": {
"title": "",
"instructions": ""
"title": ""
},
"password": {
"label": "Citadel-pasvorto"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@
"placeholder": "http://citadel.local"
},
"page": {
"title": "Conectar a nodo Citadel",
"instructions": "Esto actualmente no funciona si el 2FA está activado."
"title": "Conectar a nodo Citadel"
}
},
"umbrel": {
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/fa/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@
},
"citadel": {
"page": {
"title": "به گره <0>Citadel</0> متصل شوید",
"instructions": "در حال حاضر در صورت فعال بودن تایید دو مرحله ای، این کار نمی کند."
"title": "به گره <0>Citadel</0> متصل شوید"
},
"password": {
"label": "گذرواژه Citadel"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/fi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
},
"citadel": {
"page": {
"title": "Yhdistä <0>Citadel</0> solmuun",
"instructions": "Tämä ei tällä hetkellä toimi, jos 2FA on käytössä."
"title": "Yhdistä <0>Citadel</0> solmuun"
},
"password": {
"label": "Citadel-salasana"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
},
"citadel": {
"page": {
"title": "Connectez-vous au nœud <0>Citadelle</0>",
"instructions": "Cela ne fonctionne pas actuellement si 2FA est activé."
"title": "Connectez-vous au nœud <0>Citadelle</0>"
},
"password": {
"label": "Mot de passe Citadelle"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
},
"citadel": {
"page": {
"title": "<0>Citadel</0> node से कनेक्ट करें",
"instructions": "यह वर्तमान में काम नहीं करता है अगर 2FA सक्षम है।"
"title": "<0>Citadel</0> node से कनेक्ट करें"
},
"password": {
"label": "Citadel पासवर्ड"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/id/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
},
"citadel": {
"page": {
"title": "Sambungkan dengan node <0>Citadel</0>",
"instructions": "Saat ini tidak berfungsi jika 2FA diaktifkan."
"title": "Sambungkan dengan node <0>Citadel</0>"
},
"password": {
"label": "Kata sandi Citadel"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
},
"citadel": {
"page": {
"title": "Collega un nodo <0>Citadel</0>",
"instructions": "Attualmente non funziona se è abilitata la 2FA."
"title": "Collega un nodo <0>Citadel</0>"
},
"password": {
"label": "Password Citadel"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
},
"citadel": {
"page": {
"title": "<0>Citadel</0>ノードに接続",
"instructions": "現在のところ、2要素認証(2FA)が有効になっている場合は機能しません。"
"title": "<0>Citadel</0>ノードに接続"
},
"password": {
"label": "Citadelのパスワード"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/mr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@
},
"citadel": {
"page": {
"title": "<0>Citadel</0> node ला कनेक्ट करा",
"instructions": "This currently doesn't work if 2FA is enabled."
"title": "<0>Citadel</0> node ला कनेक्ट करा"
},
"password": {
"label": "Citadel Password"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
},
"citadel": {
"page": {
"title": "Verbinding maken met <0>Citadel</0> node",
"instructions": "Dit werkt momenteel niet als 2FA is ingeschakeld."
"title": "Verbinding maken met <0>Citadel</0> node"
},
"password": {
"label": "Citadel-wachtwoord"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/pl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@
},
"citadel": {
"page": {
"title": "Podłącz do węzła <0>Citadel</0>",
"instructions": "Ta funkcja nie działa jeśli 2FA jest włączone."
"title": "Podłącz do węzła <0>Citadel</0>"
},
"password": {
"label": "Hasło Citadel"
Expand Down
Loading
Loading