diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index 53f032996..f27e66053 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -5,10 +5,10 @@ spec: image: registry_type: GHCR registry: getalby - repository: nostr-wallet-connect-next + repository: hub instance_size_slug: basic-xxs envs: - - key: LDK_ESPLORA_SERVER - value: "https://electrs.albylabs.com" - - key: LOG_EVENTS - value: "true" + - key: LDK_ESPLORA_SERVER + value: "https://electrs.getalby.com" + - key: LOG_EVENTS + value: "true" diff --git a/.github/workflows/http.yml b/.github/workflows/http.yml index f7831940b..947e2c6e6 100644 --- a/.github/workflows/http.yml +++ b/.github/workflows/http.yml @@ -94,7 +94,7 @@ jobs: env: CGO_ENABLED: 1 TAG: ${{ github.ref_name }} - run: go build ${{ env.GOTAGS }} -o build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }} -ldflags "-X 'github.com/getAlby/nostr-wallet-connect/version.Tag=${{ env.TAG }}'" cmd/http/main.go + run: go build ${{ env.GOTAGS }} -o build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }} -ldflags "-X 'github.com/getAlby/hub/version.Tag=${{ env.TAG }}'" cmd/http/main.go - name: Copy shared libraries to the output directory run: | diff --git a/.github/workflows/wails.yml b/.github/workflows/wails.yml index 3b89a1470..23d108274 100644 --- a/.github/workflows/wails.yml +++ b/.github/workflows/wails.yml @@ -54,7 +54,7 @@ jobs: - name: Setup GoLang uses: actions/setup-go@v5 with: - go-version-file: './go.mod' + go-version-file: "./go.mod" - name: Get dependencies run: go get -v -t -d ./... @@ -101,17 +101,17 @@ jobs: - name: Build App if: runner.os == 'macOS' - run: wails build --platform darwin/universal -webview2 embed -o ${{ env.EXEC_NAME }} -tags "wails" -ldflags "-X 'github.com/getAlby/nostr-wallet-connect/version.Tag=${{ env.TAG }}'" + run: wails build --platform darwin/universal -webview2 embed -o ${{ env.EXEC_NAME }} -tags "wails" -ldflags "-X 'github.com/getAlby/hub/version.Tag=${{ env.TAG }}'" shell: bash - name: Build App if: runner.os == 'Linux' - run: wails build --platform linux/amd64 -webview2 embed -o ${{ env.EXEC_NAME }} -tags "wails" -ldflags "-X 'github.com/getAlby/nostr-wallet-connect/version.Tag=${{ env.TAG }}'" + run: wails build --platform linux/amd64 -webview2 embed -o ${{ env.EXEC_NAME }} -tags "wails" -ldflags "-X 'github.com/getAlby/hub/version.Tag=${{ env.TAG }}'" shell: bash - name: Build Windows App if: runner.os == 'Windows' - run: wails build --platform windows/amd64 -webview2 embed -o ${{ env.EXEC_NAME }}.exe -tags "wails" -ldflags "-X 'github.com/getAlby/nostr-wallet-connect/version.Tag=${{ env.TAG }}'" + run: wails build --platform windows/amd64 -webview2 embed -o ${{ env.EXEC_NAME }}.exe -tags "wails" -ldflags "-X 'github.com/getAlby/hub/version.Tag=${{ env.TAG }}'" shell: bash - name: Import Code-Signing Certificates for macOS diff --git a/Dockerfile b/Dockerfile index f72de98af..386c383f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ COPY . . COPY --from=frontend /build/frontend/dist ./frontend/dist RUN GOARCH=$(echo "$TARGETPLATFORM" | cut -d'/' -f2) go build \ - -ldflags="-X 'github.com/getAlby/nostr-wallet-connect/version.Tag=$TAG'" \ + -ldflags="-X 'github.com/getAlby/hub/version.Tag=$TAG'" \ -o main cmd/http/main.go COPY ./build/docker/copy_dylibs.sh . diff --git a/README.md b/README.md index 23563a16b..5554dfe04 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Nostr Wallet Connect (Next) +# Alby Hub -This is a self-sovereign, self-custodial, single-user rewrite of NWC currently in an experimental phase development. **❗This version is not backwards compatible with NWC - it requires a fresh database and connections to be re-added** +This is a self-sovereign, self-custodial, single-user rewrite of the original [Nostr Wallet Connect](https://github.com/getAlby/nostr-wallet-connect) app. **❗This version is not backwards compatible with the original app - it requires a fresh database and connections to be re-added** This application allows you to control your Lightning node or wallet from any other application that supports [NWC](https://nwc.dev/). Connect apps like [Damus](https://damus.io/) or [Amethyst](https://linktr.ee/amethyst.social) to your node. There are many more available on https://nwc.dev/. @@ -16,10 +16,12 @@ Ideally the app runs 24/7 (on a node, VPS or always-online desktop/laptop machin ## Supported Backends -- LND (see: lnd.go) -- Breez (see: breez.go) -- Greenlight (see: greenlight.go) -- LDK (see: ldk.go) +- LND +- Breez +- Greenlight +- LDK +- Pheonixd +- Cashu - want more? please open an issue. ## Installation @@ -123,7 +125,7 @@ For more information refer to: ### Versioning - $ go run -ldflags="-X 'github.com/getAlby/nostr-wallet-connect/version.Tag=v0.6.0'" cmd/http/main.go + $ go run -ldflags="-X 'github.com/getAlby/hub/version.Tag=v0.6.0'" cmd/http/main.go ### Windows @@ -135,9 +137,9 @@ Breez SDK requires gcc to build the Breez bindings. Run `choco install mingw` an - `CLIENT_NOSTR_PUBKEY`: if set, this service will only listen to events authored by this public key. You can set this to your own nostr public key. - `RELAY`: default: "wss://relay.getalby.com/v1" - `COOKIE_SECRET`: a randomly generated secret string. (only needed in http mode) -- `DATABASE_URI`: a sqlite filename. Default: $XDG_DATA_HOME/nostr-wallet-connect/nwc.db +- `DATABASE_URI`: a sqlite filename. Default: $XDG_DATA_HOME/albyhub/nwc.db - `PORT`: the port on which the app should listen on (default: 8080) -- `WORK_DIR`: directory to store NWC data files. Default: $XDG_DATA_HOME/nostr-wallet-connect +- `WORK_DIR`: directory to store NWC data files. Default: $XDG_DATA_HOME/albyhub - `LOG_LEVEL`: log level for the application. Higher is more verbose. Default: 4 (info) ### LND Backend parameters @@ -179,9 +181,9 @@ Create an OAuth client at the [Alby Developer Portal](https://getalby.com/develo Follow the steps to integrate Mutinynet with your NWC Next setup: -1. Configure your environment with the [Mutinynet LDK parameters](https://github.com/getAlby/nostr-wallet-connect-next#mutinynet) +1. Configure your environment with the [Mutinynet LDK parameters](https://github.com/getAlby/hub#mutinynet) -2. Proceed as described in the [Development](https://github.com/getAlby/nostr-wallet-connect-next#Development) section to run the frontend and backend +2. Proceed as described in the [Development](https://github.com/getAlby/hub#Development) section to run the frontend and backend 3. During onboarding, after setting your password and authorizing via Alby OAuth, you'll be directed to `/onboarding/lightning/migrate-alby`. Click "Skip For Now" to access your wallet interface @@ -332,11 +334,11 @@ Run NWC on your own node! ### Digital Ocean -[![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/getAlby/nostr-wallet-connect-next/tree/master) +[![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/getAlby/hub/tree/master) ### Render -[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/getAlby/nostr-wallet-connect-next) +[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/getAlby/hub) ### Fly @@ -378,10 +380,16 @@ LDK logs: _Tested on Linux only_ -`docker run -v ~/.local/share/alby-nwc:/data -e WORK_DIR='/data' -p 8080:8080 ghcr.io/getalby/nostr-wallet-connect-next:latest` +`docker run -v ~/.local/share/albyhub:/data -e WORK_DIR='/data' -p 8080:8080 ghcr.io/getalby/hub:latest` #### From Source _Tested on Linux only_ -`docker run -v ~/.local/share/alby-nwc:/data -e WORK_DIR='/data' -p 8080:8080 $(docker build -q .)` +##### Docker Compose + +`docker compose up` + +##### Manually + +`docker run -v ~/.local/share/albyhub:/data -e WORK_DIR='/data' -p 8080:8080 $(docker build -q .)` diff --git a/alby/alby_oauth_service.go b/alby/alby_oauth_service.go index 1b3cc19d6..407c139b0 100644 --- a/alby/alby_oauth_service.go +++ b/alby/alby_oauth_service.go @@ -16,14 +16,14 @@ import ( "golang.org/x/oauth2" "gorm.io/gorm" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - nip47 "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/service/keys" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + nip47 "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/service/keys" + "github.com/getAlby/hub/transactions" ) type albyOAuthService struct { @@ -259,15 +259,18 @@ func (svc *albyOAuthService) DrainSharedWallet(ctx context.Context, lnClient lnc return err } - amount := int64(math.Floor( - float64(balance.Balance)*1000* // Alby shared node balance in sats - (1-8/1000)* // Alby service fee (0.8%) - 0.99)) - // Maximum potential routing fees (1%) - 10000 // Alby fee reserve (10 sats) + balanceSat := float64(balance.Balance) - if amount < 1000 { + amountSat := int64(math.Floor( + balanceSat- // Alby shared node balance in sats + (balanceSat*(8/1000))- // Alby service fee (0.8%) + (balanceSat*0.01))) - // Maximum potential routing fees (1%) + 10 // Alby fee reserve (10 sats) + + if amountSat < 1 { return errors.New("Not enough balance remaining") } + amount := amountSat * 1000 logger.Logger.WithField("amount", amount).WithError(err).Error("Draining Alby shared wallet funds") diff --git a/alby/models.go b/alby/models.go index 62073afca..625f8b4e1 100644 --- a/alby/models.go +++ b/alby/models.go @@ -3,8 +3,8 @@ package alby import ( "context" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" ) type AlbyOAuthService interface { @@ -52,6 +52,7 @@ type ChannelPeerSuggestion struct { Pubkey string `json:"pubkey"` Host string `json:"host"` MinimumChannelSize uint64 `json:"minimumChannelSize"` + MaximumChannelSize uint64 `json:"maximumChannelSize"` Name string `json:"name"` Image string `json:"image"` BrokenLspUrl string `json:"lsp_url"` diff --git a/api/api.go b/api/api.go index 0e9b82db3..5ca16a363 100644 --- a/api/api.go +++ b/api/api.go @@ -15,17 +15,17 @@ import ( "github.com/sirupsen/logrus" "gorm.io/gorm" - "github.com/getAlby/nostr-wallet-connect/alby" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/service" - "github.com/getAlby/nostr-wallet-connect/service/keys" - "github.com/getAlby/nostr-wallet-connect/utils" - "github.com/getAlby/nostr-wallet-connect/version" + "github.com/getAlby/hub/alby" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + permissions "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/service" + "github.com/getAlby/hub/service/keys" + "github.com/getAlby/hub/utils" + "github.com/getAlby/hub/version" ) type api struct { diff --git a/api/backup.go b/api/backup.go index f264a2cf1..d38f90234 100644 --- a/api/backup.go +++ b/api/backup.go @@ -16,9 +16,9 @@ import ( "crypto/rand" "crypto/sha256" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/utils" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/utils" "golang.org/x/crypto/pbkdf2" ) diff --git a/api/esplora.go b/api/esplora.go index 8dd0e31a4..d7c4af8d0 100644 --- a/api/esplora.go +++ b/api/esplora.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/logger" "github.com/sirupsen/logrus" ) diff --git a/api/lsp.go b/api/lsp.go index cf85d5aee..2d3f0e2e1 100644 --- a/api/lsp.go +++ b/api/lsp.go @@ -13,10 +13,10 @@ import ( "strings" "time" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/lsp" - "github.com/getAlby/nostr-wallet-connect/utils" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/lsp" + "github.com/getAlby/hub/utils" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" ) diff --git a/api/models.go b/api/models.go index e309fd7fe..c16838e2e 100644 --- a/api/models.go +++ b/api/models.go @@ -5,9 +5,9 @@ import ( "io" "time" - "github.com/getAlby/nostr-wallet-connect/alby" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/lnclient" + "github.com/getAlby/hub/alby" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/lnclient" ) type API interface { @@ -34,7 +34,7 @@ type API interface { SignMessage(ctx context.Context, message string) (*SignMessageResponse, error) RedeemOnchainFunds(ctx context.Context, toAddress string) (*RedeemOnchainFundsResponse, error) GetBalances(ctx context.Context) (*BalancesResponse, error) - ListTransactions(ctx context.Context) (*ListTransactionsResponse, error) + ListTransactions(ctx context.Context, limit uint64, offset uint64) (*ListTransactionsResponse, error) SendPayment(ctx context.Context, invoice string) (*SendPaymentResponse, error) CreateInvoice(ctx context.Context, amount int64, description string) (*MakeInvoiceResponse, error) LookupInvoice(ctx context.Context, paymentHash string) (*LookupInvoiceResponse, error) diff --git a/api/transactions.go b/api/transactions.go index 27bf5a08e..e99df5236 100644 --- a/api/transactions.go +++ b/api/transactions.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/transactions" ) func (api *api) CreateInvoice(ctx context.Context, amount int64, description string) (*MakeInvoiceResponse, error) { @@ -31,11 +31,11 @@ func (api *api) LookupInvoice(ctx context.Context, paymentHash string) (*LookupI } // TODO: accept offset, limit params for pagination -func (api *api) ListTransactions(ctx context.Context) (*ListTransactionsResponse, error) { +func (api *api) ListTransactions(ctx context.Context, limit uint64, offset uint64) (*ListTransactionsResponse, error) { if api.svc.GetLNClient() == nil { return nil, errors.New("LNClient not started") } - transactions, err := api.svc.GetTransactionsService().ListTransactions(ctx, 0, 0, 20, 0, false, "", api.svc.GetLNClient()) + transactions, err := api.svc.GetTransactionsService().ListTransactions(ctx, 0, 0, limit, offset, false, "", api.svc.GetLNClient()) if err != nil { return nil, err } diff --git a/cmd/http/main.go b/cmd/http/main.go index a953049e5..929dec5de 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -10,9 +10,9 @@ import ( "time" echologrus "github.com/davrux/echo-logrus/v4" - "github.com/getAlby/nostr-wallet-connect/http" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service" + "github.com/getAlby/hub/http" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service" "github.com/labstack/echo/v4" log "github.com/sirupsen/logrus" ) diff --git a/config/config.go b/config/config.go index 0fad5cd46..54f956fdf 100644 --- a/config/config.go +++ b/config/config.go @@ -7,8 +7,8 @@ import ( "fmt" "os" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/logger" "gorm.io/gorm" "gorm.io/gorm/clause" ) diff --git a/config/models.go b/config/models.go index a8a704c3a..b20cb9a5d 100644 --- a/config/models.go +++ b/config/models.go @@ -25,7 +25,7 @@ type AppConfig struct { CookieSecret string `envconfig:"COOKIE_SECRET"` LogLevel string `envconfig:"LOG_LEVEL"` LDKNetwork string `envconfig:"LDK_NETWORK" default:"bitcoin"` - LDKEsploraServer string `envconfig:"LDK_ESPLORA_SERVER" default:"https://electrs.albylabs.com"` // TODO: remove LDK prefix + LDKEsploraServer string `envconfig:"LDK_ESPLORA_SERVER" default:"https://electrs.getalby.com"` // TODO: remove LDK prefix LDKGossipSource string `envconfig:"LDK_GOSSIP_SOURCE"` LDKLogLevel string `envconfig:"LDK_LOG_LEVEL"` MempoolApi string `envconfig:"MEMPOOL_API" default:"https://mempool.space/api"` diff --git a/db/db.go b/db/db.go index d6cbbbb3a..acc908ed5 100644 --- a/db/db.go +++ b/db/db.go @@ -3,8 +3,8 @@ package db import ( "fmt" - "github.com/getAlby/nostr-wallet-connect/db/migrations" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/db/migrations" + "github.com/getAlby/hub/logger" "github.com/glebarez/sqlite" "gorm.io/gorm" ) diff --git a/db/db_service.go b/db/db_service.go index 8f6b159f9..5779b6038 100644 --- a/db/db_service.go +++ b/db/db_service.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/logger" "github.com/nbd-wtf/go-nostr" "gorm.io/gorm" ) diff --git a/docker-compose.yml b/docker-compose.yml index ad8d54b24..8c5ec5019 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: albyhub: platform: linux/amd64 container_name: albyhub - image: ghcr.io/getalby/nostr-wallet-connect-next:latest + image: ghcr.io/getalby/hub:latest volumes: - ./albyhub-data:/data ports: diff --git a/events/events.go b/events/events.go index ac7ff3c76..48d768a05 100644 --- a/events/events.go +++ b/events/events.go @@ -5,7 +5,7 @@ import ( "slices" "sync" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/logger" "github.com/sirupsen/logrus" ) diff --git a/fly.toml b/fly.toml index 48a7d18e3..59d73ca35 100644 --- a/fly.toml +++ b/fly.toml @@ -7,7 +7,7 @@ app = 'nwc' primary_region = 'lax' [build] - image = 'ghcr.io/getalby/nostr-wallet-connect-next:latest' + image = 'ghcr.io/getalby/hub:latest' [env] DATABASE_URI = '/data/nwc.db' diff --git a/frontend/public/robots.txt b/frontend/public/robots.txt new file mode 100644 index 000000000..1f53798bb --- /dev/null +++ b/frontend/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d1b03f9d7..cd8eed836 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -13,7 +13,11 @@ function App() { return ( <> - + diff --git a/frontend/src/components/AppHeader.tsx b/frontend/src/components/AppHeader.tsx index a4e59af43..8bcb3e539 100644 --- a/frontend/src/components/AppHeader.tsx +++ b/frontend/src/components/AppHeader.tsx @@ -5,12 +5,18 @@ type Props = { title: string | ReactElement; description: string | ReactElement; contentRight?: React.ReactNode; + breadcrumb?: boolean; }; -function AppHeader({ title, description, contentRight }: Props) { +function AppHeader({ + title, + description, + contentRight, + breadcrumb = true, +}: Props) { return ( <> - + {breadcrumb && }

{title}

diff --git a/frontend/src/components/Breadcrumbs.tsx b/frontend/src/components/Breadcrumbs.tsx index ed0085df3..1ab017254 100644 --- a/frontend/src/components/Breadcrumbs.tsx +++ b/frontend/src/components/Breadcrumbs.tsx @@ -38,8 +38,8 @@ function Breadcrumbs() { // Remove the last item if it's an index route to prevent e.g. Wallet > Wallet const filteredCrumbs = isIndexRoute ? crumbs.slice(0, -1) : crumbs; - // Don't render anything if there is only one item - if (filteredCrumbs.length < 2) { + // Skip rendering for breadcrumbs consisting of 2 (or less) items + if (filteredCrumbs.length < 3) { return null; } diff --git a/frontend/src/components/layouts/AppLayout.tsx b/frontend/src/components/layouts/AppLayout.tsx index df0bb0925..fac4baf19 100644 --- a/frontend/src/components/layouts/AppLayout.tsx +++ b/frontend/src/components/layouts/AppLayout.tsx @@ -2,7 +2,6 @@ import { Cable, EllipsisVertical, ExternalLinkIcon, - FlaskRound, Home, Lock, Megaphone, @@ -15,6 +14,7 @@ import { Wallet, } from "lucide-react"; +import { CubeIcon } from "@radix-ui/react-icons"; import React from "react"; import { Link, @@ -140,13 +140,10 @@ export default function AppLayout() { const { hasChannelManagement } = useInfo(); return (
diff --git a/frontend/src/components/redirects/SetupRedirect.tsx b/frontend/src/components/redirects/SetupRedirect.tsx index 9bf611522..207ed1bf2 100644 --- a/frontend/src/components/redirects/SetupRedirect.tsx +++ b/frontend/src/components/redirects/SetupRedirect.tsx @@ -3,7 +3,6 @@ import { Outlet, useLocation, useNavigate } from "react-router-dom"; import Loading from "src/components/Loading"; import { useInfo } from "src/hooks/useInfo"; -let didSetupThisSession = false; export function SetupRedirect() { const { data: info } = useInfo(); const location = useLocation(); @@ -13,17 +12,10 @@ export function SetupRedirect() { if (!info) { return; } - if (didSetupThisSession) { - // ensure redirect does not happen as node may still be starting - // which would then incorrectly redirect to the login page - console.info("Skipping setup redirect on initial setup"); - return; - } - if (info.setupCompleted) { + if (info.setupCompleted && info.running) { navigate("/"); return; } - didSetupThisSession = true; }, [info, location, navigate]); if (!info) { diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx index 0c170b2da..849229577 100644 --- a/frontend/src/components/ui/button.tsx +++ b/frontend/src/components/ui/button.tsx @@ -18,7 +18,7 @@ const buttonVariants = cva( secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground", - link: "text-primary underline-offset-4 hover:underline", + link: "text-foreground hover:text-accent-foreground underline-offset-4 hover:underline", positive: "bg-positive text-positive-foreground shadow-sm hover:bg-positive/90", }, diff --git a/frontend/src/components/ui/card.tsx b/frontend/src/components/ui/card.tsx index ed1766392..0f76508b8 100644 --- a/frontend/src/components/ui/card.tsx +++ b/frontend/src/components/ui/card.tsx @@ -8,10 +8,7 @@ const Card = React.forwardRef< >(({ className, ...props }, ref) => (
)); @@ -75,9 +72,9 @@ CardFooter.displayName = "CardFooter"; export { Card, - CardHeader, + CardContent, + CardDescription, CardFooter, + CardHeader, CardTitle, - CardDescription, - CardContent, }; diff --git a/frontend/src/components/ui/mode-toggle.tsx b/frontend/src/components/ui/mode-toggle.tsx deleted file mode 100644 index a9ea84e51..000000000 --- a/frontend/src/components/ui/mode-toggle.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { Moon, Sun } from "lucide-react"; -import { Switch } from "src/components/ui/switch"; -import { useTheme } from "src/components/ui/theme-provider"; - -export function ModeToggle() { - const { theme, setTheme } = useTheme(); - - return ( - <> -
- - { - setTheme(theme === "dark" ? "light" : "dark"); - }} - checked={theme === "light"} - /> - -
- - ); -} diff --git a/frontend/src/components/ui/progress.tsx b/frontend/src/components/ui/progress.tsx index 336ac732b..f7bf8c8aa 100644 --- a/frontend/src/components/ui/progress.tsx +++ b/frontend/src/components/ui/progress.tsx @@ -1,5 +1,5 @@ -import * as React from "react"; import * as ProgressPrimitive from "@radix-ui/react-progress"; +import * as React from "react"; import { cn } from "src/lib/utils"; @@ -23,4 +23,23 @@ const Progress = React.forwardRef< )); Progress.displayName = ProgressPrimitive.Root.displayName; -export { Progress }; +const CircleProgress = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, value, ...props }, ref) => ( + + {props.children ||
{`${value || 0}%`}
} +
+)); + +export { CircleProgress, Progress }; diff --git a/frontend/src/components/ui/theme-provider.tsx b/frontend/src/components/ui/theme-provider.tsx index 84596d7f5..bb897bf9d 100644 --- a/frontend/src/components/ui/theme-provider.tsx +++ b/frontend/src/components/ui/theme-provider.tsx @@ -1,51 +1,76 @@ import { createContext, useContext, useEffect, useState } from "react"; -type Theme = "dark" | "light" | "system"; +export type DarkMode = "system" | "light" | "dark"; +export const Themes = ["default", "alby", "bitcoin", "nostr"] as const; +export type Theme = (typeof Themes)[number]; type ThemeProviderProps = { children: React.ReactNode; defaultTheme?: Theme; + defaultDarkMode?: DarkMode; storageKey?: string; }; type ThemeProviderState = { - theme: Theme; + theme: string; + darkMode: string; setTheme: (theme: Theme) => void; + setDarkMode: (mode: DarkMode) => void; }; const initialState: ThemeProviderState = { - theme: "system", + theme: "default", setTheme: () => null, + darkMode: "system", + setDarkMode: () => null, }; const ThemeProviderContext = createContext(initialState); export function ThemeProvider({ children, - defaultTheme = "system", + defaultTheme = "default", + defaultDarkMode = "system", storageKey = "vite-ui-theme", ...props }: ThemeProviderProps) { const [theme, setTheme] = useState(() => { return (localStorage.getItem(storageKey) as Theme) || defaultTheme; }); + + const [darkMode, setDarkMode] = useState(() => { + return ( + (localStorage.getItem(storageKey + "-darkmode") as DarkMode) || + defaultDarkMode + ); + }); + useEffect(() => { const root = window.document.documentElement; - root.classList.remove("light", "dark"); - if (theme === "system") { - const systemTheme = window.matchMedia("(prefers-color-scheme: dark)") - .matches - ? "dark" - : "light"; + // Find and remove classes that start with 'theme-' + const classList = root.classList; + classList.forEach((className) => { + if (className.startsWith("theme-")) { + classList.remove(className); + } + }); - root.classList.add(systemTheme); - setTheme(systemTheme); - return; + classList.add(`theme-${theme}`); + + let prefersDark = false; + if (darkMode == "system") { + prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + } else { + prefersDark = darkMode === "dark"; } - root.classList.add(theme); - }, [theme]); + if (prefersDark) { + classList.add("dark"); + } else { + classList.remove("dark"); + } + }, [theme, darkMode]); const value = { theme, @@ -53,6 +78,11 @@ export function ThemeProvider({ localStorage.setItem(storageKey, theme); setTheme(theme); }, + darkMode, + setDarkMode: (darkMode: DarkMode) => { + localStorage.setItem(storageKey + "-darkmode", darkMode); + setDarkMode(darkMode); + }, }; return ( diff --git a/frontend/src/hooks/useTransactions.ts b/frontend/src/hooks/useTransactions.ts index 394768fdc..6b550023d 100644 --- a/frontend/src/hooks/useTransactions.ts +++ b/frontend/src/hooks/useTransactions.ts @@ -7,9 +7,10 @@ const pollConfiguration: SWRConfiguration = { refreshInterval: 3000, }; -export function useTransactions(poll = false) { +export function useTransactions(poll = false, limit = 100, page = 1) { + const offset = (page - 1) * limit; return useSWR( - "/api/transactions", + `/api/transactions?limit=${limit}&offset=${offset}`, swrFetcher, poll ? pollConfiguration : undefined ); diff --git a/frontend/src/index.css b/frontend/src/index.css index 6590f298c..7adbc8787 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1,56 +1,12 @@ +@import "themes/default.css"; +@import "themes/alby.css"; +@import "themes/bitcoin.css"; +@import "themes/nostr.css"; + @tailwind base; @tailwind components; @tailwind utilities; -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 240 10% 3.9%; - --card: 0 0% 100%; - --card-foreground: 240 10% 3.9%; - --popover: 0 0% 100%; - --popover-foreground: 240 10% 3.9%; - --primary: 240 5.9% 10%; - --primary-foreground: 0 0% 98%; - --secondary: 240 4.8% 95.9%; - --secondary-foreground: 240 5.9% 10%; - --muted: 240 4.8% 95.9%; - --muted-foreground: 240 3.8% 46.1%; - --accent: 240 4.8% 95.9%; - --accent-foreground: 240 5.9% 10%; - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 0 0% 98%; - --border: 240 5.9% 90%; - --input: 240 5.9% 90%; - --ring: 240 5.9% 10%; - --radius: 0.5rem; - --positive: 138, 68%, 96%; - --positive-foreground: 142 76% 36%; - } - - .dark { - --background: 240 10% 3.9%; - --foreground: 0 0% 98%; - --card: 240 10% 3.9%; - --card-foreground: 0 0% 98%; - --popover: 240 10% 3.9%; - --popover-foreground: 0 0% 98%; - --primary: 0 0% 98%; - --primary-foreground: 240 5.9% 10%; - --secondary: 240 3.7% 15.9%; - --secondary-foreground: 0 0% 98%; - --muted: 240 3.7% 15.9%; - --muted-foreground: 240 5% 64.9%; - --accent: 240 3.7% 15.9%; - --accent-foreground: 0 0% 98%; - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 0 0% 98%; - --border: 240 3.7% 15.9%; - --input: 240 3.7% 15.9%; - --ring: 240 4.9% 83.9%; - } -} - @layer base { * { @apply border-border; @@ -65,9 +21,3 @@ input[type="text"]::-webkit-calendar-picker-indicator { display: none !important; } - -html { - --bc-color-brand: #000000; /* use a different brand color in dark mode */ - --bc-color-brand-dark: #ffffff; /* use a different brand color in dark mode */ - --bc-brand-mix: 100%; /* how much to mix the brand color with default foreground color */ -} diff --git a/frontend/src/routes.tsx b/frontend/src/routes.tsx index 214ed3955..3f7d62ee4 100644 --- a/frontend/src/routes.tsx +++ b/frontend/src/routes.tsx @@ -164,7 +164,7 @@ const routes = [ { path: "channels", element: , - handle: { crumb: () => "Liquidity" }, + handle: { crumb: () => "Node" }, children: [ { index: true, diff --git a/frontend/src/screens/Start.tsx b/frontend/src/screens/Start.tsx index fcd2693fd..58a52fe41 100644 --- a/frontend/src/screens/Start.tsx +++ b/frontend/src/screens/Start.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { useNavigate } from "react-router-dom"; import Container from "src/components/Container"; import TwoColumnLayoutHeader from "src/components/TwoColumnLayoutHeader"; import { Input } from "src/components/ui/input"; @@ -11,18 +10,61 @@ import { useInfo } from "src/hooks/useInfo"; import { handleRequestError } from "src/utils/handleRequestError"; import { request } from "src/utils/request"; +const messages: string[] = [ + "Unlocking", + "Starting the wallet", + "Connecting to the network", + "Syncing", + "Still syncing, please wait...", +]; + export default function Start() { const [unlockPassword, setUnlockPassword] = React.useState(""); const [loading, setLoading] = React.useState(false); - const navigate = useNavigate(); + const [buttonText, setButtonText] = React.useState("Login"); + useInfo(true); // poll the info endpoint to auto-redirect when app is running const { data: csrf } = useCSRF(); - const { mutate: refetchInfo } = useInfo(); const { toast } = useToast(); + React.useEffect(() => { + if (!loading) { + return; + } + let messageIndex = 1; + const intervalId = setInterval(() => { + if (messageIndex < messages.length) { + setButtonText(messages[messageIndex]); + messageIndex++; + } else { + clearInterval(intervalId); + } + }, 5000); + + const timeoutId = setTimeout(() => { + // if redirection didn't happen in 3 minutes info.running is false + toast({ + title: "Failed to start", + description: "Please try starting the node again.", + variant: "destructive", + }); + + setLoading(false); + setButtonText("Login"); + setUnlockPassword(""); + return; + }, 180000); // wait for 3 minutes + + return () => { + clearInterval(intervalId); + clearTimeout(timeoutId); + }; + }, [loading, toast]); + async function onSubmit(e: React.FormEvent) { e.preventDefault(); try { setLoading(true); + setButtonText(messages[0]); if (!csrf) { throw new Error("csrf not loaded"); } @@ -36,13 +78,11 @@ export default function Start() { unlockPassword, }), }); - await refetchInfo(); - - navigate("/"); } catch (error) { handleRequestError(toast, "Failed to connect", error); - } finally { setLoading(false); + setButtonText("Login"); + setUnlockPassword(""); } } @@ -68,7 +108,7 @@ export default function Start() { />
- Login + {buttonText}
diff --git a/frontend/src/screens/Welcome.tsx b/frontend/src/screens/Welcome.tsx index 4446dd164..d319d02df 100644 --- a/frontend/src/screens/Welcome.tsx +++ b/frontend/src/screens/Welcome.tsx @@ -166,7 +166,7 @@ export function Welcome() { Subject to the following terms, Alby grants to you a perpetual, worldwide license to the Application pursuant to the Apache-2.0 license. - (https://github.com/getAlby/nostr-wallet-connect-next?tab=Apache-2.0-1-ov-file#readme). + (https://github.com/getAlby/hub?tab=Apache-2.0-1-ov-file#readme). This EULA pertains solely to the Application and does not limit your rights under, or grant you rights that supersede, the license terms of any particular component. diff --git a/frontend/src/screens/apps/AppCreated.tsx b/frontend/src/screens/apps/AppCreated.tsx index 528cee735..640ef9972 100644 --- a/frontend/src/screens/apps/AppCreated.tsx +++ b/frontend/src/screens/apps/AppCreated.tsx @@ -1,4 +1,4 @@ -import { CopyIcon } from "lucide-react"; +import { CopyIcon, EyeIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { Link, Navigate, useLocation, useNavigate } from "react-router-dom"; @@ -30,6 +30,7 @@ export default function AppCreated() { console.info(appstoreApp, appId); const [timeout, setTimeout] = useState(false); + const [isQRCodeVisible, setIsQRCodeVisible] = useState(false); const createAppResponse = state as CreateAppResponse; const pairingUri = createAppResponse.pairingUri; const { data: app } = useApp(createAppResponse.pairingPublicKey, true); @@ -42,7 +43,7 @@ export default function AppCreated() { useEffect(() => { const timeoutId = window.setTimeout(() => { setTimeout(true); - }, 10000); + }, 30000); return () => window.clearTimeout(timeoutId); }, []); @@ -125,12 +126,26 @@ export default function AppCreated() {
)} - - {appstoreApp && ( - +
+ + {appstoreApp && ( + + )} +
+ {!isQRCodeVisible && ( + )}
diff --git a/frontend/src/screens/appstore/AppStore.tsx b/frontend/src/screens/appstore/AppStore.tsx index f25904c3b..966bddc55 100644 --- a/frontend/src/screens/appstore/AppStore.tsx +++ b/frontend/src/screens/appstore/AppStore.tsx @@ -7,7 +7,7 @@ function AppStore() { return ( <> diff --git a/frontend/src/screens/channels/Channels.tsx b/frontend/src/screens/channels/Channels.tsx index 2105308de..842f24d12 100644 --- a/frontend/src/screens/channels/Channels.tsx +++ b/frontend/src/screens/channels/Channels.tsx @@ -7,6 +7,7 @@ import { CopyIcon, ExternalLinkIcon, HandCoins, + Heart, Hotel, InfoIcon, MoreHorizontal, @@ -43,7 +44,7 @@ import { DropdownMenuTrigger, } from "src/components/ui/dropdown-menu.tsx"; import { LoadingButton } from "src/components/ui/loading-button.tsx"; -import { Progress } from "src/components/ui/progress.tsx"; +import { CircleProgress, Progress } from "src/components/ui/progress.tsx"; import { Table, TableBody, @@ -95,6 +96,8 @@ export default function Channels() { const [drainingAlbySharedFunds, setDrainingAlbySharedFunds] = React.useState(false); + const nodeHealth = channels ? getNodeHealth(channels) : 0; + // TODO: move to NWC backend const loadNodeStats = React.useCallback(async () => { if (!channels) { @@ -284,10 +287,10 @@ export default function Channels() { return ( <> +
*/} - + + + + + + + + + Node health: {nodeHealth}% + + + +
} >
@@ -414,14 +429,14 @@ export default function Channels() { )} > {showHostedBalance && ( - + Alby Hosted Balance - +
{new Intl.NumberFormat().format(albyBalance?.sats)} sats
@@ -476,14 +491,14 @@ export default function Channels() {
)} - + Savings Balance - + {!balances && (
@@ -519,14 +534,14 @@ export default function Channels() { - + Spending Balance - + {!balances && (
@@ -549,14 +564,14 @@ export default function Channels() { - + Receiving Capacity - +
{balances && new Intl.NumberFormat().format( @@ -797,3 +812,37 @@ export default function Channels() { ); } + +function getNodeHealth(channels: Channel[]) { + const totalChannelCapacitySats = channels + .map((channel) => (channel.localBalance + channel.remoteBalance) / 1000) + .reduce((a, b) => a + b, 0); + + const averageChannelBalance = + channels + .map((channel) => { + const totalBalance = channel.localBalance + channel.remoteBalance; + const expectedBalance = totalBalance / 2; + const actualBalance = + Math.min(channel.localBalance, channel.remoteBalance) / + expectedBalance; + return actualBalance; + }) + .reduce((a, b) => a + b, 0) / (channels.length || 1); + + const numUniqueChannelPartners = new Set( + channels.map((channel) => channel.remotePubkey) + ).size; + + let nodeHealth = Math.ceil( + Math.min(3, numUniqueChannelPartners) * + (100 / 3) * // 3 channels is great + (Math.min(totalChannelCapacitySats, 1_000_000) / 1_000_000) * // 1 million sats or more is great + averageChannelBalance // perfectly balanced is great! + ); + + // above calculation is a bit harsh + nodeHealth = Math.min(nodeHealth * 2, 100); + + return nodeHealth; +} diff --git a/frontend/src/screens/channels/IncreaseIncomingCapacity.tsx b/frontend/src/screens/channels/IncreaseIncomingCapacity.tsx index fe55ea01f..7296d8fd0 100644 --- a/frontend/src/screens/channels/IncreaseIncomingCapacity.tsx +++ b/frontend/src/screens/channels/IncreaseIncomingCapacity.tsx @@ -128,6 +128,7 @@ function NewChannelInternal({ network }: { network: Network }) { const okPartners = channelPeerSuggestions.filter( (partner) => amount >= partner.minimumChannelSize && + amount <= partner.maximumChannelSize && partner.network === network && partner.paymentMethod === "lightning" && partner.lspType === "LSPS1" && @@ -264,15 +265,19 @@ function NewChannelInternal({ network }: { network: Network }) { )}
{peer.name} - {peer.minimumChannelSize > 0 && ( - - Min.{" "} - {new Intl.NumberFormat().format( - peer.minimumChannelSize - )}{" "} - sats - - )} + + Min.{" "} + {new Intl.NumberFormat().format( + peer.minimumChannelSize + )} + sats + + Max.{" "} + {new Intl.NumberFormat().format( + peer.maximumChannelSize + )}{" "} + sats +
diff --git a/frontend/src/screens/channels/IncreaseOutgoingCapacity.tsx b/frontend/src/screens/channels/IncreaseOutgoingCapacity.tsx index 2fce27789..5e578b8e4 100644 --- a/frontend/src/screens/channels/IncreaseOutgoingCapacity.tsx +++ b/frontend/src/screens/channels/IncreaseOutgoingCapacity.tsx @@ -70,6 +70,7 @@ function NewChannelInternal({ network }: { network: Network }) { network, paymentMethod: "onchain", minimumChannelSize: 0, + maximumChannelSize: 0, pubkey: "", host: "", image: "", diff --git a/frontend/src/screens/onboarding/MigrateAlbyFunds.tsx b/frontend/src/screens/onboarding/MigrateAlbyFunds.tsx index 626417149..ed2177e99 100644 --- a/frontend/src/screens/onboarding/MigrateAlbyFunds.tsx +++ b/frontend/src/screens/onboarding/MigrateAlbyFunds.tsx @@ -25,6 +25,7 @@ export default function MigrateAlbyFunds() { const { data: albyMe } = useAlbyMe(); const { data: albyBalance } = useAlbyBalance(); const { data: csrf } = useCSRF(); + const { data: info } = useInfo(); const { data: channels } = useChannels(true); const { mutate: refetchInfo } = useInfo(); const { toast } = useToast(); @@ -44,6 +45,17 @@ export default function MigrateAlbyFunds() { const requestWrappedInvoice = React.useCallback( async (amount: number) => { try { + if (!info) { + throw new Error("Info not loaded"); + } + // other node implementations may not work / may not support 0-conf. + // so for now we are not allowing other backend types. + // They can open a channel with a different method and then migrate + // their shared funds once they have enough receiving capacity. + if (info.backendType !== "LDK") { + throw new Error("Only LDK backend is supported"); + } + if (!channels) { throw new Error("Channels not loaded"); } @@ -77,7 +89,7 @@ export default function MigrateAlbyFunds() { setError("Failed to connect to request wrapped invoice: " + error); } }, - [channels, csrf] + [channels, csrf, info] ); const payWrappedInvoice = React.useCallback( @@ -114,7 +126,7 @@ export default function MigrateAlbyFunds() { ); React.useEffect(() => { - if (hasRequestedInvoice || !channels || !albyMe || !albyBalance) { + if (hasRequestedInvoice || !info || !channels || !albyMe || !albyBalance) { return; } setRequestedInvoice(true); @@ -129,6 +141,7 @@ export default function MigrateAlbyFunds() { albyBalance, channels, albyMe, + info, requestWrappedInvoice, ]); diff --git a/frontend/src/screens/settings/Settings.tsx b/frontend/src/screens/settings/Settings.tsx index b60742bae..09ae10962 100644 --- a/frontend/src/screens/settings/Settings.tsx +++ b/frontend/src/screens/settings/Settings.tsx @@ -1,12 +1,71 @@ import SettingsHeader from "src/components/SettingsHeader"; +import { Label } from "src/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "src/components/ui/select"; +import { + DarkMode, + Theme, + Themes, + useTheme, +} from "src/components/ui/theme-provider"; +import { toast } from "src/components/ui/use-toast"; function Settings() { + const { theme, darkMode, setTheme, setDarkMode } = useTheme(); + return ( <> +
+
+ + +
+
+ + +
+
); } diff --git a/frontend/src/screens/setup/SetupFinish.tsx b/frontend/src/screens/setup/SetupFinish.tsx index dfcfa81e6..9ccda8b2a 100644 --- a/frontend/src/screens/setup/SetupFinish.tsx +++ b/frontend/src/screens/setup/SetupFinish.tsx @@ -15,9 +15,9 @@ import { request } from "src/utils/request"; export function SetupFinish() { const navigate = useNavigate(); const { nodeInfo, unlockPassword } = useSetupStore(); - - const { mutate: refetchInfo } = useInfo(); + useInfo(true); // poll the info endpoint to auto-redirect when app is running const { data: csrf } = useCSRF(); + const [loading, setLoading] = React.useState(false); const [connectionError, setConnectionError] = React.useState(false); const hasFetchedRef = React.useRef(false); @@ -30,6 +30,22 @@ export function SetupFinish() { }, }; + useEffect(() => { + if (!loading) { + return; + } + const timer = setTimeout(() => { + // SetupRedirect takes care of redirection once info.running is true + // if it still didn't redirect after 3 minutes, we show an error + setLoading(false); + setConnectionError(true); + }, 180000); + + return () => { + clearTimeout(timer); + }; + }, [loading]); + useEffect(() => { // ensure setup call is only called once if (!csrf || hasFetchedRef.current) { @@ -38,18 +54,15 @@ export function SetupFinish() { hasFetchedRef.current = true; (async () => { + setLoading(true); const succeeded = await finishSetup(csrf, nodeInfo, unlockPassword); - if (succeeded) { - const info = await refetchInfo(); - if (!info) { - throw new Error("Failed to re-fetch info"); - } - navigate("/"); - } else { + // only setup call is successful as start is async + if (!succeeded) { + setLoading(false); setConnectionError(true); } })(); - }, [csrf, nodeInfo, refetchInfo, navigate, unlockPassword]); + }, [csrf, nodeInfo, navigate, unlockPassword]); if (connectionError) { return ( @@ -57,7 +70,7 @@ export function SetupFinish() {

Connection Failed

-

Please check your node configuration.

+

Please check your node configuration and try again.

-
diff --git a/frontend/src/screens/wallet/index.tsx b/frontend/src/screens/wallet/index.tsx index 7ea557332..4f733e319 100644 --- a/frontend/src/screens/wallet/index.tsx +++ b/frontend/src/screens/wallet/index.tsx @@ -1,10 +1,4 @@ -import { - ArrowDown, - ArrowDownIcon, - ArrowUp, - ArrowUpIcon, - CreditCard, -} from "lucide-react"; +import { ArrowDownIcon, ArrowUpIcon, CreditCard } from "lucide-react"; import { Link } from "react-router-dom"; import AppHeader from "src/components/AppHeader"; import BreezRedeem from "src/components/BreezRedeem"; @@ -12,18 +6,11 @@ import ExternalLink from "src/components/ExternalLink"; import Loading from "src/components/Loading"; import TransactionsList from "src/components/TransactionsList"; import { Button } from "src/components/ui/button"; -import { - Card, - CardContent, - CardFooter, - CardHeader, - CardTitle, -} from "src/components/ui/card"; import { useBalances } from "src/hooks/useBalances"; import { useInfo } from "src/hooks/useInfo"; function Wallet() { - const { data: info, hasChannelManagement } = useInfo(); + const { data: info } = useInfo(); const { data: balances } = useBalances(); if (!info || !balances) { @@ -32,7 +19,7 @@ function Wallet() { return ( <> - +
@@ -41,97 +28,28 @@ function Wallet() { )}{" "} sats
-
+
- - -
-
- - - - Spending Balance - - - - - {!balances && ( -
-
-
-
-
- )} - {balances && ( -
- {new Intl.NumberFormat(undefined, {}).format( - Math.floor(balances.lightning.totalSpendable / 1000) - )}{" "} - sats -
- )} -
- {hasChannelManagement && ( - - - - - - )} -
- {hasChannelManagement && ( - - - - Receiving Capacity - - - - - {!balances && ( -
-
-
-
-
- )} -
- {balances && ( - <> - {new Intl.NumberFormat().format( - Math.floor(balances.lightning.totalReceivable / 1000) - )}{" "} - sats - - )} -
-
- - - - - -
- )} -
- ); diff --git a/frontend/src/themes/alby.css b/frontend/src/themes/alby.css new file mode 100644 index 000000000..db52a422f --- /dev/null +++ b/frontend/src/themes/alby.css @@ -0,0 +1,52 @@ +.theme-alby { + --background: 0 0% 100%; + --foreground: 0 0% 5%; + --card: 0 0% 100%; + --card-foreground: 0 0% 5%; + --popover: 0 0% 100%; + --popover-foreground: 0 0% 5%; + --primary: 47 100% 72%; + --primary-foreground: 0 0% 2%; + --secondary: 0 0% 96%; + --secondary-foreground: 0 0% 5%; + --muted: 0 0% 96%; + --muted-foreground: 0 0% 45%; + --accent: 0 0% 96%; + --accent-foreground: 0 0% 5%; + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 98%; + --border: 0 0% 92%; + --input: 0 0% 85%; + --ring: 0 0% 76%; + --radius: 0.5rem; +} + +.theme-alby.dark { + --background: 0 0% 3%; + --foreground: 0 0% 98%; + + --card: 0 0% 3%; + --card-foreground: 0 0% 98%; + + --popover: 0 0% 0%; + --popover-foreground: 0 0% 98%; + + --primary: 47 100% 72%; + --primary-foreground: 0 0% 2%; + + --secondary: 0 0% 0%; + --secondary-foreground: 0 0% 98%; + + --muted: 0 0% 10%; + --muted-foreground: 0 0% 49%; + + --accent: 0 0% 0%; + --accent-foreground: 0 0% 98%; + + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 98%; + + --border: 0 0% 15%; + --input: 0 0% 15%; + --ring: 47 100% 40%; +} diff --git a/frontend/src/themes/bitcoin.css b/frontend/src/themes/bitcoin.css new file mode 100644 index 000000000..eb7cd8378 --- /dev/null +++ b/frontend/src/themes/bitcoin.css @@ -0,0 +1,61 @@ +.theme-bitcoin { + --background: 0 0% 100%; + --foreground: 0 0% 5%; + + --card: 0 0% 100%; + --card-foreground: 0 0% 5%; + + --popover: 0 0% 100%; + --popover-foreground: 0 0% 5%; + + --primary: 42 100% 47%; + --primary-foreground: 0 0% 2%; + + --secondary: 0 0% 96%; + --secondary-foreground: 0 0% 5%; + + --muted: 0 0% 96%; + --muted-foreground: 0 0% 45%; + + --accent: 0 0% 96%; + --accent-foreground: 0 0% 5%; + + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 98%; + + --border: 0 0% 92%; + --input: 0 0% 85%; + --ring: 0 0% 76%; + + --radius: 0.5rem; +} + +.theme-bitcoin.dark { + --background: 60 3% 6%; + --foreground: 0 0% 98%; + + --card: 60 3% 6%; + --card-foreground: 0 0% 98%; + + --popover: 60 3% 6%; + --popover-foreground: 0 0% 98%; + + --primary: 42 100% 47%; + --primary-foreground: 0 0% 2%; + + --secondary: 40 5% 12%; + --secondary-foreground: 0 0% 98%; + + --muted: 45 4% 18%; + --muted-foreground: 40 5% 49%; + + --accent: 42 44% 12%; + --accent-foreground: 0 0% 98%; + + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 98%; + + --border: 40 5% 12%; + --input: 45 4% 18%; + --ring: 42 100% 40%; +} diff --git a/frontend/src/themes/default.css b/frontend/src/themes/default.css new file mode 100644 index 000000000..64a4a1bd1 --- /dev/null +++ b/frontend/src/themes/default.css @@ -0,0 +1,52 @@ +.theme-default { + --background: 0 0% 100%; + --foreground: 240 10% 3.9%; + --card: 0 0% 100%; + --card-foreground: 240 10% 3.9%; + --popover: 0 0% 100%; + --popover-foreground: 240 10% 3.9%; + --primary: 240 5.9% 10%; + --primary-foreground: 0 0% 98%; + --secondary: 240 4.8% 95.9%; + --secondary-foreground: 240 5.9% 10%; + --muted: 240 4.8% 95.9%; + --muted-foreground: 240 3.8% 46.1%; + --accent: 240 4.8% 95.9%; + --accent-foreground: 240 5.9% 10%; + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 0 0% 98%; + --border: 240 5.9% 90%; + --input: 240 5.9% 90%; + --ring: 240 5.9% 10%; + --positive: 138, 68%, 96%; + --positive-foreground: 142 76% 36%; + --radius: 0.5rem; +} + +.theme-default.dark { + --background: 240 10% 3.9%; + --foreground: 0 0% 98%; + --card: 240 10% 3.9%; + --card-foreground: 0 0% 98%; + --popover: 240 10% 3.9%; + --popover-foreground: 0 0% 98%; + --primary: 0 0% 98%; + --primary-foreground: 240 5.9% 10%; + --secondary: 240 3.7% 15.9%; + --secondary-foreground: 0 0% 98%; + --muted: 240 3.7% 15.9%; + --muted-foreground: 240 5% 64.9%; + --accent: 240 3.7% 15.9%; + --accent-foreground: 0 0% 98%; + --destructive: 0 62.8% 30.6%; + --destructive-foreground: 0 0% 98%; + --border: 240 3.7% 15.9%; + --input: 240 3.7% 15.9%; + --ring: 240 4.9% 83.9%; +} + +html { + --bc-color-brand: #000000; /* use a different brand color in dark mode */ + --bc-color-brand-dark: #ffffff; /* use a different brand color in dark mode */ + --bc-brand-mix: 100%; /* how much to mix the brand color with default foreground color */ +} diff --git a/frontend/src/themes/nostr.css b/frontend/src/themes/nostr.css new file mode 100644 index 000000000..01b9c7321 --- /dev/null +++ b/frontend/src/themes/nostr.css @@ -0,0 +1,61 @@ +.theme-nostr { + --background: 270 8% 95%; + --foreground: 270 8% 5%; + + --card: 270 8% 95%; + --card-foreground: 270 8% 5%; + + --popover: 270 8% 95%; + --popover-foreground: 270 8% 5%; + + --primary: 273 100% 29%; + --primary-foreground: 300 9% 98%; + + --secondary: 276 11% 91%; + --secondary-foreground: 270 8% 5%; + + --muted: 270 9% 91%; + --muted-foreground: 274 9% 45%; + + --accent: 276 11% 91%; + --accent-foreground: 270 8% 5%; + + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 98%; + + --border: 270 9% 87%; + --input: 267 9% 81%; + --ring: 273 36% 72%; + + --radius: 0.5rem; +} + +.theme-nostr.dark { + --background: 300 4% 5%; + --foreground: 0 0% 98%; + + --card: 300 4% 5%; + --card-foreground: 0 0% 98%; + + --popover: 300 4% 5%; + --popover-foreground: 0 0% 98%; + + --primary: 273 42% 47%; + --primary-foreground: 0 0% 98%; + + --secondary: 300 2% 10%; + --secondary-foreground: 0 0% 98%; + + --muted: 270 3% 15%; + --muted-foreground: 276 2% 49%; + + --accent: 273 18% 10%; + --accent-foreground: 0 0% 98%; + + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 98%; + + --border: 300 2% 12%; + --input: 270 2% 18%; + --ring: 272 41% 40%; +} diff --git a/frontend/src/types.ts b/frontend/src/types.ts index b2d04c9d2..68248f44e 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -298,6 +298,7 @@ export type RecommendedChannelPeer = { image: string; name: string; minimumChannelSize: number; + maximumChannelSize: number; } & ( | { paymentMethod: "onchain"; diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index 7c74ebbce..afa21e7a8 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -2,7 +2,7 @@ const defaultTheme = require("tailwindcss/defaultTheme"); /** @type {import('tailwindcss').Config} */ module.exports = { - darkMode: ["class"], + darkMode: ["selector"], content: [ "./pages/**/*.{ts,tsx}", "./components/**/*.{ts,tsx}", diff --git a/go.mod b/go.mod index 6a92bd486..2b5641732 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/getAlby/nostr-wallet-connect +module github.com/getAlby/hub go 1.22.2 @@ -10,7 +10,7 @@ require ( github.com/getAlby/glalby-go v0.0.0-20240621192717-95673c864d59 github.com/getAlby/ldk-node-go v0.0.0-20240624140557-d51c707f10d9 github.com/go-gormigrate/gormigrate/v2 v2.1.2 - github.com/gorilla/sessions v1.2.2 + github.com/gorilla/sessions v1.3.0 github.com/labstack/echo-contrib v0.17.1 github.com/labstack/echo/v4 v4.12.0 github.com/nbd-wtf/go-nostr v0.32.0 @@ -20,8 +20,8 @@ require ( github.com/wailsapp/wails/v2 v2.8.2 golang.org/x/crypto v0.24.0 golang.org/x/oauth2 v0.21.0 - google.golang.org/grpc v1.64.0 - gopkg.in/DataDog/dd-trace-go.v1 v1.65.0 + google.golang.org/grpc v1.65.0 + gopkg.in/DataDog/dd-trace-go.v1 v1.65.1 gopkg.in/macaroon.v2 v2.1.0 gorm.io/gorm v1.25.10 ) @@ -205,8 +205,8 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/errgo.v1 v1.0.1 // indirect gopkg.in/macaroon-bakery.v2 v2.3.0 // indirect diff --git a/go.sum b/go.sum index 1921c22ab..ff64021c0 100644 --- a/go.sum +++ b/go.sum @@ -278,8 +278,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY= -github.com/gorilla/sessions v1.2.2/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ= +github.com/gorilla/sessions v1.3.0 h1:XYlkq7KcpOB2ZhHBPv5WpjMIxrQosiZanfoy1HLZFzg= +github.com/gorilla/sessions v1.3.0/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -891,20 +891,20 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 h1:P8OJ/WCl/Xo4E4zoe4/bifHpSmmKwARqyqE4nW6J2GQ= -google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 h1:Q2RxlXqh1cgzzUgV261vBO2jI5R/3DD1J2pM0nI4NhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= -gopkg.in/DataDog/dd-trace-go.v1 v1.65.0 h1:mMix4feEsbn2/wONR8e68JLob2QSdpiAMINhpG/8s7k= -gopkg.in/DataDog/dd-trace-go.v1 v1.65.0/go.mod h1:beNFIWd/H04d0k96cfltgiDH2+t0T5sDbyYLF3VTXqk= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +gopkg.in/DataDog/dd-trace-go.v1 v1.65.1 h1:Ne7kzWr/br/jwhUJR7CnqPl/mUpNxa6LfgZs0S4htZM= +gopkg.in/DataDog/dd-trace-go.v1 v1.65.1/go.mod h1:beNFIWd/H04d0k96cfltgiDH2+t0T5sDbyYLF3VTXqk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/http/alby_http_service.go b/http/alby_http_service.go index 83a038237..22b934086 100644 --- a/http/alby_http_service.go +++ b/http/alby_http_service.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "github.com/getAlby/nostr-wallet-connect/alby" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service" + "github.com/getAlby/hub/alby" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service" "github.com/labstack/echo/v4" ) diff --git a/http/http_service.go b/http/http_service.go index 2038d352e..949f9819c 100644 --- a/http/http_service.go +++ b/http/http_service.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "strconv" "strings" echologrus "github.com/davrux/echo-logrus/v4" @@ -14,14 +15,14 @@ import ( "github.com/labstack/echo/v4/middleware" "gorm.io/gorm" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service" - "github.com/getAlby/nostr-wallet-connect/api" - "github.com/getAlby/nostr-wallet-connect/frontend" + "github.com/getAlby/hub/api" + "github.com/getAlby/hub/frontend" ) type HttpService struct { @@ -180,14 +181,13 @@ func (httpSvc *HttpService) startHandler(c echo.Context) error { }) } - err := httpSvc.api.Start(&startRequest) - if err != nil { - return c.JSON(http.StatusInternalServerError, ErrorResponse{ - Message: fmt.Sprintf("Failed to start node: %s", err.Error()), + if !httpSvc.cfg.CheckUnlockPassword(startRequest.UnlockPassword) { + return c.JSON(http.StatusUnauthorized, ErrorResponse{ + Message: "Invalid password", }) } - err = httpSvc.saveSessionCookie(c) + err := httpSvc.saveSessionCookie(c) if err != nil { return c.JSON(http.StatusInternalServerError, ErrorResponse{ @@ -195,6 +195,13 @@ func (httpSvc *HttpService) startHandler(c echo.Context) error { }) } + go func() { + err := httpSvc.api.Start(&startRequest) + if err != nil { + logger.Logger.WithError(err).Error("Failed to start node") + } + }() + return c.NoContent(http.StatusNoContent) } @@ -447,7 +454,22 @@ func (httpSvc *HttpService) lookupTransactionHandler(c echo.Context) error { func (httpSvc *HttpService) listTransactionsHandler(c echo.Context) error { ctx := c.Request().Context() - transactions, err := httpSvc.api.ListTransactions(ctx) + limit := uint64(20) + offset := uint64(0) + + if limitParam := c.QueryParam("limit"); limitParam != "" { + if parsedLimit, err := strconv.ParseUint(limitParam, 10, 64); err == nil { + limit = parsedLimit + } + } + + if offsetParam := c.QueryParam("offset"); offsetParam != "" { + if parsedOffset, err := strconv.ParseUint(offsetParam, 10, 64); err == nil { + offset = parsedOffset + } + } + + transactions, err := httpSvc.api.ListTransactions(ctx, limit, offset) if err != nil { return c.JSON(http.StatusInternalServerError, ErrorResponse{ diff --git a/lnclient/breez/breez.go b/lnclient/breez/breez.go index cefdbf8e6..82bd1dd80 100644 --- a/lnclient/breez/breez.go +++ b/lnclient/breez/breez.go @@ -16,8 +16,8 @@ import ( decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" ) type BreezService struct { diff --git a/lnclient/breez/breez_stub.go b/lnclient/breez/breez_stub.go index 9692e0eff..e7169c887 100644 --- a/lnclient/breez/breez_stub.go +++ b/lnclient/breez/breez_stub.go @@ -3,7 +3,7 @@ package breez import ( - "github.com/getAlby/nostr-wallet-connect/lnclient" + "github.com/getAlby/hub/lnclient" ) func NewBreezService(mnemonic, apiKey, inviteCode, workDir string) (result lnclient.LNClient, err error) { diff --git a/lnclient/cashu/cashu.go b/lnclient/cashu/cashu.go index 4128d16c1..d858a59ff 100644 --- a/lnclient/cashu/cashu.go +++ b/lnclient/cashu/cashu.go @@ -11,8 +11,8 @@ import ( "github.com/elnosh/gonuts/wallet" "github.com/elnosh/gonuts/wallet/storage" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" ) diff --git a/lnclient/greenlight/greenlight.go b/lnclient/greenlight/greenlight.go index 7b2f1a12c..300b7e102 100644 --- a/lnclient/greenlight/greenlight.go +++ b/lnclient/greenlight/greenlight.go @@ -13,15 +13,15 @@ import ( "strings" "time" - //"github.com/getAlby/nostr-wallet-connect/glalby" // for local development only + //"github.com/getAlby/hub/glalby" // for local development only "github.com/getAlby/glalby-go/glalby" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" ) type GreenlightService struct { diff --git a/lnclient/greenlight/models.go b/lnclient/greenlight/models.go index 4e9fddce6..50e060971 100644 --- a/lnclient/greenlight/models.go +++ b/lnclient/greenlight/models.go @@ -1,6 +1,6 @@ package greenlight -import "github.com/getAlby/nostr-wallet-connect/lnclient" +import "github.com/getAlby/hub/lnclient" type NodeInfo struct { ID string `json:"id"` diff --git a/lnclient/ldk/ldk.go b/lnclient/ldk/ldk.go index 3c943ccef..8dd7aafdb 100644 --- a/lnclient/ldk/ldk.go +++ b/lnclient/ldk/ldk.go @@ -16,19 +16,19 @@ import ( "time" "github.com/getAlby/ldk-node-go/ldk_node" - // "github.com/getAlby/nostr-wallet-connect/ldk_node" + // "github.com/getAlby/hub/ldk_node" "encoding/hex" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/lsp" - "github.com/getAlby/nostr-wallet-connect/utils" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/lsp" + "github.com/getAlby/hub/utils" ) type LDKService struct { diff --git a/lnclient/ldk/ldk_event_broadcaster.go b/lnclient/ldk/ldk_event_broadcaster.go index 4b734b080..2dd46f400 100644 --- a/lnclient/ldk/ldk_event_broadcaster.go +++ b/lnclient/ldk/ldk_event_broadcaster.go @@ -6,8 +6,8 @@ import ( "time" "github.com/getAlby/ldk-node-go/ldk_node" - // "github.com/getAlby/nostr-wallet-connect/ldk_node" - "github.com/getAlby/nostr-wallet-connect/logger" + // "github.com/getAlby/hub/ldk_node" + "github.com/getAlby/hub/logger" "github.com/sirupsen/logrus" ) diff --git a/lnclient/lnd/lnd.go b/lnclient/lnd/lnd.go index 9c060c7b1..14da8edfa 100644 --- a/lnclient/lnd/lnd.go +++ b/lnclient/lnd/lnd.go @@ -16,9 +16,9 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" decodepay "github.com/nbd-wtf/ln-decodepay" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/lnclient/lnd/wrapper" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/lnclient/lnd/wrapper" + "github.com/getAlby/hub/logger" "github.com/sirupsen/logrus" // "gorm.io/gorm" @@ -40,6 +40,7 @@ func (svc *LNDService) GetBalance(ctx context.Context) (balance int64, err error return int64(resp.LocalBalance.Msat), nil } +// FIXME: this always returns limit * 2 transactions and offset is not used correctly func (svc *LNDService) ListTransactions(ctx context.Context, from, until, limit, offset uint64, unpaid bool, invoiceType string) (transactions []lnclient.Transaction, err error) { // Fetch invoices var invoices []*lnrpc.Invoice diff --git a/lnclient/phoenixd/phoenixd.go b/lnclient/phoenixd/phoenixd.go index a18208139..b40f5a1c7 100644 --- a/lnclient/phoenixd/phoenixd.go +++ b/lnclient/phoenixd/phoenixd.go @@ -12,8 +12,8 @@ import ( "strings" "time" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" diff --git a/main_wails.go b/main_wails.go index 143fb6444..0b021d426 100644 --- a/main_wails.go +++ b/main_wails.go @@ -7,9 +7,9 @@ import ( "context" "embed" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service" - "github.com/getAlby/nostr-wallet-connect/wails" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service" + "github.com/getAlby/hub/wails" log "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/decode_request.go b/nip47/controllers/decode_request.go index 2fba4c073..0daedc927 100644 --- a/nip47/controllers/decode_request.go +++ b/nip47/controllers/decode_request.go @@ -3,8 +3,8 @@ package controllers import ( "encoding/json" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/get_balance_controller.go b/nip47/controllers/get_balance_controller.go index 0c9f27a3e..66ca9b94d 100644 --- a/nip47/controllers/get_balance_controller.go +++ b/nip47/controllers/get_balance_controller.go @@ -3,8 +3,8 @@ package controllers import ( "context" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/get_balance_controller_test.go b/nip47/controllers/get_balance_controller_test.go index 10a65d4ad..259cc67c2 100644 --- a/nip47/controllers/get_balance_controller_test.go +++ b/nip47/controllers/get_balance_controller_test.go @@ -8,11 +8,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47GetBalanceJson = ` diff --git a/nip47/controllers/get_info_controller.go b/nip47/controllers/get_info_controller.go index 4d2114b1d..cc0c3fdf5 100644 --- a/nip47/controllers/get_info_controller.go +++ b/nip47/controllers/get_info_controller.go @@ -3,10 +3,10 @@ package controllers import ( "context" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" + permissions "github.com/getAlby/hub/nip47/permissions" "github.com/nbd-wtf/go-nostr" "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/get_info_controller_test.go b/nip47/controllers/get_info_controller_test.go index 18500d78d..41f2daa60 100644 --- a/nip47/controllers/get_info_controller_test.go +++ b/nip47/controllers/get_info_controller_test.go @@ -8,11 +8,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47GetInfoJson = ` diff --git a/nip47/controllers/list_transactions_controller.go b/nip47/controllers/list_transactions_controller.go index 24c57508c..2460427ae 100644 --- a/nip47/controllers/list_transactions_controller.go +++ b/nip47/controllers/list_transactions_controller.go @@ -3,8 +3,8 @@ package controllers import ( "context" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/list_transactions_controller_test.go b/nip47/controllers/list_transactions_controller_test.go index 987e22708..71cbea3f4 100644 --- a/nip47/controllers/list_transactions_controller_test.go +++ b/nip47/controllers/list_transactions_controller_test.go @@ -9,11 +9,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47ListTransactionsJson = ` diff --git a/nip47/controllers/lookup_invoice_controller.go b/nip47/controllers/lookup_invoice_controller.go index ae802de29..85f1847e3 100644 --- a/nip47/controllers/lookup_invoice_controller.go +++ b/nip47/controllers/lookup_invoice_controller.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" diff --git a/nip47/controllers/lookup_invoice_controller_test.go b/nip47/controllers/lookup_invoice_controller_test.go index 7e8aa8071..28c7645e0 100644 --- a/nip47/controllers/lookup_invoice_controller_test.go +++ b/nip47/controllers/lookup_invoice_controller_test.go @@ -9,11 +9,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) var nip47LookupInvoiceJson = ` diff --git a/nip47/controllers/make_invoice_controller.go b/nip47/controllers/make_invoice_controller.go index 816f7c37d..5426bb406 100644 --- a/nip47/controllers/make_invoice_controller.go +++ b/nip47/controllers/make_invoice_controller.go @@ -3,8 +3,8 @@ package controllers import ( "context" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/make_invoice_controller_test.go b/nip47/controllers/make_invoice_controller_test.go index 46a17a779..2ad2383ab 100644 --- a/nip47/controllers/make_invoice_controller_test.go +++ b/nip47/controllers/make_invoice_controller_test.go @@ -8,11 +8,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47MakeInvoiceJson = ` diff --git a/nip47/controllers/models.go b/nip47/controllers/models.go index 7cc6ef604..9ccec5c33 100644 --- a/nip47/controllers/models.go +++ b/nip47/controllers/models.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" ) diff --git a/nip47/controllers/multi_pay_invoice_controller.go b/nip47/controllers/multi_pay_invoice_controller.go index aa6909f18..d5f1acc01 100644 --- a/nip47/controllers/multi_pay_invoice_controller.go +++ b/nip47/controllers/multi_pay_invoice_controller.go @@ -6,9 +6,9 @@ import ( "strings" "sync" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" diff --git a/nip47/controllers/multi_pay_invoice_controller_test.go b/nip47/controllers/multi_pay_invoice_controller_test.go index c66d4fa87..b9af03e78 100644 --- a/nip47/controllers/multi_pay_invoice_controller_test.go +++ b/nip47/controllers/multi_pay_invoice_controller_test.go @@ -9,11 +9,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47MultiPayJson = ` diff --git a/nip47/controllers/multi_pay_keysend_controller.go b/nip47/controllers/multi_pay_keysend_controller.go index f3931ff49..c02afa4a2 100644 --- a/nip47/controllers/multi_pay_keysend_controller.go +++ b/nip47/controllers/multi_pay_keysend_controller.go @@ -4,8 +4,8 @@ import ( "context" "sync" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" ) diff --git a/nip47/controllers/multi_pay_keysend_controller_test.go b/nip47/controllers/multi_pay_keysend_controller_test.go index c881cd03f..002267182 100644 --- a/nip47/controllers/multi_pay_keysend_controller_test.go +++ b/nip47/controllers/multi_pay_keysend_controller_test.go @@ -9,11 +9,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47MultiPayKeysendJson = ` diff --git a/nip47/controllers/nip47_controller.go b/nip47/controllers/nip47_controller.go index 74875e97b..fd45e9a12 100644 --- a/nip47/controllers/nip47_controller.go +++ b/nip47/controllers/nip47_controller.go @@ -1,10 +1,10 @@ package controllers import ( - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/transactions" "gorm.io/gorm" ) diff --git a/nip47/controllers/pay_invoice_controller.go b/nip47/controllers/pay_invoice_controller.go index b6a706b99..4f955bdf7 100644 --- a/nip47/controllers/pay_invoice_controller.go +++ b/nip47/controllers/pay_invoice_controller.go @@ -5,10 +5,10 @@ import ( "fmt" "strings" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" diff --git a/nip47/controllers/pay_invoice_controller_test.go b/nip47/controllers/pay_invoice_controller_test.go index 2a9508fba..325d97d56 100644 --- a/nip47/controllers/pay_invoice_controller_test.go +++ b/nip47/controllers/pay_invoice_controller_test.go @@ -8,11 +8,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47PayInvoiceJson = ` diff --git a/nip47/controllers/pay_keysend_controller.go b/nip47/controllers/pay_keysend_controller.go index 60c790efb..98a6b98ec 100644 --- a/nip47/controllers/pay_keysend_controller.go +++ b/nip47/controllers/pay_keysend_controller.go @@ -3,11 +3,11 @@ package controllers import ( "context" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" "github.com/sirupsen/logrus" ) diff --git a/nip47/controllers/pay_keysend_controller_test.go b/nip47/controllers/pay_keysend_controller_test.go index dd234cab4..09dca0d86 100644 --- a/nip47/controllers/pay_keysend_controller_test.go +++ b/nip47/controllers/pay_keysend_controller_test.go @@ -8,11 +8,11 @@ import ( "github.com/nbd-wtf/go-nostr" "github.com/stretchr/testify/assert" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" ) const nip47KeysendJson = ` diff --git a/nip47/controllers/sign_message_controller.go b/nip47/controllers/sign_message_controller.go index 15d5c7c6f..6213e9f0e 100644 --- a/nip47/controllers/sign_message_controller.go +++ b/nip47/controllers/sign_message_controller.go @@ -3,8 +3,8 @@ package controllers import ( "context" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" "github.com/sirupsen/logrus" ) diff --git a/nip47/event_handler.go b/nip47/event_handler.go index a8b7b13bd..c71945849 100644 --- a/nip47/event_handler.go +++ b/nip47/event_handler.go @@ -7,13 +7,13 @@ import ( "fmt" "time" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - controllers "github.com/getAlby/nostr-wallet-connect/nip47/controllers" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/nip47/permissions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + controllers "github.com/getAlby/hub/nip47/controllers" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/nip04" "github.com/sirupsen/logrus" diff --git a/nip47/event_handler_test.go b/nip47/event_handler_test.go index b1e874f69..2ce7545ad 100644 --- a/nip47/event_handler_test.go +++ b/nip47/event_handler_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/tests" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/tests" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/nip04" "github.com/stretchr/testify/assert" diff --git a/nip47/models/transactions.go b/nip47/models/transactions.go index 0dc07e15c..b4bd8102e 100644 --- a/nip47/models/transactions.go +++ b/nip47/models/transactions.go @@ -1,7 +1,7 @@ package models import ( - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/transactions" ) func ToNip47Transaction(transaction *transactions.Transaction) *Transaction { diff --git a/nip47/nip47_service.go b/nip47/nip47_service.go index 7618d0d13..5a7996d80 100644 --- a/nip47/nip47_service.go +++ b/nip47/nip47_service.go @@ -3,13 +3,13 @@ package nip47 import ( "context" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/nip47/notifications" - permissions "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/service/keys" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/nip47/notifications" + permissions "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/service/keys" + "github.com/getAlby/hub/transactions" "github.com/nbd-wtf/go-nostr" "gorm.io/gorm" ) diff --git a/nip47/notifications/models.go b/nip47/notifications/models.go index 22b416c80..888c81d83 100644 --- a/nip47/notifications/models.go +++ b/nip47/notifications/models.go @@ -1,6 +1,6 @@ package notifications -import "github.com/getAlby/nostr-wallet-connect/nip47/models" +import "github.com/getAlby/hub/nip47/models" type Notification struct { Notification interface{} `json:"notification,omitempty"` diff --git a/nip47/notifications/nip47_notification_queue.go b/nip47/notifications/nip47_notification_queue.go index 59bf954b2..e5bb5b4b7 100644 --- a/nip47/notifications/nip47_notification_queue.go +++ b/nip47/notifications/nip47_notification_queue.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/logger" ) type Nip47NotificationQueue interface { diff --git a/nip47/notifications/nip47_notifier.go b/nip47/notifications/nip47_notifier.go index be87e4a98..dc51cdc32 100644 --- a/nip47/notifications/nip47_notifier.go +++ b/nip47/notifications/nip47_notifier.go @@ -5,15 +5,15 @@ import ( "encoding/json" "errors" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/service/keys" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/service/keys" + "github.com/getAlby/hub/transactions" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/nip04" "github.com/sirupsen/logrus" diff --git a/nip47/notifications/nip47_notifier_test.go b/nip47/notifications/nip47_notifier_test.go index f0ab0ffcf..5b943ba5d 100644 --- a/nip47/notifications/nip47_notifier_test.go +++ b/nip47/notifications/nip47_notifier_test.go @@ -7,11 +7,11 @@ import ( "testing" "time" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/nip47/permissions" - "github.com/getAlby/nostr-wallet-connect/tests" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/nip47/permissions" + "github.com/getAlby/hub/tests" + "github.com/getAlby/hub/transactions" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/nip04" "github.com/stretchr/testify/assert" diff --git a/nip47/permissions/permissions.go b/nip47/permissions/permissions.go index fa5b6d7e7..3fe913403 100644 --- a/nip47/permissions/permissions.go +++ b/nip47/permissions/permissions.go @@ -5,13 +5,13 @@ import ( "slices" "time" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/transactions" - "github.com/getAlby/nostr-wallet-connect/utils" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/transactions" + "github.com/getAlby/hub/utils" "github.com/sirupsen/logrus" "gorm.io/gorm" ) diff --git a/nip47/permissions/permissions_test.go b/nip47/permissions/permissions_test.go index 7e53146b0..a5224bcc8 100644 --- a/nip47/permissions/permissions_test.go +++ b/nip47/permissions/permissions_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/nip47/models" - "github.com/getAlby/nostr-wallet-connect/tests" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/nip47/models" + "github.com/getAlby/hub/tests" "github.com/stretchr/testify/assert" ) diff --git a/nip47/publish_nip47_info.go b/nip47/publish_nip47_info.go index bb877a9e6..fe7877aee 100644 --- a/nip47/publish_nip47_info.go +++ b/nip47/publish_nip47_info.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/nip47/models" "github.com/nbd-wtf/go-nostr" ) diff --git a/render.yaml b/render.yaml index d6f09e8be..26f796bc3 100644 --- a/render.yaml +++ b/render.yaml @@ -3,7 +3,7 @@ services: runtime: image name: albyhub image: - url: ghcr.io/getalby/nostr-wallet-connect-next:latest + url: ghcr.io/getalby/hub:latest numInstances: 1 region: frankfurt # Default: oregon plan: starter @@ -18,4 +18,4 @@ services: - key: LOG_EVENTS value: true - key: LDK_ESPLORA_SERVER - value: "https://electrs.albylabs.com" + value: "https://electrs.getalby.com" diff --git a/scripts/README.md b/scripts/README.md index 781859b7c..5453f8254 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,11 +1,11 @@ ### Installation on a Raspberry Pi Zero ```shell -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/getAlby/nostr-wallet-connect-next/master/scripts/install.sh)" +/bin/bash -c "$(curl -fsSL https://getalby.com/zero/install.sh)" ``` ### Updating a running instance ```shell -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/getAlby/nostr-wallet-connect-next/master/scripts/update.sh)" +/bin/bash -c "$(curl -fsSL https://getalby.com/zero/update.sh)" ``` diff --git a/scripts/install.sh b/scripts/install.sh index 8b3e370f0..72813d9a6 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -29,10 +29,12 @@ Restart=always RestartSec=1 User=root ExecStart=/opt/albyhub/bin/albyhub +# Hack to ensure Alby Hub never uses more than 90% CPU +CPUQuota=90% Environment="PORT=80" Environment="WORK_DIR=/opt/albyhub/data" -Environment="LDK_ESPLORA_SERVER=https://electrs.albylabs.com" +Environment="LDK_ESPLORA_SERVER=https://electrs.getalby.com" Environment="LOG_EVENTS=true" Environment="LDK_GOSSIP_SOURCE=" diff --git a/scripts/linux-x86_64/phoenixd/README.md b/scripts/linux-x86_64/phoenixd/README.md index f14723220..79ecddc04 100644 --- a/scripts/linux-x86_64/phoenixd/README.md +++ b/scripts/linux-x86_64/phoenixd/README.md @@ -4,14 +4,14 @@ Run your Alby Hub with phoenixd as a backend. ## Requirements -+ Linux distribution -+ Runs pretty much on any VPS or server +- Linux distribution +- Runs pretty much on any VPS or server ## Docker -To run Alby Hub with phoenixd use [docker-compose](https://docs.docker.com/compose/) using the [docker-compose.yml file](https://raw.githubusercontent.com/getAlby/nostr-wallet-connect-next/master/scripts/linux-x86_64/phoenixd/docker-compose.yml). +To run Alby Hub with phoenixd use [docker-compose](https://docs.docker.com/compose/) using the [docker-compose.yml file](https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/phoenixd/docker-compose.yml). - $ wget https://raw.githubusercontent.com/getAlby/nostr-wallet-connect-next/master/scripts/linux-x86_64/phoenixd/docker-compose.yml + $ wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/phoenixd/docker-compose.yml $ docker-compose up # or docker-compose up --pull=always <- to make sure you get the latest images It will run on localhost:8080 by default. You can configure the port by editing the docker-compose.yml file. @@ -26,7 +26,7 @@ Make sure to backup the `albyhub-phoenixd` which is used as volume for albyhub a ### Installation (non-Docker) - $ wget https://raw.githubusercontent.com/getAlby/nostr-wallet-connect-next/master/scripts/linux-x86_64/phoenixd/install.sh + $ wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/phoenixd/install.sh $ ./install.sh The install script will prompt you for a installation folder and will install phoenixd and Alby Hub there. @@ -47,10 +47,9 @@ Or us the start scripts: $ [your install path]/phoenixd/start.sh $ [your install path]/albyhub/start.sh - ### Backup Make sure to backup your data directories: -+ `[your install path]/phoenixd/data` -+ `[your install path]/albyhub/data` +- `[your install path]/phoenixd/data` +- `[your install path]/albyhub/data` diff --git a/scripts/linux-x86_64/phoenixd/docker-compose.yml b/scripts/linux-x86_64/phoenixd/docker-compose.yml index 794e03b9b..9f7b5ef0f 100644 --- a/scripts/linux-x86_64/phoenixd/docker-compose.yml +++ b/scripts/linux-x86_64/phoenixd/docker-compose.yml @@ -2,7 +2,7 @@ services: albyhub: platform: linux/amd64 container_name: albyhub - image: ghcr.io/getalby/nostr-wallet-connect-next:latest + image: ghcr.io/getalby/hub:latest volumes: - ./albyhub-phoenixd:/data ports: diff --git a/service/keys/keys.go b/service/keys/keys.go index 7135db4d9..cde80dd99 100644 --- a/service/keys/keys.go +++ b/service/keys/keys.go @@ -1,8 +1,8 @@ package keys import ( - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/logger" "github.com/nbd-wtf/go-nostr" ) diff --git a/service/models.go b/service/models.go index 9c8e107dc..d0a549a6b 100644 --- a/service/models.go +++ b/service/models.go @@ -1,12 +1,12 @@ package service import ( - "github.com/getAlby/nostr-wallet-connect/alby" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/service/keys" - "github.com/getAlby/nostr-wallet-connect/transactions" + "github.com/getAlby/hub/alby" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/service/keys" + "github.com/getAlby/hub/transactions" "gorm.io/gorm" ) diff --git a/service/service.go b/service/service.go index d57f75655..2e9b6a739 100644 --- a/service/service.go +++ b/service/service.go @@ -16,18 +16,18 @@ import ( "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" - "github.com/getAlby/nostr-wallet-connect/alby" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service/keys" - "github.com/getAlby/nostr-wallet-connect/transactions" - "github.com/getAlby/nostr-wallet-connect/version" - - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/nip47" - "github.com/getAlby/nostr-wallet-connect/nip47/models" + "github.com/getAlby/hub/alby" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service/keys" + "github.com/getAlby/hub/transactions" + "github.com/getAlby/hub/version" + + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/nip47" + "github.com/getAlby/hub/nip47/models" ) type service struct { @@ -58,7 +58,7 @@ func NewService(ctx context.Context) (*service, error) { logger.Logger.Info("AlbyHub " + version.Tag) if appConfig.Workdir == "" { - appConfig.Workdir = filepath.Join(xdg.DataHome, "/alby-nwc") + appConfig.Workdir = filepath.Join(xdg.DataHome, "/albyhub") logger.Logger.WithField("workdir", appConfig.Workdir).Info("No workdir specified, using default") } // make sure workdir exists diff --git a/service/start.go b/service/start.go index 2f44774c2..83715e413 100644 --- a/service/start.go +++ b/service/start.go @@ -10,16 +10,16 @@ import ( "github.com/nbd-wtf/go-nostr/nip19" "github.com/sirupsen/logrus" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/lnclient/breez" - "github.com/getAlby/nostr-wallet-connect/lnclient/cashu" - "github.com/getAlby/nostr-wallet-connect/lnclient/greenlight" - "github.com/getAlby/nostr-wallet-connect/lnclient/ldk" - "github.com/getAlby/nostr-wallet-connect/lnclient/lnd" - "github.com/getAlby/nostr-wallet-connect/lnclient/phoenixd" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/lnclient/breez" + "github.com/getAlby/hub/lnclient/cashu" + "github.com/getAlby/hub/lnclient/greenlight" + "github.com/getAlby/hub/lnclient/ldk" + "github.com/getAlby/hub/lnclient/lnd" + "github.com/getAlby/hub/lnclient/phoenixd" + "github.com/getAlby/hub/logger" ) func (svc *service) StartNostr(ctx context.Context, encryptionKey string) error { @@ -39,7 +39,7 @@ func (svc *service) StartNostr(ctx context.Context, encryptionKey string) error logger.Logger.WithFields(logrus.Fields{ "npub": npub, "hex": svc.keys.GetNostrPublicKey(), - }).Info("Starting nostr-wallet-connect") + }).Info("Starting Alby Hub") svc.wg.Add(1) go func() { //Start infinite loop which will be only broken by canceling ctx (SIGINT) diff --git a/service/stop.go b/service/stop.go index cdff012c9..2ec0fe036 100644 --- a/service/stop.go +++ b/service/stop.go @@ -3,8 +3,8 @@ package service import ( "fmt" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/logger" ) // TODO: this should happen on ctx.Done() rather than having to call manually diff --git a/tests/create_app.go b/tests/create_app.go index 7acb676a3..9a72ba101 100644 --- a/tests/create_app.go +++ b/tests/create_app.go @@ -1,7 +1,7 @@ package tests import ( - "github.com/getAlby/nostr-wallet-connect/db" + "github.com/getAlby/hub/db" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/nip04" ) diff --git a/tests/mock_ln_client.go b/tests/mock_ln_client.go index 18c2fc480..fd8c1f9b2 100644 --- a/tests/mock_ln_client.go +++ b/tests/mock_ln_client.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/getAlby/nostr-wallet-connect/lnclient" + "github.com/getAlby/hub/lnclient" ) // for the invoice: diff --git a/tests/test_service.go b/tests/test_service.go index 2d3c480a7..ec3a5b6bc 100644 --- a/tests/test_service.go +++ b/tests/test_service.go @@ -3,12 +3,12 @@ package tests import ( "os" - "github.com/getAlby/nostr-wallet-connect/config" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/events" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service/keys" + "github.com/getAlby/hub/config" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/events" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service/keys" "gorm.io/gorm" ) diff --git a/transactions/transactions_service.go b/transactions/transactions_service.go index 371dc4c06..9dc3195a6 100644 --- a/transactions/transactions_service.go +++ b/transactions/transactions_service.go @@ -7,9 +7,9 @@ import ( "strings" "time" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/lnclient" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/lnclient" + "github.com/getAlby/hub/logger" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" "gorm.io/gorm" diff --git a/version/version.go b/version/version.go index e2c5b151f..f8f49f473 100644 --- a/version/version.go +++ b/version/version.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/logger" "github.com/sirupsen/logrus" ) @@ -23,7 +23,7 @@ func GetLatestReleaseTag() string { if latestRelease != "" && time.Since(lastVersionCheck) < 5*time.Minute { return latestRelease } - url := "https://api.github.com/repos/getAlby/nostr-wallet-connect-next/releases" + url := "https://api.github.com/repos/getAlby/hub/releases" client := http.Client{ Timeout: time.Second * 10, diff --git a/wails.json b/wails.json index 924d8e75e..64b30e3c4 100644 --- a/wails.json +++ b/wails.json @@ -1,7 +1,7 @@ { "$schema": "https://wails.io/schemas/config.v2.json", - "name": "AlbyHub", - "outputfilename": "Nostr-Wallet-Connect", + "name": "albyhub", + "outputfilename": "albyhub", "frontend:install": "yarn install", "frontend:build": "yarn build:wails", "frontend:dev:watcher": "yarn dev:wails", diff --git a/wails/wails_app.go b/wails/wails_app.go index 001c109e3..4425476ea 100644 --- a/wails/wails_app.go +++ b/wails/wails_app.go @@ -5,9 +5,9 @@ import ( "embed" "log" - "github.com/getAlby/nostr-wallet-connect/api" - "github.com/getAlby/nostr-wallet-connect/logger" - "github.com/getAlby/nostr-wallet-connect/service" + "github.com/getAlby/hub/api" + "github.com/getAlby/hub/logger" + "github.com/getAlby/hub/service" "github.com/wailsapp/wails/v2" "github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options/assetserver" diff --git a/wails/wails_handlers.go b/wails/wails_handlers.go index 5b9f4109d..2d47301a3 100644 --- a/wails/wails_handlers.go +++ b/wails/wails_handlers.go @@ -5,14 +5,15 @@ import ( "fmt" "os" "regexp" + "strconv" "strings" "github.com/sirupsen/logrus" - "github.com/getAlby/nostr-wallet-connect/alby" - "github.com/getAlby/nostr-wallet-connect/api" - "github.com/getAlby/nostr-wallet-connect/db" - "github.com/getAlby/nostr-wallet-connect/logger" + "github.com/getAlby/hub/alby" + "github.com/getAlby/hub/api" + "github.com/getAlby/hub/db" + "github.com/getAlby/hub/logger" "github.com/wailsapp/wails/v2/pkg/runtime" ) @@ -201,6 +202,38 @@ func (app *WailsApp) WailsRequestRouter(route string, method string, body string return WailsRequestRouterResponse{Body: paymentInfo, Error: ""} } + listTransactionsRegex := regexp.MustCompile( + `/api/transactions`, + ) + + switch { + case listTransactionsRegex.MatchString(route): + limit := uint64(20) + offset := uint64(0) + + // Extract limit and offset parameters + paramRegex := regexp.MustCompile(`[?&](limit|offset)=([^&]+)`) + paramMatches := paramRegex.FindAllStringSubmatch(route, -1) + for _, match := range paramMatches { + switch match[1] { + case "limit": + if parsedLimit, err := strconv.ParseUint(match[2], 10, 64); err == nil { + limit = parsedLimit + } + case "offset": + if parsedOffset, err := strconv.ParseUint(match[2], 10, 64); err == nil { + offset = parsedOffset + } + } + } + + transactions, err := app.api.ListTransactions(ctx, limit, offset) + if err != nil { + return WailsRequestRouterResponse{Body: nil, Error: err.Error()} + } + return WailsRequestRouterResponse{Body: transactions, Error: ""} + } + paymentRegex := regexp.MustCompile( `/api/payments/([0-9a-zA-Z]+)`, ) @@ -371,12 +404,6 @@ func (app *WailsApp) WailsRequestRouter(route string, method string, body string } res := WailsRequestRouterResponse{Body: invoice, Error: ""} return res - case "/api/transactions": - transactions, err := app.api.ListTransactions(ctx) - if err != nil { - return WailsRequestRouterResponse{Body: nil, Error: err.Error()} - } - return WailsRequestRouterResponse{Body: transactions, Error: ""} case "/api/wallet/sync": app.api.SyncWallet() return WailsRequestRouterResponse{Body: nil, Error: ""}