You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[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)
17
14
15
+
## Purpose
18
16
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.
20
18
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
22
20
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.
24
22
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
28
24
29
-
## Scope of the system.
25
+
Reach all users who want to acquire non-custodial Bitcoin satoshis through a Telegram bot.
30
26
31
-
Reach all users who require to acquire Bitcoin satoshis without custody through a bot on Telegram.
2) Node management system[Polar](https:/lightningpolar.com/) or LND node.
37
31
38
32

39
33
34
+
3)[Docker](https://www.docker.com/): automation of application deployment as portable, self-sufficient containers that can run in the cloud or locally.
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
43
39
44
-
## Prepare the environment.
40
+
###Prepare the environment.
45
41
46
-
1) Check if you have Nodejs installed.
42
+
#### 1) Check if Node.js is installed.
47
43
48
44
```
49
45
$ node -v
50
46
```
47
+
In case it's not installed:
51
48
52
-
In case you do not have it installed:
53
-
54
-
* On Mac run the following instruction:
49
+
* On Mac run the following command:
55
50
```
56
51
$ brew install node
57
52
```
58
53
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/).
61
55
62
-
```
63
-
$ sudo apt install npm
64
-
```
65
56
66
-
## Docker
57
+
### MongoDB Configuration with Docker Compose
58
+
59
+
#### 2. Create the Directory and Configuration File
67
60
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:
69
62
70
63
```
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
75
67
```
76
68
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:
79
71
```
80
72
version: "3.7"
81
73
@@ -86,138 +78,114 @@ services:
86
78
MONGO_INITDB_ROOT_USERNAME: mongoadmin
87
79
MONGO_INITDB_ROOT_PASSWORD: secret
88
80
volumes:
89
-
- ./db-data/:/data/db
81
+
- ./mongodb-data/:/data/db
90
82
ports:
91
83
- 27017:27017
92
-
```
93
-
94
-
3) Check if Docker is up with the following instruction:
95
84
96
85
```
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.
103
86
87
+
#### 4. Start MongoDB
88
+
To start MongoDB, run the following command:
104
89
```
105
-
$ docker-compose up –d
90
+
$ dockercompose -f mongo.yml up
106
91
```
107
92
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:
* 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:
116
104
```
117
-
$ docker exec -it <container id> /bin/bash
105
+
$ cp .env-sample .env
106
+
$ nano .env
118
107
```
119
108
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:
121
111
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'`.
123
113
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',`
125
116
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`.
133
118
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:
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
+

142
122
143
-
* Execute the following instructions:
123
+
#### Complete the configuration of the `.env` file
144
124
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:
149
126
150
-
## Connect to the Lightning node.
151
127
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=''
153
133
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'
155
139
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
* 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'
160
145
161
-

146
+
FIAT_RATE_EP='https://api.yadio.io/rate'
162
147
148
+
DISPUTE_CHANNEL='@your-dispute-channel'
163
149
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=''
165
151
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=''
168
153
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
+
```
171
155
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:
173
157
174
-

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.
175
159
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_).
177
161
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.
179
163
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
+

190
165
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.
195
167
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.
199
169
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.
201
171
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.
205
173
174
+
### 7. Running the bot
206
175
```
207
176
$ npm start
208
177
```
209
178
210
-
• For testing purposes:
211
-
179
+
- For testing purposes:
212
180
```
213
181
$ npm test
214
182
```
215
183
216
-
## Start with the bot.
184
+
## Using the bot
217
185
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:
219
187
220
-
1) You must start the bot with the same account with the command:
0 commit comments