Skip to content

Commit ee9da62

Browse files
authored
Update INSTALL.md (#534)
1 parent 5aa7ba1 commit ee9da62

File tree

1 file changed

+86
-118
lines changed

1 file changed

+86
-118
lines changed

Diff for: docs/INSTALL.md

+86-118
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,67 @@
77
## Table of contents
88
- [Purpose](#purpose)
99
- [Target](#target)
10-
- [Scope](#scope-of-the-system)
10+
- [System Scope](#system-scope)
1111
- [Technical requirements](#technical-requirements)
12-
- [Prepare the environment](#prepare-the-environment)
13-
- [Docker](#docker)
14-
- [MongoDB](#mongodb)
15-
- [P2plnbot](#p2plnbot)
16-
- [Connect to the Lightning node](#connect-to-the-lightning-node)
12+
- [Installation](#installation-1)
13+
- [Using the bot](#using-the-bot)
1714

15+
## Purpose
1816

19-
## Purpose.
17+
Allow people to trade with other people on Telegram using the _Lightning Network_. The _lnp2pbot_ is developed in Node.js and connects to an LND (Lightning Network Daemon) node is a full implementation of a Lightning Network node.
2018

21-
To allow people to trade with other people on Telegram using the _Lightning_ network. The _p2plnbot_ bot is developed in nodejs and connects to a LND (Lightning Network Daemon) node is a full implementation of a Lightning Network node.
19+
## Target
2220

23-
## Target.
21+
Achieving that the telegram bot is able to receive payments _Lightning_ without being custodian. Users won't need permission to use the service or provide personal data that could compromise their privacy, thus maintaining full custody of their assets at all times. The bot will use hold invoices and will only settle the seller's invoices when both parties agree. Immediately after this, the bot will pay the buyer's invoice.
2422

25-
Achieving that the telegram bot is able to receive payments _Lightning_ without being custodian, that is; that the user will not need permission to use the service, or provide personal data
26-
that may compromise their privacy thereby achieving retain full custody of their goods at all times, for this the bot will use withheld invoices and only settle such invoices from the seller
27-
when each party agrees to it and just after that time the bot will pay the buyer's invoice.
23+
## System Scope
2824

29-
## Scope of the system.
25+
Reach all users who want to acquire non-custodial Bitcoin satoshis through a Telegram bot.
3026

31-
Reach all users who require to acquire Bitcoin satoshis without custody through a bot on Telegram.
32-
33-
## Technical requirements.
27+
## Technical requirements
3428

3529
1) Computer with internet access.
36-
2) Node Management System [Polar.](https://lightningpolar.com/)
30+
2) Node management system [Polar](https:/lightningpolar.com/) or LND node.
3731

3832
![polar](images/polar.jpg)
3933

34+
3) [Docker](https://www.docker.com/): automation of application deployment as portable, self-sufficient containers that can run in the cloud or locally.
35+
36+
4) [MogoDB](https://www.mongodb.com/): database manager system.
4037

41-
3) [Docker](https://www.docker.com/): deployment automation of applications as portable, self-contained containers that can be run in the cloud or locally.
42-
4) [MogoDB](https://www.mongodb.com/) as a database manager.
38+
## Installation
4339

44-
## Prepare the environment.
40+
### Prepare the environment.
4541

46-
1) Check if you have Nodejs installed.
42+
#### 1) Check if Node.js is installed.
4743

4844
```
4945
$ node -v
5046
```
47+
In case it's not installed:
5148

52-
In case you do not have it installed:
53-
54-
* On Mac run the following instruction:
49+
* On Mac run the following command:
5550
```
5651
$ brew install node
5752
```
5853

59-
* On Windows go to the following [link](https://nodejs.org/en/download/)
60-
* On Linux:
54+
* On Linux and Windows, go to the following [link](https://nodejs.org/en/download/).
6155

62-
```
63-
$ sudo apt install npm
64-
```
6556

66-
## Docker
57+
### MongoDB Configuration with Docker Compose
58+
59+
#### 2. Create the Directory and Configuration File
6760

68-
2) Create a directory where you will place the `docker-compose.yml` file for MongoDB with the following values:
61+
Create a directory where you will place the `mongo.yml` file for MongoDB:
6962

7063
```
71-
mkdir mongodb
72-
cd mongodb
73-
mkdir db-data
74-
vi docker-compose.yml
64+
$ mkdir mongodb
65+
$ cd mongodb
66+
$ nano mongo.yml
7567
```
7668

77-
The file must contain the following:
78-
69+
#### 3. Content of the mongo.yml file
70+
The contents of the `mongo.yml` file must be:
7971
```
8072
version: "3.7"
8173
@@ -86,138 +78,114 @@ services:
8678
MONGO_INITDB_ROOT_USERNAME: mongoadmin
8779
MONGO_INITDB_ROOT_PASSWORD: secret
8880
volumes:
89-
- ./db-data/:/data/db
81+
- ./mongodb-data/:/data/db
9082
ports:
9183
- 27017:27017
92-
```
93-
94-
3) Check if Docker is up with the following instruction:
9584
9685
```
97-
$ docker ps –a
98-
```
99-
100-
_Note: When executing the first command you will see the image you have created._
101-
102-
* Lift the container.
10386

87+
#### 4. Start MongoDB
88+
To start MongoDB, run the following command:
10489
```
105-
$ docker-compose up –d
90+
$ docker compose -f mongo.yml up
10691
```
10792

108-
* To enter the container, you must execute the following instructions:
109-
93+
### Lnp2pbot
94+
#### 5. Clone the Bot Repository
95+
Clone the bot [repository](https://github.com/lnp2pBot/bot) and navigate to the project directory:
11096
```
111-
$ docker ps –a
97+
$ git clone https://github.com/lnp2pBot/bot.git
98+
$ cd bot
99+
$ npm install
112100
```
113101

114-
* This command will show you the ID that has been created to later enter the container:
115-
102+
#### 6. Create and Configure the .env file
103+
In the root directory of the project, you will find a sample `.env-sample` file. Copy that file and edit it to configure your environment variables:
116104
```
117-
$ docker exec -it <container id> /bin/bash
105+
$ cp .env-sample .env
106+
$ nano .env
118107
```
119108

120-
_Note: Entering the container will allow you to enter the DB._
109+
#### Connect to the Lightning Node
110+
To connect to an `LND` node, you need to set several variables in the `.env` file created in the previous step:
121111

122-
## MongoDB
112+
- _LND_CERT_BASE64:_ TLS certificate of the LND node in base64 format. You can obtain it with the command: `~/.lnd/tls.cert | tr -d '\n'`.
123113

124-
4) Login to MongoDB
114+
- _LND_MACAROON_BASE64:_ Macaroon file in base64 format. This file contains permissions to perform actions on the LND node. You can obtain it with the command:`~/.lnd/data/chain/bitcoin
115+
/mainnet/admin.macaroon | tr -d '\n',`
125116

126-
```
127-
$ mongo admin -u mongoadmin –p secret
128-
$ show dbs
129-
$ use nueva_db ej.
130-
```
131-
132-
## P2plnbot
117+
- _LND_GRPC_HOST:_ IP address or domain name of the LND node and the port, separated by a colon. Example: `192.168.0.2:10009`.
133118

134-
5) Clone the [repository](https://github.com/grunch/p2plnbot.git) of the bot:
119+
If you are using [Polar](https://lightningpolar.com/), you can obtain the necessary information as shown in the following image:
135120

136-
```
137-
$ git clone https://github.com/grunch/p2plnbot.git
138-
$ cd p2plnbot
139-
$ npm install
140-
```
141-
6) Create a `.env` file, in the root directory of the project, there is a sample file, so you only need to copy it and fill in some data:
121+
![polarVariables](images/polarVariables.jpg)
142122

143-
* Execute the following instructions:
123+
#### Complete the configuration of the `.env` file
144124

145-
```
146-
$ cp .env-sample .env
147-
$ vi .env
148-
```
125+
Here are the variables you need to modify in the `.env` file. The remaining variables can either keep their default values or be adjusted as you see fit:
149126

150-
## Connect to the Lightning node.
151127

152-
• To connect to an `lnd` node, we need to set some variables:
128+
```
129+
LND_CERT_BASE64=''
130+
LND_MACAROON_BASE64=''
131+
LND_GRPC_HOST=''
132+
BOT_TOKEN=''
153133
154-
**LND_CERT_BASE64:** TLS certificate of the LND node in base64 format, you can get it in base64 format. `~/.lnd/tls.cert | tr -d '\n'` in the lnd node.
134+
DB_USER='mongoadmin'
135+
DB_PASS='secret'
136+
DB_HOST='127.0.0.1'
137+
DB_PORT='27017'
138+
DB_NAME='lnp2pbot'
155139
156-
**LND_MACAROON_BASE64:** Macaron file in base64 format, the macaron file contains permission to perform actions on the lnd node, you can get it with base64 `~/.lnd/data/chain/bitcoin/mainnet
157-
/admin.macaroon | tr -d '\n',`
140+
MONGO_URI='mongodb://mongoadmin:secret@localhost/lnp2pbot?authSource=admin'
158141
159-
* If you are using Polar you get the data as shown in the following image:
142+
CHANNEL='@your-offers-channel'
143+
ADMIN_CHANNEL='-10*****46'
144+
HELP_GROUP='@your-support-group'
160145
161-
![polarVariables](images/polarVariables.jpg)
146+
FIAT_RATE_EP='https://api.yadio.io/rate'
162147
148+
DISPUTE_CHANNEL='@your-dispute-channel'
163149
164-
**LND_GRPC_HOST:** IP address or the domain name from the LND node and the port separated by a colon, e.g: `192.168.0.2:10009.`
150+
NOSTR_SK=''
165151
166-
**BOT_TOKEN:** u will need to log in to Telegram and search for `BotFather.` Execute the menu and select `Create a new bot` where you will choose the name of the bot and the user, once gener
167-
ated it will show a token number that will be placed in this field.
152+
RELAYS=''
168153
169-
**CHANNEL:** Create a channel in Telegram, to do this press the write new message button. On Android it is in the lower right corner with a round icon with a pencil, and on iOS it is in the
170-
upper right corner with a rather small icon in the shape of a pencil. Tap on the `New channel` option.
154+
```
171155

172-
**ADMIN_CHANNEL:** This data will be the ID of your channel, to get it write a message in your channel, forward it to the bot `@JsonDumpBot` and it will show you a JSON with the channel ID.
156+
Details of some variables:
173157

174-
![telegram_bot](images/telegram_bot.jpg)
158+
- _BOT_TOKEN:_ You will need to go to Telegram and open [@BotFather](https://t.me/BotFather). Run the menu and choose `Create a new bot` where you will select the bot's name and username. Once generated, it will show you a token that you will place in this field.
175159

176-
* More information [aquí.](https://gist.github.com/mraaroncruz/e76d19f7d61d59419002db54030ebe35)
160+
- _CHANNEL:_ This is the channel where the bot posts offers. Create a channel on Telegram by pressing the button to write a new message. On Android, it is in the bottom right corner with a round icon featuring a pencil, and on iOS, it is in the top right corner with a small pencil-shaped icon. Press the `New Channel` option. Then, set the bot as a channel's administrator (open the bot and select: _Add to a group or channel_).
177161

178-
* File `.env`
162+
- _ADMIN_CHANNEL:_ This channel is where the bot sends relevant information to administrators, such as payments failures, when a user takes an order but doesn't proceed, among other things. In this field, you need to enter the channel ID. To obtain it, write a message in the channel, forward it to the `@JsonDumpBot`, and it will show you a JSON with the channel ID. More information can be found [here](https://gist.github.com/mraaroncruz/e76d19f7d61d59419002db54030ebe35). You need to add the bot as a channel's administrator.
179163

180-
```
181-
LND_CERT_BASE64=
182-
LND_GRPC_HOST='127.0.0.1:10001'
183-
BOT_TOKEN=''
184-
FEE=.001
185-
DB_USER='mongoadmin'
186-
DB_PASS='secret'
187-
DB_HOST='localhost'
188-
DB_PORT='27017'
189-
DB_NAME='p2plnbot'
164+
![telegram_bot](images/telegram_bot.jpg)
190165

191-
INVOICE_EXPIRATION_WINDOW=60000
192-
HOLD_INVOICE_EXPIRATION_WINDOW=60
193-
CHANNEL='@yournewchannel' # channel created by you, the bot must be admin here
194-
ADMIN_CHANNEL='-10******46' # Info dumped from the bot @JsonDumpBot
166+
- _HELP_GROUP:_ This is the group where you will provide bot support. You can create a new group or use an existing one.
195167

196-
MAX_DISPUTES=8
197-
HOLD_INVOICE_CLTV_DELTA=144
198-
HOLD_INVOICE_CLTV_DELTA_SAFETY_WINDOW=12
168+
- _DISPUTE_CHANNEL:_ This channel is where the bot posts disputes for solvers to take on (it's not a channel for resolving disputes, just for claiming them). You need to create this channel on Telegram and add the bot as an administrator.
199169

200-
PENDING_PAYMENT_WINDOW=5
170+
- _NOSTR_SK:_ The private key for [Nostr](https://nostr.com/) that will publish the bot's offers as a [replaceable parameterized event type 38383](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds). If you do not want your bot to publish offers on [Nostr](https://nostr.com/), comment out this variable.
201171

202-
FIAT_RATE_EP='https://api.yadio.io/rate'
203-
```
204-
• Once the file has been edited, execute the following instruction:
172+
- _RELAYS:_ The Nostr relays that the [Nostr](https://nostr.com/) user of your bot will connect to in order to publish offers. If you do not want your bot to publish offers on [Nostr](https://nostr.com/), comment out this variable.
205173

174+
### 7. Running the bot
206175
```
207176
$ npm start
208177
```
209178

210-
• For testing purposes:
211-
179+
- For testing purposes:
212180
```
213181
$ npm test
214182
```
215183

216-
## Start with the bot.
184+
## Using the bot
217185

218-
• It will be necessary to have already created a bot with `BotFather`, to have another number to use with Telegram and to have opened channels in Polar.
186+
After completing the [Installation](#installation-1) steps:
219187

220-
1) You must start the bot with the same account with the command:
188+
Start the bot with the command:
221189

222190
```
223191
/start

0 commit comments

Comments
 (0)