Skip to content

Commit

Permalink
Merge branch 'feat/encrypt-prompt' of https://github.com/getAlby/ligh…
Browse files Browse the repository at this point in the history
…tning-browser-extension into feat/encrypt-prompt
  • Loading branch information
reneaaron committed Dec 18, 2023
2 parents 4707330 + 008c31b commit bddb62d
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"@bitcoin-design/bitcoin-icons-react": "^0.1.10",
"@bitcoinerlab/secp256k1": "^1.0.5",
"@getalby/sdk": "^2.6.0",
"@getalby/sdk": "^3.1.0",
"@headlessui/react": "^1.7.16",
"@lightninglabs/lnc-web": "^0.2.4-alpha",
"@noble/curves": "^1.1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/app/context/AccountContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ export function AccountProvider({ children }: { children: React.ReactNode }) {
if (!response.configured && !onWelcomePage) {
utils.openPage("welcome.html");
window.close();
} else if (response.configured && onWelcomePage) {
utils.redirectPage("options.html");
} else if (response.unlocked) {
if (response.configured && onWelcomePage) {
utils.redirectPage("options.html");
}
selectAccount(response.currentAccountId, true);
} else {
setAccount(null);
Expand Down
55 changes: 29 additions & 26 deletions src/app/router/Welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
import { Outlet, Route, HashRouter as Router, Routes } from "react-router-dom";
import Container from "~/app/components/Container";
import Toaster from "~/app/components/Toast/Toaster";
import { AccountProvider } from "~/app/context/AccountContext";
import { SettingsProvider } from "~/app/context/SettingsContext";
import { getConnectorRoutes, renderRoutes } from "~/app/router/connectorRoutes";
import ChooseConnectorPath from "~/app/screens/connectors/ChooseConnectorPath";
Expand All @@ -17,34 +18,36 @@ const connectorRoutes = getConnectorRoutes();
function Welcome() {
return (
<SettingsProvider>
<Router>
<Toaster />
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<SetPassword />} />
<Route path="choose-path">
<Route index={true} element={<ChooseConnectorPath />}></Route>
<Route path="choose-connector">
<Route
index={true}
element={
<ChooseConnector
title={i18n.t("translation:choose_connector.title")}
description={i18n.t(
"translation:choose_connector.description"
)}
connectorRoutes={connectorRoutes}
/>
}
></Route>
{renderRoutes(connectorRoutes)}
<AccountProvider>
<Router>
<Toaster />
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<SetPassword />} />
<Route path="choose-path">
<Route index={true} element={<ChooseConnectorPath />}></Route>
<Route path="choose-connector">
<Route
index={true}
element={
<ChooseConnector
title={i18n.t("translation:choose_connector.title")}
description={i18n.t(
"translation:choose_connector.description"
)}
connectorRoutes={connectorRoutes}
/>
}
></Route>
{renderRoutes(connectorRoutes)}
</Route>
</Route>
<Route path="test-connection" element={<TestConnection />} />
<Route path="pin-extension" element={<PinExtension />} />
</Route>
<Route path="test-connection" element={<TestConnection />} />
<Route path="pin-extension" element={<PinExtension />} />
</Route>
</Routes>
</Router>
</Routes>
</Router>
</AccountProvider>
</SettingsProvider>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/screens/MakeInvoice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TextField from "@components/form/TextField";
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import ScreenHeader from "~/app/components/ScreenHeader";
import toast from "~/app/components/Toast";
import { useSettings } from "~/app/context/SettingsContext";
import { useNavigationState } from "~/app/hooks/useNavigationState";
import { USER_REJECTED_ERROR } from "~/common/constants";
Expand Down Expand Up @@ -91,6 +92,7 @@ function MakeInvoice() {
});
msg.reply(response);
} catch (e) {
if (e instanceof Error) toast.error(`${tCommon("error")}: ${e.message}`);
console.error(e);
} finally {
setLoading(false);
Expand Down
3 changes: 3 additions & 0 deletions src/app/screens/SendToBitcoinAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ function SendToBitcoinAddress() {
setFeesLoading(true);

const result = await api.getSwapInfo();
if (!result.available) {
throw new Error("Swaps currently not available");
}

setServiceFeePercentage(result.service_fee_percentage);
setSatsPerVbyte(result.sats_per_vbyte);
Expand Down
4 changes: 2 additions & 2 deletions src/extension/background-script/connectors/alby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Alby implements Connector {
custom_records: invoice.custom_records,
id: `${invoice.payment_request}-${index}`,
memo: invoice.comment || invoice.memo,
preimage: invoice.preimage,
preimage: invoice.preimage ?? "",
payment_hash: invoice.payment_hash,
settled: invoice.settled,
settleDate: new Date(invoice.settled_at).getTime(),
Expand Down Expand Up @@ -291,7 +291,7 @@ export default class Alby implements Connector {
}
}

let authUrl = authClient.generateAuthURL({
let authUrl = await authClient.generateAuthURL({
code_challenge_method: "S256",
authorizeUrl: process.env.ALBY_OAUTH_AUTHORIZE_URL,
});
Expand Down
4 changes: 4 additions & 0 deletions src/extension/background-script/connectors/lnc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const methods: Record<string, string> = {
sendtoroute: "lnd.lightning.SendToRouteSync",
verifymessage: "lnd.lightning.VerifyMessage",
walletbalance: "lnd.lightning.WalletBalance",
newaddress: "lnd.lightning.NewAddress",
nextaddr: "lnd.walletKit.nextAddr",
listaddresses: "lnd.walletKit.ListAddresses",
listunspent: "lnd.walletKit.ListUnspent",
};

const DEFAULT_SERVER_HOST = "mailbox.terminal.lightning.today:443";
Expand Down
16 changes: 16 additions & 0 deletions src/extension/background-script/connectors/lnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ const methods: Record<string, Record<string, string>> = {
path: "/v2/invoices/settle",
httpMethod: "POST",
},
newaddress: {
path: "/v1/newaddress",
httpMethod: "GET",
},
nextaddr: {
path: "/v2/wallet/address/next",
httpMethod: "POST",
},
listaddresses: {
path: "/v2/wallet/addresses",
httpMethod: "GET",
},
listunspent: {
path: "/v2/wallet/utxos",
httpMethod: "POST",
},
};

const pathTemplateParser = (
Expand Down
12 changes: 10 additions & 2 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,11 @@
"routermc": "Read the internal mission control state",
"addinvoice": "Create new invoices",
"addholdinvoice": "Create new HODL invoices",
"settleinvoice": "Settle an accepted invoice"
"settleinvoice": "Settle an accepted invoice",
"newaddress": "Get a new onchain address",
"nextaddr": "Get the next unused address within the wallet",
"listaddresses": "Get all the addresses along with their balance",
"listunspent": "Get a list of all utxos spendable by the wallet"
},
"lnc": {
"getinfo": "Get the node information",
Expand All @@ -1239,7 +1243,11 @@
"routermc": "Read the internal mission control state",
"addinvoice": "Create new invoices",
"addholdinvoice": "Create new HODL invoices",
"settleinvoice": "Settle an accepted invoice"
"settleinvoice": "Settle an accepted invoice",
"newaddress": "Get a new onchain address",
"nextaddr": "Get the next unused onchain address within the wallet",
"listaddresses": "Get all the onchain addresses along with their balance",
"listunspent": "Get a list of all utxos spendable by the wallet"
}
}
}
27 changes: 16 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,13 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.52.0.tgz#78fe5f117840f69dc4a353adf9b9cd926353378c"
integrity sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==

"@getalby/sdk@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-2.6.0.tgz#51508c7833b0580575055f15b8fe21567b76288a"
integrity sha512-klD1FrpGY39QldPf00KtzIveWj0dXtgGdZH6nLWdJ0Ness7FAqy2RkgSF7JQfKJeJSFek7Ip3AL/KCT5/lZgww==
"@getalby/sdk@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-3.1.0.tgz#49a6d7b292f3c6ab1c37e72422aa0f0ec8f43226"
integrity sha512-1WwwMfrCRtlUv3BnT/rqYiE5giztH5ZxfT1fDwhaJGeC8EJXxGjFBbaUhE0Wq98Fcs/hKoGM4gSmp3UHFDuQxg==
dependencies:
crypto-js "^4.1.1"
events "^3.3.0"
nostr-tools "1.13.1"
nostr-tools "^1.17.0"

"@headlessui/react@^1.7.16":
version "1.7.16"
Expand Down Expand Up @@ -1053,6 +1052,11 @@
strict-event-emitter "^0.2.4"
web-encoding "^1.1.5"

"@noble/[email protected]":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@noble/ciphers/-/ciphers-0.2.0.tgz#a12cda60f3cf1ab5d7c77068c3711d2366649ed7"
integrity sha512-6YBxJDAapHSdd3bLDv6x2wRPwq4QFMUaB3HvljNBUTThDd12eSm7/3F+2lnfzx2jvM+S6Nsy0jEt9QbPqSwqRw==

"@noble/[email protected]", "@noble/curves@^1.1.0", "@noble/curves@~1.1.0":
version "1.1.0"
resolved "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz"
Expand Down Expand Up @@ -3482,7 +3486,7 @@ cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

[email protected], crypto-js@^4.1.1:
[email protected]:
version "4.1.1"
resolved "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz"
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
Expand Down Expand Up @@ -7147,11 +7151,12 @@ normalize-range@^0.1.2:
resolved "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz"
integrity "sha1-LRDAa9/TEuqXd2laTShDlFa3WUI= sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA=="

nostr-tools@1.13.1:
version "1.13.1"
resolved "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.13.1.tgz"
integrity sha512-DTwpbxTH1/ar+afWd4gmVdpHH8CF290kdaxi00Llra88SHE6e38XuyzlRABVTcrBaceLMnoDdHmV3x16MoEFJg==
nostr-tools@^1.17.0:
version "1.17.0"
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.17.0.tgz#b6f62e32fedfd9e68ec0a7ce57f74c44fc768e8c"
integrity sha512-LZmR8GEWKZeElbFV5Xte75dOeE9EFUW/QLI1Ncn3JKn0kFddDKEfBbFN8Mu4TMs+L4HR/WTPha2l+PPuRnJcMw==
dependencies:
"@noble/ciphers" "0.2.0"
"@noble/curves" "1.1.0"
"@noble/hashes" "1.3.1"
"@scure/base" "1.1.1"
Expand Down

0 comments on commit bddb62d

Please sign in to comment.