Skip to content

Commit

Permalink
feat: make it easier to run multiple hubs locally (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Dec 17, 2024
1 parent c3d9c81 commit 2d1327e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ _To configure via env, the following parameters must be provided:_

- `LDK_ESPLORA_SERVER`: By default the optimized Alby esplora is used. You can configure your own esplora server (note: the public blockstream one is slow and can cause onchain syncing and issues with opening channels)
- `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 Network Configuration

Expand All @@ -188,7 +189,7 @@ See [Phoenixd](scripts/linux-x86_64/phoenixd/README.md)

Create an OAuth client at the [Alby Developer Portal](https://getalby.com/developer) 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, OAuth redirects will not work locally if running the react app you will need to manually change the port to 5173. **Login in Wails mode is not yet supported**
> If running the React app locally, make sure to set `FRONTEND_URL=http://localhost:5173` so that the OAuth redirect works.
## Getting Started with Mutinynet

Expand All @@ -214,14 +215,29 @@ Follow the steps to integrate Mutinynet with your NWC Next setup:

3. After the transaction confirms, the new channel will appear in the Channels section

### Opening a Channel in NWC Next
### Opening a Channel from Alby Hub

1. From the Channels interface (`/channels`), select "Open a Channel" and opt for "Custom Channel."

2. Enter the pubkey of the Faucet Lightning Node (omit host and port details) available on the [Mutinynet Faucet](https://faucet.mutinynet.com/) page.

3. Specify a channel capacity greater than 25,000 sats, confirm the action, and return to the Channels page to view your newly established channel.

### Running Multiple Hubs Locally

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=0.0.0.0:9736,[::]:9736

Then launch the frontend with `VITE_PORT=5174 VITE_API_URL=http://localhost:8081 yarn dev:http`

## Application deeplink options

### `/apps/new` deeplink options
Expand Down
1 change: 1 addition & 0 deletions config/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type AppConfig struct {
LDKGossipSource string `envconfig:"LDK_GOSSIP_SOURCE"`
LDKLogLevel string `envconfig:"LDK_LOG_LEVEL" default:"3"`
LDKVssUrl string `envconfig:"LDK_VSS_URL"`
LDKListeningAddresses string `envconfig:"LDK_LISTENING_ADDRESSES" default:"0.0.0.0:9735,[::]:9735"`
MempoolApi string `envconfig:"MEMPOOL_API" default:"https://mempool.space/api"`
AlbyClientId string `envconfig:"ALBY_OAUTH_CLIENT_ID" default:"J2PbXS1yOf"`
AlbyClientSecret string `envconfig:"ALBY_OAUTH_CLIENT_SECRET" default:"rABK2n16IWjLTZ9M1uKU"`
Expand Down
5 changes: 3 additions & 2 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ export default defineConfig(({ command }) => ({
...(command === "serve" ? [insertDevCSPPlugin] : []),
],
server: {
port: process.env.VITE_PORT ? parseInt(process.env.VITE_PORT) : undefined,
proxy: {
"/api": {
target: "http://localhost:8080",
target: process.env.VITE_API_URL || "http://localhost:8080",
secure: false,
},
"/logout": {
target: "http://localhost:8080",
target: process.env.VITE_API_URL || "http://localhost:8080",
secure: false,
},
},
Expand Down
11 changes: 5 additions & 6 deletions lnclient/ldk/ldk.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
logDirPath := filepath.Join(newpath, "./logs")

ldkConfig := ldk_node.DefaultConfig()
listeningAddresses := []string{
"0.0.0.0:9735",
"[::]:9735",
}
listeningAddresses := strings.Split(cfg.GetEnv().LDKListeningAddresses, ",")

ldkConfig.TrustedPeers0conf = []string{
lsp.OlympusLSP().Pubkey,
lsp.AlbyPlebsLSP().Pubkey,
Expand Down Expand Up @@ -136,8 +134,9 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
}

logger.Logger.WithFields(logrus.Fields{
"migrate_storage": migrateStorage,
"vss_enabled": vssToken != "",
"migrate_storage": migrateStorage,
"vss_enabled": vssToken != "",
"listening_addresses": listeningAddresses,
}).Info("Creating node")
var node *ldk_node.Node
if vssToken != "" {
Expand Down

0 comments on commit 2d1327e

Please sign in to comment.