- User authentication with LNUrl-Auth
- Onboarding flow with auth / wallet creation / user creation
- Lightning wallet management with LNBits
- MongoDB for storing Users and Posts
- Next-Auth for Session management and authentication
- Tipping flow for Posts
If you are running locally you need to rename .env.sample to .env
.env.sample contains all of the necessary environment variables (some of them being optional/prefilled) with comments describing their purpose.
In .env.sample there is an environment variable MONGO_URI you can set with your MongoDB connection string. If you are familiar with MongoDB, you can use your existing MongoDB instance by providing the connection string. If you don't have a MongoDB instance or are new to it, follow the steps below to set up a free serverless instance with MongoDB Atlas.
-
Visit MongoDB Atlas and sign up for a new account or log in to your existing account.
-
Click on "Create a New Cluster" and choose the "Free Shared" tier.
- Select your preferred cloud provider, region, and choose a name for your cluster. Then, click on "Create Cluster" to start the deployment process. This may take a few minutes.
- Once the cluster is deployed, click on "Connect" to set up the connection to your cluster.
- In the "Connect to Your Cluster" window, click on "Connect to your application." which might be called "Drivers"
-
Choose your preferred driver and version. Copy the connection string provided.
-
Replace with the password you created for your MongoDB user and with the name of your database (e.g., pleb-post). It should look something like this:
mongodb+srv://<username>:<password>@cluster0.mongodb.net/<dbname>?retryWrites=true&w=majority
-
If you haven't made a MongoDB user yet, follow these steps:
-
Click on the "Database Access" tab on the left sidebar.
-
Click "Add New Database User".
-
Type in a username / password for this user and choose their permissions. Now this username and password can be used directly in your mongo uri string.
- Finally, paste the connection string into the .env file as the value for MONGO_URI.
MONGO_URI=mongodb+srv://<username>:<password>@cluster0.mongodb.net/<dbname>?retryWrites=true&w=majority
Now your MongoDB instance is connected, and the application will use it to store Users and Posts data.
- Visit https://legend.lnbits.com/ and create a wallet with any name
- Click on the "extensions" tab in the sidebar and enable the User Manager extension
- Now click on the User Manager extension on the sidebar. The wallet you are now in will be the admin for the user manager wallet
- Copy the URL and save it as the LN_BITS_USER_MANAGER_URL env variable in .env
- Click on the "Post user + initial wallet" tab on the right sidebar and copy the admin_id from the example request. Put this as the LN_BITS_ADMIN_ID env variable in your .env
- Now copy the X-Api-Key value from the same example request and set it as the LN_BITS_KEY env variable in your .env
-
Click 'Create Node'
- Choose LND
- You can pick a Lite Node to start and use testnet if you are still in development or mainnet if you just wanna start ripping some real invoices
- Create a username and password for your node and be sure to write them down
- After your node is done initializing you should see this message on your node's home page to request a free inbound channel! This will allow us to instantly start receiving sats into our LNBits instance from the wider network.
- Now go to the dashboards page in the sidebar and click 'Create Dashboard' under LNBits
- Once LNBits is initialized you can click 'Launch Dashboard' and put in your node's password to login
- Now click on the 'Manage Extensions' tab in the left sidebar, scroll down to the "User Manager" extension and click "enable"
- Now click on the User Manager extension on the sidebar. The wallet you are now in will be the admin for the user manager wallet
- Copy the URL and save it as the LN_BITS_USER_MANAGER_URL env variable in .env
- Click on the "GET users" tab on the right sidebar and copy the first part of the URL in the example request. Put this as the NEXT_PUBLIC_LN_BITS_DOMAIN env variable in your .env
- In the same "GET users" tab on the right sidebar copy the FULL URL in the example request. Put this as the LN_BITS_USER_MANAGER_API env variable in your .env
- Click on the "Post user + initial wallet" tab on the right sidebar and copy the admin_id from the example request. Put this as the LN_BITS_ADMIN_ID env variable in your .env
- Now copy the X-Api-Key value from the same example request and set it as the LN_BITS_KEY env variable in your .env
Great now you have your own LNBits instance running on your Voltage node and with these ENV variables updated pleb-post will now be integrated! Once your free inbound channel from Voltage is confirmed you should be able to start sending sats into any of your LNBits wallets (though you will need to open a well connected outbound channel to spend out of your instance to the wider network)