|
| 1 | +# Setting up an always listening wallet |
| 2 | + |
| 3 | +For some use cases, like mining Grin, it's important to have a wallet that is always listening for incoming transactions. For this use case and others like it, configuring `grin-wallet` as a service is recommended and easy to do. |
| 4 | + |
| 5 | +## Set up grin-wallet as a service |
| 6 | + |
| 7 | +Create a service file for `grin-wallet`: |
| 8 | + |
| 9 | +```bash |
| 10 | +sudo nano /etc/systemd/system/grin-wallet.service |
| 11 | +``` |
| 12 | + |
| 13 | +Paste the following content into the file. The following configuration assumes a 'grin' user will be running the process with the wallet configuration living in `/var/lib/grin`. Wallet configuration by default is saved to the user's home directory in `.grin`. If you installed the snap package, your wallet command will be `grin.wallet` instead. |
| 14 | + |
| 15 | +``` |
| 16 | +[Unit] |
| 17 | +Description=grin wallet |
| 18 | +After=network.target |
| 19 | +
|
| 20 | +[Service] |
| 21 | +WorkingDirectory=/var/lib/grin |
| 22 | +User=grin |
| 23 | +Group=grin |
| 24 | +PrivateDevices=yes |
| 25 | +Type=simple |
| 26 | +ExecReload=/bin/kill -HUP $MAINPID |
| 27 | +KillMode=mixed |
| 28 | +KillSignal=SIGTERM |
| 29 | +TimeoutStopSec=60 |
| 30 | +ExecStart=/usr/local/bin/grin-wallet listen |
| 31 | +Restart=on-failure |
| 32 | +RestartSec=30 |
| 33 | +
|
| 34 | +[Install] |
| 35 | +WantedBy=multi-user.target |
| 36 | +Alias=grin.service |
| 37 | +``` |
| 38 | + |
| 39 | +Tell systemd to reload (you need to do that every time you edit this file): |
| 40 | + |
| 41 | +```bash |
| 42 | +systemctl daemon-reload |
| 43 | +``` |
| 44 | + |
| 45 | +Now try to start the wallet service: |
| 46 | + |
| 47 | +```bash |
| 48 | +sudo systemctl start grin-wallet |
| 49 | +``` |
| 50 | + |
| 51 | +And check to see if it's running: |
| 52 | + |
| 53 | +```bash |
| 54 | +ps aux | grep grin-wallet |
| 55 | +``` |
| 56 | + |
| 57 | +That should give you two lines of output like this: |
| 58 | + |
| 59 | +```bash |
| 60 | +grin 269149 0.0 0.0 971240 10804 ? Sl Aug25 0:00 /usr/local/bin/grin-wallet listen |
| 61 | +ubuntu 336964 0.0 0.0 7004 2168 pts/0 S+ 22:02 0:00 grep --color=auto grin-wallet |
| 62 | +``` |
| 63 | + |
| 64 | +## Handling a wallet password |
| 65 | + |
| 66 | +If your wallet is configured with a password, the `ExecStart` line in `grin-wallet.service` should probably look something like this... |
| 67 | + |
| 68 | +```bash |
| 69 | +ExecStart=/bin/sh -c 'cat wallet-password.txt | /usr/local/bin/grin-wallet listen' |
| 70 | +``` |
| 71 | + |
| 72 | +Drop you wallet's password in `wallet-password.txt`. Make sure this file lives in the configured `WorkingDirectory` and that correct read permissions are set. The contents of this file will be fed into the `grin-wallet` command. |
| 73 | + |
| 74 | +## Verifying your wallet is online and reachable |
| 75 | + |
| 76 | +Run the following command to get your wallet's address: |
| 77 | + |
| 78 | +```bash |
| 79 | +grin-wallet info |
| 80 | +``` |
| 81 | + |
| 82 | +Grab the address that is displayed and search for it on [grinchck](https://grinchck.uber.space/) |
| 83 | + |
| 84 | +[More information on grinchck](https://forum.grin.mw/t/is-this-grin-wallet-url-reachable/7349) |
0 commit comments