Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into task-permissions-re…
Browse files Browse the repository at this point in the history
…vamp
  • Loading branch information
rolznz committed Jul 14, 2024
2 parents 21bcd22 + 7b9e4d5 commit 42242bd
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 99 deletions.
10 changes: 3 additions & 7 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,11 @@ func (api *api) Stop() error {
return errors.New("LNClient not started")
}

// TODO: this should stop everything related to the lnclient
// stop the lnclient
// stop the lnclient, nostr relay etc.
// The user will be forced to re-enter their unlock password to restart the node
err := api.svc.StopLNClient()
if err != nil {
logger.Logger.WithError(err).Error("Failed to stop LNClient")
}
api.svc.StopApp()

return err
return nil
}

func (api *api) GetNodeConnectionInfo(ctx context.Context) (*lnclient.NodeConnectionInfo, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ func main() {
defer cancel()
e.Shutdown(ctx)
logger.Logger.Info("Echo server exited")
svc.WaitShutdown()
svc.Shutdown()
logger.Logger.Info("Service exited")
}
1 change: 1 addition & 0 deletions frontend/public/images/illustrations/alby-account-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/src/components/SidebarHint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function SidebarHint() {
title="Open Your First Channel"
description="Deposit bitcoin by onchain or lightning payment to start using your new wallet."
buttonText="Begin Now"
buttonLink="/channels"
buttonLink="/channels/outgoing"
/>
);
}
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/components/TransactionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ function TransactionItem({ tx }: Props) {
className={cn(
"w-6 h-6 md:w-8 md:h-8",
type === "outgoing"
? "text-orange-400 dark:text-amber-600 stroke-orange-400 dark:stroke-amber-600"
: "text-green-500 dark:text-emerald-500 stroke-green-400 dark:stroke-emerald-500"
? "stroke-orange-400 dark:stroke-amber-600"
: "stroke-green-400 dark:stroke-emerald-500"
)}
/>
</div>
</div>
<div className="overflow-hidden mr-3">
<div className="flex items-center gap-2 truncate dark:text-white">
<div className="flex items-center gap-2 truncate">
<p className="text-lg md:text-xl font-semibold">
{type == "incoming" ? "Received" : "Sent"}
</p>
Expand All @@ -86,12 +86,12 @@ function TransactionItem({ tx }: Props) {
{tx.description || "Lightning invoice"}
</p>
</div>
<div className="flex ml-auto text-right space-x-3 shrink-0 dark:text-white">
<div className="flex ml-auto text-right space-x-3 shrink-0">
<div className="flex items-center gap-2 text-xl">
<p
className={cn(
"font-semibold",
type == "incoming" && "text-green-600 dark:color-green-400"
type == "incoming" && "text-green-600 dark:text-emerald-500"
)}
>
{type == "outgoing" ? "-" : "+"}
Expand All @@ -104,7 +104,7 @@ function TransactionItem({ tx }: Props) {
</p>

{/* {!!tx.totalAmountFiat && (
<p className="text-xs text-gray-400 dark:text-neutral-600">
<p className="text-xs text-muted-foreground">
~{tx.totalAmountFiat}
</p>
)} */}
Expand Down Expand Up @@ -133,8 +133,8 @@ function TransactionItem({ tx }: Props) {
className={cn(
"w-6 h-6 md:w-8 md:h-8",
type === "outgoing"
? "text-orange-400 dark:text-amber-600 stroke-orange-400 dark:stroke-amber-600"
: "text-green-500 dark:text-emerald-500 stroke-green-400 dark:stroke-emerald-500"
? "stroke-orange-400 dark:stroke-amber-600"
: "stroke-green-400 dark:stroke-emerald-500"
)}
/>
</div>
Expand All @@ -145,13 +145,13 @@ function TransactionItem({ tx }: Props) {
)}{" "}
{Math.floor(tx.amount / 1000) == 1 ? "sat" : "sats"}
</p>
{/* <p className="text-sm md:text-base text-gray-500">
{/* <p className="text-sm md:text-base text-muted-foreground">
Fiat Amount
</p> */}
</div>
</div>
<div className="mt-8">
<p className="dark:text-white">Date & Time</p>
<p>Date & Time</p>
<p className="text-muted-foreground">
{dayjs(tx.settled_at * 1000)
.tz(dayjs.tz.guess())
Expand All @@ -160,7 +160,7 @@ function TransactionItem({ tx }: Props) {
</div>
{type == "outgoing" && (
<div className="mt-6">
<p className="dark:text-white">Fee</p>
<p>Fee</p>
<p className="text-muted-foreground">
{new Intl.NumberFormat(undefined, {}).format(
Math.floor(tx.fees_paid / 1000)
Expand All @@ -171,7 +171,7 @@ function TransactionItem({ tx }: Props) {
)}
{tx.description && (
<div className="mt-6">
<p className="dark:text-white">Description</p>
<p>Description</p>
<p className="text-muted-foreground">{tx.description}</p>
</div>
)}
Expand All @@ -191,7 +191,7 @@ function TransactionItem({ tx }: Props) {
{showDetails && (
<>
<div className="mt-6 !ml-0">
<p className="dark:text-white">Preimage</p>
<p>Preimage</p>
<div className="flex items-center gap-4">
<p className="text-muted-foreground break-all">
{tx.preimage}
Expand All @@ -205,7 +205,7 @@ function TransactionItem({ tx }: Props) {
</div>
</div>
<div className="mt-6 !ml-0">
<p className="dark:text-white">Hash</p>
<p>Hash</p>
<div className="flex items-center gap-4">
<p className="text-muted-foreground break-all">
{tx.payment_hash}
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/components/connections/AlbyConnectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import { Separator } from "src/components/ui/separator";
import { useAlbyMe } from "src/hooks/useAlbyMe";
import { LinkStatus, useLinkAccount } from "src/hooks/useLinkAccount";
import { App, BudgetRenewalType } from "src/types";
import linkAccountIllustration from "/images/illustrations/link-account.png";
import albyAccountDark from "/images/illustrations/alby-account-dark.svg";
import albyAccountLight from "/images/illustrations/alby-account-light.svg";

function AlbyConnectionCard({ connection }: { connection?: App }) {
const { data: albyMe } = useAlbyMe();
Expand Down Expand Up @@ -93,8 +94,12 @@ function AlbyConnectionCard({ connection }: { connection?: App }) {
every app you access through your Alby Account will handle
payments via the Hub.
<img
src={linkAccountIllustration}
className="w-80 mx-auto"
src={albyAccountDark}
className="w-full hidden dark:block"
/>
<img
src={albyAccountLight}
className="w-full dark:hidden"
/>
You can add a budget that will restrict how much can be
spent from the Hub with your Alby Account.
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/icons/Apple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function AppleIcon(props: SVGAttributes<SVGElement>) {
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clip-path="url(#a)" stroke="currentColor" strokeLinejoin="round">
<g clipPath="url(#a)" stroke="currentColor" strokeLinejoin="round">
<path d="M9.978.758c-.578.04-1.254.41-1.648.892-.359.437-.654 1.086-.54 1.717.632.02 1.285-.36 1.663-.85.354-.455.621-1.1.525-1.76ZM13.573 5.697c-.717-.898-1.724-1.42-2.675-1.42-1.256 0-1.787.601-2.66.601-.899 0-1.582-.599-2.668-.599-1.067 0-2.202.652-2.923 1.767-1.012 1.57-.839 4.52.802 7.035.587.9 1.371 1.91 2.397 1.92.912.008 1.17-.586 2.406-.592 1.236-.007 1.47.6 2.381.59 1.027-.008 1.854-1.13 2.44-2.029.422-.645.578-.97.905-1.697-2.374-.904-2.755-4.28-.405-5.576Z" />
</g>
<defs>
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/icons/NostrWalletConnectIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export function NostrWalletConnectIcon(props: SVGAttributes<SVGElement>) {
<path
d="M19.0762 10.4686L12.1498 3.49661L12.139 3.48643C11.5326 2.95054 10.7514 2.66751 9.93962 2.6898C9.12414 2.71209 8.35652 3.04096 7.77802 3.61595L2.08467 9.27969C1.48133 9.87936 1.14795 10.6778 1.146 11.5277C1.14406 12.3776 1.47366 13.1774 2.07414 13.78L9.83155 21.5627C10.4324 22.1654 11.2324 22.4985 12.0842 22.5005H12.0918C12.9406 22.5005 13.7393 22.1714 14.3411 21.5732M15.4823 2.6898L15.9356 2.23648C16.2346 1.93664 16.5882 1.72403 16.987 1.60457C17.3604 1.49266 17.7627 1.47003 18.1504 1.5393C18.5381 1.60857 18.9079 1.76907 19.2197 2.00352C19.5522 2.25363 19.8101 2.57518 19.986 2.95927L20.0071 3.00499L20.0119 3.02134L22.6604 10.8165C22.7892 11.1548 22.8544 11.5099 22.8544 11.8719C22.8544 12.2652 22.7777 12.6489 22.6264 13.0122C22.4753 13.3753 22.257 13.7003 21.9778 13.978L20.1633 15.7816"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M14.2662 15.6078C14.2662 15.6078 13.5444 16.3647 12.9536 16.6056C12.3981 16.8322 11.9234 16.7415 11.4177 16.6274C10.8145 16.4912 10.2642 16.1871 9.82651 15.7478L8.87089 14.7887C8.69428 14.6115 8.59742 14.3766 8.59822 14.1276C8.59903 13.8785 8.69733 13.6443 8.87501 13.4681L12.1782 10.1948C12.3549 10.0197 12.5893 9.92325 12.838 9.92325H12.8404C13.0908 9.92406 13.3257 10.0221 13.5025 10.1993L14.4582 11.1584C14.8903 11.5921 15.1901 12.135 15.3251 12.7285C15.4383 13.2256 15.4892 13.6773 15.3095 14.2394C15.105 14.8795 14.2662 15.6078 14.2662 15.6078ZM14.2662 15.6078L19.0305 20.3721M9.41292 12.9364L7.20264 10.7261M11.4322 10.9322L9.21436 8.71436"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/layouts/SettingsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function SettingsLayout() {
<MenuItem to="/settings/key-backup">Key Backup</MenuItem>
)}
{hasNodeBackup && (
<MenuItem to="/settings/node-backup">Node Backup</MenuItem>
<MenuItem to="/settings/node-backup">Migrate Node</MenuItem>
)}
<MenuItem to="/debug-tools">
Debug Tools
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons";
import * as React from "react";

import { cn } from "src/lib/utils";

Expand Down Expand Up @@ -36,7 +36,7 @@ const DialogContent = React.forwardRef<
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
"fixed max-h-[90%] overflow-y-auto left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
Expand Down Expand Up @@ -108,13 +108,13 @@ DialogDescription.displayName = DialogPrimitive.Description.displayName;

export {
Dialog,
DialogPortal,
DialogOverlay,
DialogTrigger,
DialogClose,
DialogContent,
DialogHeader,
DialogDescription,
DialogFooter,
DialogHeader,
DialogOverlay,
DialogPortal,
DialogTitle,
DialogDescription,
DialogTrigger,
};
29 changes: 26 additions & 3 deletions frontend/src/screens/BackupNode.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { InfoCircledIcon } from "@radix-ui/react-icons";
import { AlertTriangleIcon } from "lucide-react";
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";

import Container from "src/components/Container";
import SettingsHeader from "src/components/SettingsHeader";
import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert";
import { Button } from "src/components/ui/button";
import { Input } from "src/components/ui/input";
import { Label } from "src/components/ui/label";
Expand Down Expand Up @@ -80,9 +83,28 @@ export function BackupNode() {
return (
<>
<SettingsHeader
title="Backup Your Node"
description="Your Alby Hub will be stopped and you will receive a backup file you can import on another host or machine"
title="Migrate Your Node"
description="Your Alby Hub will be stopped and you will receive a backup file you can import on another host or machine."
/>
<Alert>
<AlertTriangleIcon className="h-4 w-4" />
<AlertTitle>Do not run your node on multiple devices</AlertTitle>
<AlertDescription>
Your node maintains channel state with your channel partners. After
you create this backup, do not restart Alby Hub on this device.
</AlertDescription>
</Alert>
<Alert>
<InfoCircledIcon className="h-4 w-4" />
<AlertTitle>What Happens Next</AlertTitle>
<AlertDescription>
You'll need to enter your unlock password to encrypt and download a
backup of your Alby Hub data. After your encrypted backup is
downloaded, we'll give you instructions on how to import the backup
file on another host or machine. Your unlock password will be needed
again to restore your backup.
</AlertDescription>
</Alert>
{showPasswordScreen ? (
<Container>
<h1 className="text-xl font-medium">Enter unlock password</h1>
Expand Down Expand Up @@ -114,9 +136,10 @@ export function BackupNode() {
type="submit"
disabled={loading}
size="lg"
className="w-full"
onClick={() => setShowPasswordScreen(true)}
>
Create Backup
Create Backup To Migrate Node
</Button>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/Intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function Intro() {
api={api}
icon={ShieldCheck}
title="Your Keys Are Safe"
description="You wallet is encrypted by a password of your choice. No one can access your funds but you."
description="Your wallet is encrypted by a password of your choice. No one can access your funds but you."
/>
</CarouselItem>
<CarouselItem>
Expand Down
18 changes: 11 additions & 7 deletions frontend/src/screens/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,17 @@ export default function Channels() {
channel.localBalance + channel.remoteBalance;

let channelWarning = "";
if (channel.localSpendableBalance < capacity * 0.1) {
channelWarning =
"Spending balance low. You may have trouble sending payments through this channel.";
}
if (channel.localSpendableBalance > capacity * 0.9) {
channelWarning =
"Receiving capacity low. You may have trouble receiving payments through this channel.";
if (channel.error) {
channelWarning = channel.error;
} else {
if (channel.localSpendableBalance < capacity * 0.1) {
channelWarning =
"Spending balance low. You may have trouble sending payments through this channel.";
}
if (channel.localSpendableBalance > capacity * 0.9) {
channelWarning =
"Receiving capacity low. You may have trouble receiving payments through this channel.";
}
}

return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/wallet/OnboardingChecklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function OnboardingChecklist() {
checked: hasChannel,
to: canMigrateAlbyFundsToNewChannel
? "/onboarding/lightning/migrate-alby"
: "/channels",
: "/channels/outgoing",
},
{
title: "Send or receive your first payment",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export type Channel = {
forwardingFeeBaseMsat: number;
unspendablePunishmentReserve: number;
counterpartyUnspendablePunishmentReserve: number;
error?: string;
};

export type UpdateChannelRequest = {
Expand Down
14 changes: 13 additions & 1 deletion lnclient/ldk/ldk.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
"0364913d18a19c671bb36dd04d6ad5be0fe8f2894314c36a9db3f03c2d414907e1@192.243.215.102:9735", // LQwD
"035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226@170.75.163.209:9735", // WoS
"02fcc5bfc48e83f06c04483a2985e1c390cb0f35058baa875ad2053858b8e80dbd@35.239.148.251:9735", // Blink
"027100442c3b79f606f80f322d98d499eefcb060599efc5d4ecb00209c2cb54190@3.230.33.224:9735", // c=
}
logger.Logger.Info("Connecting to some peers to retrieve P2P gossip data")
for _, peer := range peers {
Expand Down Expand Up @@ -832,21 +833,32 @@ func (ls *LDKService) ListChannels(ctx context.Context) ([]lnclient.Channel, err
unspendablePunishmentReserve = *ldkChannel.UnspendablePunishmentReserve
}

var channelError *string

if ldkChannel.CounterpartyForwardingInfoFeeBaseMsat == nil {
// if we don't have this, routing will not work (LND <-> LDK interoperability bug - https://github.com/lightningnetwork/lnd/issues/6870 )
channelErrorValue := "Counterparty forwarding info not available. Please contact support@getalby.com"
channelError = &channelErrorValue
}

isActive := ldkChannel.IsUsable /* superset of ldkChannel.IsReady */ && channelError == nil

channels = append(channels, lnclient.Channel{
InternalChannel: internalChannel,
LocalBalance: int64(ldkChannel.ChannelValueSats*1000 - ldkChannel.InboundCapacityMsat - ldkChannel.CounterpartyUnspendablePunishmentReserve*1000),
LocalSpendableBalance: int64(ldkChannel.OutboundCapacityMsat),
RemoteBalance: int64(ldkChannel.InboundCapacityMsat),
RemotePubkey: ldkChannel.CounterpartyNodeId,
Id: ldkChannel.UserChannelId, // CloseChannel takes the UserChannelId
Active: ldkChannel.IsUsable, // superset of ldkChannel.IsReady
Active: isActive,
Public: ldkChannel.IsPublic,
FundingTxId: fundingTxId,
Confirmations: ldkChannel.Confirmations,
ConfirmationsRequired: ldkChannel.ConfirmationsRequired,
ForwardingFeeBaseMsat: ldkChannel.Config.ForwardingFeeBaseMsat(),
UnspendablePunishmentReserve: unspendablePunishmentReserve,
CounterpartyUnspendablePunishmentReserve: ldkChannel.CounterpartyUnspendablePunishmentReserve,
Error: channelError,
})
}

Expand Down
1 change: 1 addition & 0 deletions lnclient/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type Channel struct {
ForwardingFeeBaseMsat uint32 `json:"forwardingFeeBaseMsat"`
UnspendablePunishmentReserve uint64 `json:"unspendablePunishmentReserve"`
CounterpartyUnspendablePunishmentReserve uint64 `json:"counterpartyUnspendablePunishmentReserve"`
Error *string `json:"error"`
}

type NodeStatus struct {
Expand Down
Loading

0 comments on commit 42242bd

Please sign in to comment.