aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man/sentrum.1
blob: d2190091a9ec2b8b89cbf39d6474ef7faac31c8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
.nh
.TH sentrum
.PP





.PP
Daemon that monitors the Bitcoin blockchain for transactions involving your
wallets and sends you notifications in many different channels (ntfy push
notifications, email, telegram, nostr, arbitrary command, etc).

.PP
Example screenshot of many noifications for a single transaction:

  


.SH Installation
.PP
Either:

.RS
.IP \(bu 2
Download the binary from the
releases page
\[la]https://github.com/sommerfelddev/sentrum/releases\[ra]
.IP \(bu 2
Install \fBcargo\fR, compile from source using \fBcargo install sentrum\fR (binary
will be installed in \fB~/.cargo/bin\fR)
.IP \(bu 2
If using archlinux, install it from the AUR:
sentrum
\[la]https://aur.archlinux.org/packages/sentrum\[ra],
sentrum-bin
\[la]https://aur.archlinux.org/packages/sentrum\-bin\[ra] or
sentrum-git
\[la]https://aur.archlinux.org/packages/sentrum\-git\[ra]

.RE

.SH Configuration
.SS Config file path
.PP
It will look for a \fBsentrum.toml\fR configuration file located in any of these
directories (with this priority):

.RS
.IP "  1." 5
Current working directory
.IP "  2." 5
\fB$XDG_CONFIG_HOME/sentrum\fR
.IP "  3." 5
\fB~/.config/sentrum\fR
.IP "  4." 5
\fB/etc/sentrum\fR (more appropriate if running as a systemd service)

.RE

.PP
Alternatively, you can pass the configuration file path as an argument in the
invocation and that will override any of the above.

.PP
\fBStart by copying the sample configuration to where you want it.\fP E.g.

.EX
cp sentrum.sample.toml sentrum.toml
.EE

.PP
or

.EX
sudo cp sentrum.sample.toml /etc/sentrum/sentrum.toml
.EE

.SS What to configure
.PP
You can use the 
\[la]sentrum.sample.toml\[ra] file as an
example.
Most options have very good defaults so you don't need to change them unless you
want to. \fBIn the examples below, commented options showcase their defaults,
unless explicitly said otherwise.\fP

.SS Required
.RS
.IP \(bu 2
\fBwallets\fR: what wallets you want to monitor
.IP \(bu 2
\fBactions\fR: what actions you want to take once a relevant transaction is found

.RE

.SS Optional
.RS
.IP \(bu 2
\fBelectrum\fR: by default, public electrum servers are used. You can configure it
to connect to your own
.IP \(bu 2
\fBmessage\fR: this allows you to configure the subject and body templates of the
notification message and choose the relevant data from the transaction that
you want to include

.RE

.SH Wallets
.PP
For each wallet you want to track, add the following configuration:

.EX
[[wallets]]
# Identifier for naming purposes (required)
name = "alice"
# Wallet xpub (required)
xpub = "xpub6CkXHzuU1NyHUFNiQZLq2bgt6QPqjZbwpJ1MDgDeo4bWZ8ZP7HZr7v9WTLCQFhxVhqiJNcw5wSKE77rkAK1SzcuHjt36ZUibBHezGzGL9h9"
# Script kind ("legacy","nested_segwit","segwit","taproot") (optional)
#kind = "segwit"
.EE

.PP
It assumes a BIP84 (native segwit, \fBbc1\fR style addresses) wallet. If your wallet
has a different script kind add the field \fBkind = "legacy"\fR (or \fBnested_segwit\fR,
or \fBtaproot\fR).

.SS Multisig and friends
.PP
More complex wallet types are supported by providing \fBdescriptor = "<desc>"\fR and
\fBchange_descriptor = "<desc>"\fR wallet descriptors instead of \fBxpub =\fR and
\fBkind =\fR\&. You don't need to provide \fBchange_descriptor\fR, it's optional, and
many times the main descriptor already includes it. Example:

.EX
[[wallets]]
name = "charlie"
descriptor = "wsh(sortedmulti(2,[bbc5fee8/48h/1h/0h/2h]tpubDEuo3nCajorgHFrA5unQB3dSR3Mh7EPfedyU36GC2wVLwB32PsDuiPcsw5RobqNRfQyjas3cxeEraxs6HYJvQPcNX5neut2jRvZijyxLiqT/<0;1>/*,[3f007faa/48h/1h/0h/2h]tpubDEgyzFTDNEUcy674okNRZFuV1Q3P3RNdhd5FwncHBZ9DpZNHR3FGm5c4n8co1Efg3Xv6cUCPuPraJ85j8CV2QXqhLdXn38uyNoSX3rVMpbC/<0;1>/*,[c478c82d/48h/1h/0h/2h]tpubDFKmAnxyJKb7LLQ2UDU4ytFZ1Lx5R7C9op23Ew7zxDwCHDMUhqWfmgMi7d6YNSfKnsW3wp9QEU4TuNJxcPCcAi4ddCYsVL9ken6tWGPD9jz/<0;1>/*))#3l992dql"
.EE

.PP
You can retrieve the wallet descriptor for practically any wallet using Sparrow
Wallet by opening the wallet, going to
\fBSettings >> Script Policy >> Descriptor Edit\fR\&. A window will pop-up where you
can copy the wallet descriptor string and paste it as the \fBdescriptor =\fR value
of the \fBsentrum.toml\fR\&.

.PP
Not all scripts are supported. \fBsentrum\fR depends on bdk which only supports
these scripts
\[la]https://bitcoindevkit.org/descriptors/\[ra]\&.

.SH Actions
.PP
For each new relevant transaction, you can take multiple actions. For each
action you desire to take, you need to add the configuration:

.EX
[[actions]]
# Action type (required)
type =  "<INSERT ACTION KIND>"
<.... INSERT ACTION SPECIFIC CONFIGURATION HERE...>
.EE

.PP
Below we explain the configuration for each action kind. You can have multiple
actions of the same kind (e.g. you want to send multiple emails from different
accounts for some reason).

.SS ntfy
.PP
This is the best straightforward way to get push notifications on a smartphone.

.RS
.IP "  1." 5
Install the android/iOS app following the relevant links in https://ntfy.sh
.IP "  2." 5
Open the app, give it the needed permissions

.RE

.PP
Then you just need to add the relevant configuration:

.EX
[[actions]]
type =  "ntfy"
#
# EVERYTHING BELOW IS OPTIONAL
#
# Credentials (optional, relevant for self-hosted instances or paid reserved topics)
# You can also use an access token by setting the username to an empty string ""
#credentials.username = "<YOUR USERNAME HERE>"
#credentials.password = "<YOUR PASSWORD HERE>"
# ntfy server (optional)
#url = "https://ntfy.sh"
# notification channel name (optional, defaults to random string for security)
#topic = "<RANDOM TOPIC NAME>"
# Proxy used to connect (optional, defaults to None)
#proxy = "socks5://127.0.0.1:9050"
# Priority ("max", "high", "default", "low", "min") (optional)
#priority = "default"
.EE

.PP
If you don't set a \fBtopic =\fR, \fBsentrum\fR will auto-generate one for you randomly
(since topic names are kind of like a password for the public default ntfy.sh
server). When you later run \fBsentrum\fR, it will print out the topic name it's
using.

.PP
Open the ntfy app, click on the \fB+\fR button, create a "topic" and set the same
equal to the one should be the \fBsentrum\fR logs.

.SS nostr
.PP
Get notified by a nostr NIP04 encrypted
DM
\[la]https://github.com/nostr\-protocol/nips/blob/master/04.md\[ra] (leaks metadata
but widely supported) or a
NIP59 GiftWrap sealed sender DM
\[la]https://github.com/nostr\-protocol/nips/blob/master/59.md\[ra]
(more private but not supported by many clients). Add:

.EX
[[actions]]
type = "nostr"
# Which npub to send the DM (required)
recipient = "<YOUR npub, hex pubkey, nprofile or nip05>"
# If NIP59 giftwrap DMs should be used instead of NIP04 (optional)
#sealed_dm = false
# Which relays to use to send DMs
#relays = ["wss://nostr.bitcoiner.social", "wss://nostr.oxtr.dev", "wss://nostr.orangepill.dev", "wss://relay.damus.io"]
.EE

.SS email
.PP
You need to add the configuration below and essentially configure an
authenticated connection to your email provider's SMTP server. I cannot help you
out with every provider's weird rules (maybe you need to allow 3rd party apps
for gmail, who knows).

.EX
[[actions]]
type =  "email"
# SMTP server (required)
server = "<insert smtp server url (e.g. smtp.gmail.com)"
# SMTP connection type ("tls", "starttls" or "plain") (optional)
#connection = "tls"
# SMTP port (optional, defaults to 587 for TLS, 465 for STARTTLS and 25 for plain connections
#port = 1025
# SMTP credentials (required in most cases)
credentials.authentication_identity = "<insert login email>"
credentials.secret = "<insert password>"
# Accept self signed certificates (needed if you are using protonmail-bridge) (optional)
#self_signed_cert = false
# Configure sender (required)
from = "sentrum <youremailhere@host.tld>"
# Configure recipient (optional, defaults to the same as the "from" sender)
#to = "sentrum <youremailhere@host.tld>"
.EE

.SS telegram
.RS
.IP "  1." 5
Create a new bot using @Botfather
\[la]https://t.me/botfather\[ra] to get a token in the format \fB123456789:blablabla\fR\&.
.IP "  2." 5
Optionally configure the bot (name, profile pic, etc) with @Botfather
.IP "  3." 5
Open a chat with your bot
.IP "  4." 5
Add the relevant config:

.RE

.EX
[[actions]]
type =  "telegram"
# Auth token of the bot created with @Botfather (required)
bot_token = "<insert bot token>"
# 10-digit user id of the DM recipient, go to your profile to get it (required)
user_id = 1234567890
.EE

.SS command
.PP
Runs an external command where you can use transaction details as arguments.
You can check what parameters (such as \fB{wallet}\fR or \fB{tx_net}\fR you can use in
the message
\[la]#message\[ra] configuration, since they are the same.

.EX
[[actions]]
type = "command"
cmd = "notify-send"
args = ["[{wallet}] new tx: {tx_net} sats"]
.EE

.SS terminal_print
.PP
Justs prints the notification text in the terminal. You can potentially pipe it
to something else.

.EX
[[actions]]
type =  "terminal_print"
.EE

.SS desktop_notification
.PP
Displays the transaction message as a native desktop notification on the same
computer sentrum is running.

.EX
[[actions]]
type =  "desktop_notification"
.EE

.SH Message
.PP
You can configure the message template and it applies to almost every action
type. This configuration is entirely optional since the default templates will
be used if omitted.

.PP
Here is the default template:

.EX
[message]
subject = "[{wallet}] new transaction"
body = "net: {tx_net} sats, balance: {total_balance} sats, txid: {txid_short}"
# Can be "plain", "markdown" or "html"
format = "plain"
# Configure blockexplorer urls. This is used to create the {tx_url} parameter
block_explorers.mainnet = "https://mempool.space/tx/{txid}"
block_explorers.testnet = "https://mempool.space/testnet/tx/{txid}"
block_explorers.signet = "https://mempool.space/signet/tx/{txid}"
.EE

.PP
In the subject and body templates, you can use the following parameters:

.RS
.IP \(bu 2
\fB{tx_net}\fR: difference between the owned outputs and owned inputs
.IP \(bu 2
\fB{wallet}\fR: name of the configured wallet
.IP \(bu 2
\fB{total_balance}\fR: total balance of the wallet
.IP \(bu 2
\fB{txid}\fR: txid of the transaction
.IP \(bu 2
\fB{txid_short}\fR: truncated txid, easier on the eyes
.IP \(bu 2
\fB{received}\fR: sum of owned outputs
.IP \(bu 2
\fB{sent}\fR: sum of owned inputs
.IP \(bu 2
\fB{fee}\fR: transaction fee
.IP \(bu 2
\fB{current_height}\fR: current blockheight
.IP \(bu 2
\fB{tx_height}\fR: blockheight transaction confirmation
.IP \(bu 2
\fB{confs}\fR: number of transaction confirmations (0 for unconfirmed)
.IP \(bu 2
\fB{conf_timestamp}\fR: timestamp of the first confirmation in the \fB%Y-%m-%d %H:%M:%S\fR format
.IP \(bu 2
\fB{tx_url}\fR: a block explorer URL to the transaction

.RE

.SH Electrum server
.PP
By default, public electrum servers will be used. I \fBstrongly suggest
configuring your own electrum server if you want privacy (as you should)\fP\&.

.PP
The defaults are:

.EX
[electrum]
# Defaults:
# - mainnet: ssl://fulcrum.sethforprivacy.com:50002
# - testnet: ssl://electrum.blockstream.info:60002
# - signet: ssl://mempool.space:60602
# Use "tcp://" if you are connecting without SSL (e.g. "tcp://localhost:50001"
# or "tcp://fwafiuesngirdghrdhgiurdhgirdgirdhgrd.onion:50001"
url = "ssl://fulcrum.sethforprivacy.com:50002"
# blockchain network ("bitcoin", "testnet", "signet", "regtest")
network = "bitcoin"
# Optional socks5 proxy (defaults to None)
#socks5 = 127.0.0.1:9050
# If using ssl with a trusted certificate, set this to true
certificate_validation = false
.EE


.SH Usage
.PP
Just run \fBsentrum\fR without arguments (uses default config search paths) or
\fBsentrum <path/to/config/file>\fR\&.

.PP
You can pass the \fB--test\fR flag to send a single test notification to all
configured actions.

.PP
By default, only new transactions can trigger actions. If you pass
\fB--notify-past-txs\fR, it will send notifications of past transactions
in the initial wallet sync. If you have a long transaction history, this will
spam your notification channels for every transaction.

.SH systemd service
.PP
The ideal use-case is as a long running daemon, so it makes sense to configure
it as a systemd service.

.PP
If you installed sentrum from the AUR, you just need to edit
\fB/etc/sentrum/sentrum.conf\fR and do \fBsudo systemclt enable --now sentrum.service\fR

.PP
If you are installing \fBsentrum\fR manually (e.g. from the releases page or \fBcargo
install\fR), you should (either from the cloned repository or from inside the
extracted release archive):

.RS
.IP "  1." 5
Copy systemd files to appropriate places:

.RE

.EX
sudo cp contrib/systemd/sentrum.service /etc/systemd/system
sudo cp contrib/systemd/sentrum.sysusers /etc/sysusers.d/sentrum.conf
sudo cp contrib/systemd/sentrum.tmpfiles /etc/tmpfiles.d/sentrum.conf
.EE

.RS
.IP "  1." 5
Reload systemd daemon, sysusers and tmpfiles:

.RE

.EX
sudo systemclt daemon-reload
sudo systemd-sysusers
sudo systemd-tmpfiles --create
.EE

.RS
.IP "  1." 5
Place the \fBsentrum.toml\fR (or \fBsentrum.sample.toml\fR) configuration file in
\fB/etc/sentrum\fR and make sure the \fBsentrum\fR user owns it:

.RE

.EX
sudo cp sentrum.toml /etc/sentrum
sudo chown sentrum:sentrum /etc/sentrum/sentrum.toml
.EE

.RS
.IP "  1." 5
Enable and start the service:

.RE

.EX
sudo systemclt enable --now sentrum.service
.EE

.RS
.IP "  1." 5
Check if everything is fine with \fBsystemctl status sentrum\fR
.IP "  2." 5
Check the logs with \fBjournalctl -fu sentrum\fR

.RE

.SH Docker
.PP
To run sentrum using Docker, you can either build the image yourself or use the prebuilt image.

.SS Building the image
.PP
To build the image from source, run the following:

.EX
git clone https://github.com/sommerfelddev/sentrum.git
cd sentrum
docker build -t sentrum:local .
.EE

.PP
To use the prebuilt image, simply pull from GHCR:

.EX
docker pull docker pull ghcr.io/sommerfelddev/sentrum:latest
.EE

.PP
Note that there are two types of tags:

.PP
\fBlatest\fR: a tag from the latest commit to master
\fBx.x.x\fR: (i.e. \fB0.1.1\fR) a tag of the corresponding sentrum version

.SS Running the image
.PP
To run the image, simply run the following, passing in the \fBsentrum.toml\fR file you created and configured earlier:

.EX
docker run --rm -it --volume ./sentrum.toml:/sentrum.toml ghcr.io/sommerfelddev/sentrum:latest
.EE

.PP
If using Docker compose, you can configure the service as follows:

.EX
services:
  sentrum:
    container_name: sentrum
    image: ghcr.io/sommerfelddev/sentrum:latest
    restart: unless-stopped
    volumes:
      - ./sentrum.toml:/sentrum.toml
.EE

.SH Future Work
.RS
.IP \(bu 2
More action types:
.RS
.IP \(bu 2
Matrix DM
.IP \(bu 2
SimpleX chat DM
.IP \(bu 2
IRC
.IP \(bu 2
XMPP
.IP \(bu 2
Whatsapp/Signal using linked devices (harder)
.IP \(bu 2
HTTP request

.RE

.IP \(bu 2
More wallet types:
.RS
.IP \(bu 2
Single Address (blocked by
https://github.com/bitcoindevkit/bdk/issues/759)
.IP \(bu 2
Collections of wallets as a single entity

.RE

.IP \(bu 2
Notifications for the first tx confirmation and after N confirmations
.IP \(bu 2
Filtering notifications by the transaction amounts (e.g. no action for
transactions smaller than 1M sats)
.IP \(bu 2
Debian package (using \fBcargo-deb\fR)
.IP \(bu 2
Allow per wallet actions
.IP \(bu 2
Support other blockchain backends (bitcoind-rpc, explora, block filters, dojo)
.IP \(bu 2
Maybe create a little web UI that helps with writing the configuration
.IP \(bu 2
Incentivize node distributions to package sentrum

.RE