Alby Hub - Your Own Center for Internet Money
Alby Hub allows you to control your Lightning node or wallet from any other application that supports NWC. Connect apps like Damus or Amethyst to your node. There are many more available on https://nwc.dev/.
The application can run in two modes:
- Desktop (Wails app): Mac (arm64), Windows (amd64), Linux (amd64)
- HTTP (Web app): Docker, Linux (amd64), Mac (arm64)
Ideally the app runs 24/7 (on a node, VPS or always-online desktop/laptop machine) so it can be connected to a lightning address and receive online payments.
Visit albyhub.com to learn more and get started and get Alby Hub running in minutes.
Go to the Deploy it yourself section below.
By default Alby Hub uses the embedded LDK based lightning node. Optionally it can be configured to use an external node:
- LND
- Phoenixd
- Cashu
- CLN
- want more? please open an issue.
- Go
- Node
- NPM
- Yarn
$ cp .env.example .env
# edit the config for your needs (Read further down for all the available env options)
$ vim .env
-
Create a Lightning Polar setup with two LND nodes and uncomment the Polar LND section in your
.envfile. -
Compile the frontend or run
touch frontend/dist/tmpto ensure there are embeddable files available. -
go run cmd/http/main.go
Go to /frontend
yarn installyarn dev:http
$ yarn build:http
If you plan to run Alby Hub on a subpath behind a reverse proxy, you can do:
$ BASE_PATH="/hub" yarn build:http
Make sure to have wails installed and all platform-specific dependencies installed (see wails doctor)
$ wails dev -tags "wails"
If you get a blank screen, try running in your normal terminal (outside of vscode, and make sure HTTP frontend is not running)
$ wails build -tags "wails"
$ mkdir tmp
$ go build -o main cmd/http/main.go
$ cp main tmp
$ cp .env tmp
$ cd tmp
$ ./main
$ docker build . -t nwc-local --progress=plain
$ docker run -v $(pwd)/.data/docker:/data -e WORK_DIR='/data' -p 127.0.0.1:8080:8080 nwc-local
In vscode open cmd/http/main.go and then press F5. You can set breakpoints in the Alby Hub code and third party modules
$ go test ./...
$ go test ./... -run TestHandleGetInfoEvent
By default, sqlite is used for testing. It is also possible to run the tests with PostgreSQL.
The tests use pgtestdb to set up a temporary PostgreSQL database, which requires a running PostgreSQL server. Follow your OS instructions to install PostgreSQL, or use the official Docker image.
See the docker compose file for an easy way to get started.
When PostgreSQL is installed and running, set the TEST_DATABASE_URI environment variable to the PostgreSQL connection string. For example:
$ export TEST_DATABASE_URI="postgresql://user:password@localhost:5432/postgres"
Note that the PostgreSQL user account must be granted appropriate permissions to create new databases. When the tests complete, the temporary database will be removed.
Do not use a production database. It is preferable to launch a dedicated PostgreSQL instance for testing purposes.
We use testify/mock to facilitate mocking in tests. Instead of writing mocks manually, we generate them using vektra/mockery. To regenerate them, install mockery and run it in the project's root directory:
$ mockery
Mockery loads its configuration from the .mockery.yaml file in the root directory of this project. To add mocks for new interfaces, add them to the configuration file and run mockery.
The application supports both the Go pprof library and the DataDog profiler.
To enable Go pprof, set the GO_PROFILER_ADDR environment variable to the address you want the profiler to be available on (e.g. localhost:6060).
Now, you should be able to access the pprof web interface at http://localhost:6060/debug/pprof.
You can use the go tool pprof command to collect and inspect the profiling data. For example, to profile the application for 30 seconds and then open the pprof web UI, run:
go tool pprof -http=localhost:8081 -seconds=30 http://localhost:6060/debug/pprof/profileFor more information on the Go pprof library, see the official documentation.
$ go run -ldflags="-X 'github.com/getAlby/hub/version.Tag=v0.6.0'" cmd/http/main.go
The following configuration options can be set as environment variables or in a .env file
RELAY: default: "wss://relay.getalby.com,wss://relay2.getalby.com" (supports multiple separated by commas)DATABASE_URI: A sqlite filename or postgres URL. Default is SQLite DBnwc.dbwithout a path, which will be put in the user home directory: $XDG_DATA_HOME/albyhub/nwc.dbPORT: The port on which the app should listen on (default: 8080)WORK_DIR: Directory to store NWC data files. Default: $XDG_DATA_HOME/albyhubLOG_LEVEL: Log level for the main application. Higher is more verbose. Default: 4 (info)SETUP_CODE: Require this code to set up Alby Hub. Open Alby Hub with?c=<code>appended to the URL, or enter the code when prompted.AUTO_UNLOCK_PASSWORD: Provide unlock password to auto-unlock Alby Hub on startup (e.g. after a machine restart). Unlock password still be required to access the interface.BOLTZ_API: A Boltz-compatible API which provides swaps functionality. If not set, the swap provider is chosen by Alby (mainnet only; swaps are disabled on other networks)NETWORK: On-chain network used for the node. Default: "bitcoin"REBALANCE_SERVICE_URL: service url for rebalancing existing channels.
The chain source is used by the LDK backend to sync, and with every backend to look up on-chain transactions and addresses for swaps. Lookups are never sent to a server other than the configured one.
ELECTRUM_SERVER: By default the optimized Alby electrum server is used. You can configure your own electrum server (e.g.127.0.0.1:50001for a self-hosted server, orssl://host:50002for a server using SSL).ESPLORA_SERVER: Use an esplora server as the chain source instead of electrum (note: the public blockstream one is slow and can cause onchain syncing and issues with opening channels)BITCOIND_RPC_HOST,BITCOIND_RPC_PORT,BITCOIND_RPC_USER,BITCOIND_RPC_PASSWORD: Use your own bitcoind as the chain source instead of electrum or esplora, e.g.BITCOIND_RPC_HOST=127.0.0.1BITCOIND_RPC_PORT=8332BITCOIND_RPC_USER=yourusernameBITCOIND_RPC_PASSWORD=yourpassword
Bitcoind does not need -txindex: transactions are looked up in the mempool and the last 288 blocks. Bitcoind has no address index, so auto swap to an xpub is not available.
Wait until bitcoind has finished its initial sync before starting Alby Hub. If a hub with channels is started while bitcoind is still syncing, the channels can be force-closed.
If you import a seed, on-chain funds received before the import are not found: with bitcoind the on-chain wallet starts at the current block and does not scan older ones.
With the LDK backend, a full (non-pruned) bitcoind is required for now. With a pruned bitcoind, the LDK node cannot verify lightning gossip and will not be able to find routes for outgoing payments.
There is a boltz regtest fork with mempool service and alby-specific instructions here
Make sure to update your RPC password below (docker exec boltz-bitcoind cat /app/bitcoin/regtest/.cookie | cut -d: -f2), and change your work directory each time you restart boltz (it is ephemeral):
WORK_DIR=.data/boltz-regtest-1
BITCOIND_RPC_HOST="127.0.0.1"
BITCOIND_RPC_PORT="18443"
BITCOIND_RPC_USER="__cookie__"
BITCOIND_RPC_PASSWORD="f7460d81974b000b63e46c0e880243cf28bbaf93938b6e38494628f1f1700f23"
# or use esplora
#ESPLORA_SERVER=http://localhost:4002/api
NETWORK="regtest"
LDK_LISTENING_ADDRESSES="0.0.0.0:19735"
BOLTZ_API=http://localhost:9001
PORT=8082
MEMPOOL_API=http://localhost:8123/api
And then run the frontend with: VITE_API_URL="http://localhost:8082" yarn dev:http
To test auto-swaps to xpub you can use sparrow wallet in regtest:
/opt/sparrow/bin/Sparrow -n regtest
Sparrow needs to be connected to regtest boltz setup Bitcoin Core RPC (127.0.0.1:18443 with user:password as __cookie__:cookiepassword) with an imported mnemonic and copied the tpub from the settings page
A coding agent can start boltz regtest, write the .env above and run the hub, so you only need to use the UI and ask for things like "send 1M sats to bcrt1...", "give me the LND-1 pubkey", "pay 101251 sats to bcrt1... from an external wallet" or "mine a block". This works well in a sandbox environment that supports docker (e.g. a full VM, not an LXC container) with ~32GB of free disk space for the docker images. The agent should:
- Use a fresh git worktree for the branch being tested, so it starts without an existing
.envor.datadirectory - Run the scripts container helpers non-interactively (the
aliases.shhelpers usedocker exec -it, which needs a TTY):docker exec boltz-scripts bash -c 'source /etc/profile.d/utils.sh && bitcoin-cli-sim-client -generate 1' - Use
lncli-sim 1 getinfofor the LND-1 pubkey, as it changes on every restart (connect via<pubkey>@127.0.0.1:29735) - Follow swap progress in the hub logs (
Lockup transaction found in mempool,Swap succeeded)
Migration of the database is currently experimental. Please make a backup before continuing.
-
Stop the running hub
-
Update the
DATABASE_URIto your destination e.g.postgresql://myuser:mypass@localhost:5432/nwc -
Run the migration:
go run cmd/db_migrate/main.go -from .data/nwc.db -to postgresql://myuser:mypass@localhost:5432/nwc
No manual steps are needed: create a migration file from Settings -> Migrate Alby Hub. The contents of the Postgres database will automatically be copied into a Sqlite database which is included in the migration file. Alternatively, run the migration tool manually:
go run cmd/db_migrate/main.go -from postgresql://myuser:mypass@localhost:5432/nwc -to .data/nwc.db
ENABLE_ADVANCED_SETUP: set tofalseto force a specific backend type (combined with backend parameters below)
Can be configured via env or the UI
LN_BACKEND_TYPE: CLNCLN_ADDRESS: the CLN grpc address (grpc-host and grpc-port), e.g.127.0.0.1:9737CLN_LIGHTNING_DIR: CLN's lightning directory containing the grpc certificates, usually~/.lightning/<network>
Optional for hold invoice methods support:
CLN_ADDRESS_HOLD: the CLN hold plugin grpc address (grpc-host and grpc-port), e.g.127.0.0.1:9738
If you are copying the certificates to another machine make sure you get the ca.pem, client.pem and client-key.pem from the lightning directory and optionally from the hold directory inside the lightning directory and keep the sub-directory structure of the hold directory.
LND can be configured via env. Other node types may need to be configured via the UI.
To configure via env, the following parameters must be provided:
LN_BACKEND_TYPE: LNDLND_ADDRESS: the LND gRPC address, eg.localhost:10009(used with the LND backend)LND_CERT_FILE: the location where LND'stls.certfile can be found (used with the LND backend)LND_MACAROON_FILE: the location where LND'sadmin.macaroonfile can be found (used with the LND backend)
- The chain source is configured for all backends, see Chain source.
LDK_VSS_URL: Use VSS (encrypted remote storage) rather than local sqlite store for lightning and bitcoin data. Currently this feature only works for brand new Alby Hub instances that are connected to Alby Accounts with an active subscription plan.LDK_LISTENING_ADDRESSES: configure listening addresses, required for public channels, and ideally reachable if you would like others to be able to initiate peering with your node.LDK_ANNOUNCEMENT_ADDRESSES: configure announcement addresses (only required if you use a VPN)LDK_MAX_CHANNEL_SATURATION: Sets the maximum portion of a channel's total capacity that may be used for sending a payment, expressed as a power of 1/2. Seemax_channel_saturation_power_of_halfin LDK docs.LDK_MAX_PATH_COUNT: Maximum number of paths that may be used by MPP payments.LDK_LOG_LEVEL: Log level for the LDK node. Higher is more verbose. Default: 3. This is separate from the main application log level, allowing you to enable more verbose LDK logging (e.g., level 4, 5 or 6) without enabling verbose logging for the entire application.LDK_CHANNEL_MONITOR_WARNING_SIZE_BYTES: If a channel monitor is larger than this value, a performance warning will be shown on the node page.LDK_LSPS2_ADDRESSES: Override the LSPS2 just-in-time (JIT) LSP provider for receiving. When set, Alby Hub can receive payments even without inbound liquidity: the configured LSP opens a channel on the fly and the fee is deducted from the incoming payment. Expected format is a single<pubkey>@<host>:<port>. When set, the "Open Your First Channel" prompts are hidden since the first channel is created automatically on the first receive.
MEMPOOL_API=https://mutinynet.com/apiNETWORK=signetELECTRUM_SERVER=electrum.mutinynet.com:50001LDK_GOSSIP_SOURCE=https://rgs.mutinynet.com/snapshot(NOTE: by default ALby Hub does not use RGS)
(or esplora instead of electrum)
ESPLORA_SERVER=https://mutinynet.com/api
MEMPOOL_API=https://mempool.space/signet/apiNETWORK=signetESPLORA_SERVER=https://mempool.space/signet/api
MEMPOOL_API=https://mempool.space/testnet/apiNETWORK=testnetESPLORA_SERVER=https://mempool.space/testnet/apiLDK_GOSSIP_SOURCE=https://rapidsync.lightningdevkit.org/testnet/snapshot(NOTE: by default ALby Hub does not use RGS)
See Phoenixd
Bark connects to an Ark server. It can be configured via env.
LN_BACKEND_TYPE: BARKBARK_SERVER: the Ark server URL. For signet usehttps://ark.signet.2nd.devBARK_ESPLORA_SERVER: the Esplora server URL used for chain data. For signet usehttps://esplora.signet.2nd.dev.BARK_SERVER_ACCESS_TOKEN: an optional access token, only required if using a private Ark server.BARK_LOG_LEVEL: Log level for Bark. Higher is more verbose. Default: 3. This is separate from the main application log level, allowing you to enable more verbose Bark logging (e.g., level 4 or 5) without enabling verbose logging for the entire application.
Create an OAuth client at the Alby Developer Portal and set your ALBY_OAUTH_CLIENT_ID and ALBY_OAUTH_CLIENT_SECRET in your .env. If not running locally, you'll also need to change your BASE_URL.
If running the React app locally, make sure to set
FRONTEND_URL=http://localhost:5173so that the OAuth redirect works.
Follow the steps to integrate Mutinynet with your NWC Next setup:
-
Configure your environment with the Mutinynet LDK parameters
-
Proceed as described in the Development section to run the frontend and backend
-
Navigate to
channels/outgoing, copy your On-Chain Address, then visit the Mutinynet Faucet to deposit sats. Ensure the transaction confirms on mempool.space -
Your On-chain balance will update under
/channels
-
To create a channel, use the Mutinynet Faucet by entering your desired Channel Capacity and Amount to Push
-
Locate your Node ID. In the Wallet click on the status on the top right "online". This shows the node ID or look in the NWC Next logs. Then input this in the Connection String field on the faucet page to request a Lightning Channel
{"level":"info","msg":"Connected to LDK node","nodeId":"<your node ID>","time":"<timestamp>"}
- After the transaction confirms, the new channel will appear in the Channels section
-
From the Channels interface (
/channels), select "Open a Channel" and opt for "Custom Channel." -
Enter the pubkey of the Faucet Lightning Node (omit host and port details) available on the Mutinynet Faucet page.
-
Specify a channel capacity greater than 25,000 sats, confirm the action, and return to the Channels page to view your newly established channel.
You can run multiple hubs locally to e.g. open channels between the two nodes or test sending payments between them. Currently this will only work with LDK.
You will need two copies of the alby hub repository.
For the second hub, you will need to update your .env with the following changes:
FRONTEND_URL=http://localhost:5174
BASE_URL=http://localhost:8081
PORT=8081
LDK_LISTENING_ADDRESSES=[::]:9736
Then launch the frontend with VITE_PORT=5174 VITE_API_URL=http://localhost:8081 yarn dev:http
Clients can use a deeplink to allow the user to add a new connection. Depending on the client this URL has different query options:
The default option is that the NWC app creates a secret and the user uses the nostr wallet connect URL string to enable the client application.
name: the name of the client app
Example:
/apps/new?name=myapp
If the client creates the secret the client only needs to share the public key of that secret for authorization. The user authorized that pubkey and no sensitivate data needs to be shared.
name: the name of the client apppubkey: the public key of the client's secret for the user to authorizereturn_to: (optional) if areturn_toURL is provided the user will be redirected to that URL after authorization. Thelud16,relayandpubkeyquery parameters will be added to the URL.expires_at(optional) connection cannot be used after this date. Unix timestamp in seconds.max_amount(optional) maximum amount in millisats that can be sent per renewal periodbudget_renewal(optional) reset the budget at the end of the given budget renewal. Can benever(default),daily,weekly,monthly,yearlyrequest_methods(optional) url encoded, space separated list of request types that you need permission for:pay_invoice(default),get_balance(see NIP47). For example:..&request_methods=pay_invoice%20get_balancenotification_types(optional) url encoded, space separated list of notification types that you need permission for: For example:..¬ification_types=payment_received%20payment_sentisolated(optional) makes an isolated app connection with its own balance and only access to its own transaction list. e.g.&isolated=true. If using this option, you should not pass any custom request methods or notification types, nor set a budget or expiry.
Example:
/apps/new?name=myapp&pubkey=47c5a21...&return_to=https://example.com
Web clients can open a new prompt popup to load the authorization page.
Once the user has authorized the app connection a nwc:success message is sent to the webview (using dispatchEvent) or opening page (using postMessage) to indicate that the connection is authorized. See the fromAuthorizationUrl() function in the alby-js-sdk
If you need help contact support@getalby.com or reach out on Nostr: npub1getal6ykt05fsz5nqu4uld09nfj3y3qxmv8crys4aeut53unfvlqr80nfm You can also visit the chat of our Community on Telegram.
For security vulnerabilities, please follow our security policy.
Want to support the work on Alby?
Support the Alby team ⚡️hello@getalby.com You can also contribute to our bounty program: ⚡️bounties@getalby.com
✅ NIP-47 info event
❌ expiration tag in requests
✅ get_info
✅ get_balance
✅ pay_invoice
⚠️ amount not supported (for amountless invoices)⚠️ PAYMENT_FAILED error code not supported
✅ pay_keysend
⚠️ PAYMENT_FAILED error code not supported
✅ make_invoice
✅ lookup_invoice
⚠️ NOT_FOUND error code not supported
✅ list_transactions
⚠️ from and until in request not supported⚠️ failed payments will not be returned
✅ multi_pay_invoice
⚠️ amount not supported (for amountless invoices)⚠️ PAYMENT_FAILED error code not supported
✅ multi_pay_keysend
⚠️ PAYMENT_FAILED error code not supported
Run NWC on your own node!
NOTE: the below links are for the original version of NWC
- https://github.com/getAlby/umbrel-community-app-store
- https://github.com/horologger/nostr-wallet-connect-startos
Warning
Alby Hub is intended to run on a secure, private network (for example your home network or behind a VPN). Do not expose it directly to the public internet. By default the HTTP server listens on all network interfaces, so restrict access with a firewall or bind it to a private address. For remote access without exposing it publicly, see the Tailcat example.
The application has no runtime dependencies. (simple Go executable).
As data storage SQLite is used.
For the default backend which runs a node internally we recommend 2GB of RAM + 1GB of disk space (or 512MB RAM + 2GB swap can also be used). For connecting to an external node, Alby Hub uses very little RAM (256MB is enough).
Go to the Quick start script which you can run as a service.
Go to the Quick start script which you can run as a service.