Skip to content

Instantly share code, notes, and snippets.

@openoms

openoms/thunderhub.md Secret

Last active Aug 13, 2020
Embed
What would you like to do?
ThunderHub Installation

example: https://www.thunderhub.io/
https://github.com/apotdevin/thunderhub
use lnd v0.10.0 for full compatibility

RaspiBlitz install script:

https://github.com/rootzoll/raspiblitz/blob/v1.6/home.admin/config.scripts/bonus.thunderhub.sh
usage:

# update NodeJS
wget https://raw.githubusercontent.com/rootzoll/raspiblitz/v1.6/home.admin/config.scripts/bonus.nodejs.sh
bash bonus.nodejs.sh off
bash bonus.nodejs.sh on
# download thunderhub install script
wget https://raw.githubusercontent.com/rootzoll/raspiblitz/v1.6/home.admin/config.scripts/bonus.thunderhub.sh
# run
bash bonus.thunderhub.sh on

Manual installation on a RaspiBlitz:

# Preparations
# check and install NodeJS
/home/admin/config.scripts/bonus.nodejs.sh

# open the firewall for the chosen port (here: 3010)
# set any free port (the default port: 3000 is reserved for RTL)
# fill in the approrpriate local subnet (here: 192.168.0.0/16)
sudo ufw allow from 192.168.0.0/16 to any port 3010 comment 'allow ThunderHub on LAN'

# create a dedicated Hidden Service (if Tor is on)):
/home/admin/config.scripts/internet.hiddenservice.sh thunderhub 80 3010

# create thunderhub user
sudo adduser --disabled-password --gecos "" thunderhub

# change to thunderhub user
sudo su - thunderhub

git clone https://github.com/apotdevin/thunderhub.git
cd thunderhub
npm install
npm run build

# run this in Tmux if you want to keep it running after closing the terminal
npm run start -- -p 3010

Connect to RASPIBLITZ_IP:3010 or to the TOR_HIDDEN_SERVICE.onion in the Tor Browser.

Copy the HEX macaroon and TLS.cert from the menu: LNDCREDS -> EXPORT -> HEX
Use localhost or the LAN_IP and the GRPC port 10009.

Afterwards use the command to run (in Tmux if you want to keep it running after closing the terminal):

sudo su - thunderhub
cd thunderhub
npm run start:compatible -- -p 3010

To uninstall ThunderHub:

sudo userdel -rf thunderhub

To update ThunderHub:

with the RaspiBlitz install script:

bash bonus.thunderhub.sh update

Manual:

sudo systemctl stop thunderhub
sudo su - thunderhub
cd thunderhub
git pull
npm install
npm run build
exit
sudo systemctl start thunderhub

.env file:

nano /home/thunderhub/thunderhub/.env

# -----------
# Server Configs
# -----------
LOG_LEVEL='debug'
# HODL_KEY='HODL_HODL_API_KEY'
# BASE_PATH='/basePath'

# -----------
# Interface Configs
# -----------
THEME='dark'
# CURRENCY='sat'
# FETCH_PRICES=false
# FETCH_FEES=false

# -----------
# Account Configs
# -----------
ACCOUNT_CONFIG_PATH='/home/thunderhub/thubConfig.yaml'
#COOKIE_PATH='/home/thunderhub/.cookie'
#SSO_SERVER_URL='127.0.0.1:10009'
#SSO_CERT_PATH='/home/thunderhub/.lnd/tls.cert'
#SSO_MACAROON_PATH='/home/thunderhub/.lnd/data/chain/bitcoin/mainnet/'

thubConfig.yaml:

nano /home/thunderhub/thubConfig.yaml

masterPassword: 'PASSWORD' # Default password unless defined in account
accounts:
  - name: 'blitz'
    serverUrl: '127.0.0.1:10009'
    macaroonPath: '/home/thunderhub/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'
    certificatePath: '/home/thunderhub/.lnd/tls.cert'
   #password: 'accountpassword'

Systemd unit

(can copy-paste the whole script)

    # install service
    echo "*** Install ThundeHub systemd for ${network} on ${chain} ***"
    cat > /home/admin/thunderhub.service <<EOF
# Systemd unit for thunderhub
# /etc/systemd/system/thunderhub.service

[Unit]
Description=ThunderHub daemon
Wants=lnd.service
After=lnd.service

[Service]
WorkingDirectory=/home/thunderhub/thunderhub
ExecStart=/usr/bin/npm run start -- -p 3010
User=thunderhub
Restart=always
TimeoutSec=120
RestartSec=30
StandardOutput=null
StandardError=journal

[Install]
WantedBy=multi-user.target
EOF

    sudo mv /home/admin/thunderhub.service /etc/systemd/system/thunderhub.service 
    sudo chown root:root /etc/systemd/system/thunderhub.service
    sudo systemctl enable thunderhub
    echo "OK - the ThunderHub service is now enabled"
 
 sudo systemctl start thunderhub
@openoms

This comment has been minimized.

Copy link
Owner Author

@openoms openoms commented May 20, 2020

To remove yarn serving the previous versions:
sudo apt remove yarn

@grnqrtr

This comment has been minimized.

Copy link

@grnqrtr grnqrtr commented May 21, 2020

Hey @openoms, I used your instructions before with no problems, but after the last ThunderHub update, I now get this after npm install:

found 14 vulnerabilities (7 low, 1 moderate, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details

npm audit fix just says that you need to fix issues manually.

@openoms

This comment has been minimized.

Copy link
Owner Author

@openoms openoms commented May 21, 2020

@qrnqrtr that is about the numerous Javascript dependencies managed upstream.
There is nothing actionable on our side.
This is one of the reasons I aim to separate the various applications under their own non-sudo user.

@grnqrtr

This comment has been minimized.

Copy link

@grnqrtr grnqrtr commented May 21, 2020

Okay, thanks. Maybe it was the same before and I didn't notice.

@apotdevin

This comment has been minimized.

Copy link

@apotdevin apotdevin commented May 26, 2020

Updated and removed some dependencies. The npm audit vulnerabilities is now less.

The High and Moderate dependencies as shown below can be safely ignored as shown in this thread: airbnb/babel-plugin-inline-react-svg#59

image

The remaining vulnerabilities should all be Low.

Will try to keep them as reduced as possible, but there's only so much I can do with external dependencies

@openoms

This comment has been minimized.

Copy link
Owner Author

@openoms openoms commented May 26, 2020

Thanks for clarifying this @apotdevin!

@drunkenclam

This comment has been minimized.

Copy link

@drunkenclam drunkenclam commented May 26, 2020

It seems to be working fine for me at first, but when I try to create an invoice I get this (yes, it's setup with Admin Macaroon):

2020-05-25 15:49:45 error [THUB]: Error getting invoice: [
  503,
  'AddInvoiceError',
  {
    err: Error: 2 UNKNOWN: permission denied
        at Object.exports.createStatusError (/home/thunderhub/thunderhub/node_modules/grpc/src/common.js:91:15)
        at Object.onReceiveStatus (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:1209:28)
        at InterceptingListener._callNext (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:568:42)
        at InterceptingListener.onReceiveStatus (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:618:8)
        at callback (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:847:24) {
      [stack]: 'Error: 2 UNKNOWN: permission denied\n' +
        '    at Object.exports.createStatusError (/home/thunderhub/thunderhub/node_modules/grpc/src/common.js:91:15)\n' +
        '    at Object.onReceiveStatus (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:1209:28)\n' +
        '    at InterceptingListener._callNext (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:568:42)\n' +
        '    at InterceptingListener.onReceiveStatus (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:618:8)\n' +
        '    at callback (/home/thunderhub/thunderhub/node_modules/grpc/src/client_interceptors.js:847:24)',
      [message]: '2 UNKNOWN: permission denied',
      code: 2,
      metadata: Metadata { _internal_repr: {}, flags: 0 },
      details: 'permission denied'
    }
  },
  [length]: 3
]
@openoms

This comment has been minimized.

Copy link
Owner Author

@openoms openoms commented May 26, 2020

@drunkenclam can you please open an issue at https://github.com/apotdevin/thunderhub describing your environment?
The developer can try to reproduce and help you there

@drunkenclam

This comment has been minimized.

Copy link

@drunkenclam drunkenclam commented May 26, 2020

@openoms done, thanks

@drunkenclam

This comment has been minimized.

Copy link

@drunkenclam drunkenclam commented May 26, 2020

@openoms is it correct that sometimes port 3001 is used and sometimes 3010?

@openoms

This comment has been minimized.

Copy link
Owner Author

@openoms openoms commented May 26, 2020

thanks fixed, it needs to be consistent. Decided to use 3010 as it will be in RaspiBlitz.

@Jestopher-BTC

This comment has been minimized.

Copy link

@Jestopher-BTC Jestopher-BTC commented May 28, 2020

When I dump the Systemd Unit into the command line, I get an error at the "fi" line.

@openoms

This comment has been minimized.

Copy link
Owner Author

@openoms openoms commented May 28, 2020

@Jestopher-BTC sure, removed that

@hermanlim

This comment has been minimized.

Copy link

@hermanlim hermanlim commented Jul 25, 2020

Hi, can anyone confirm whether the 'Chats' is working on Raspiblitz 1.6 RC3 with Thunder Hub fully updated? I keep getting a "Cannot read property 'messages' of undefined" error.

@grnqrtr

This comment has been minimized.

Copy link

@grnqrtr grnqrtr commented Jul 25, 2020

@hermanlim Yes, I just checked, seems to be working fine for me on Raspiblitz 1.6 RC3 with ThunderHub fully updated.

@apotdevin

This comment has been minimized.

Copy link

@apotdevin apotdevin commented Jul 25, 2020

Hey @ hermanlim, when are you getting this error?

@hermanlim

This comment has been minimized.

Copy link

@hermanlim hermanlim commented Jul 25, 2020

@apotdevin, I'm getting it everytime I click on the chat bubble, on the top right of the screen.
This has never worked properly, although the rest of the app works well and without issue.

@grnqrtr, thanks for checking.

Screenshot_20200725_204614

@apotdevin

This comment has been minimized.

Copy link

@apotdevin apotdevin commented Jul 26, 2020

@hermanlim thanks! Will look into it

@Jestopher-BTC

This comment has been minimized.

Copy link

@Jestopher-BTC Jestopher-BTC commented Aug 13, 2020

After trying the automated scripts, I attempted the manual install on my raspi 3B+. It appears to be maxing out the memory. Any suggestions?

thunderhub@raspberrypi:~/thunderhub $ npm run build

thunderhub@0.9.3 build /home/thunderhub/thunderhub
next build

info - Loaded env from /home/thunderhub/thunderhub/.env
info - Using external babel configuration from /home/thunderhub/thunderhub/.babelrc
Creating an optimized production build .
<--- Last few GCs --->

[25147:0x28e49d8] 250310 ms: Scavenge 228.7 (231.6) -> 228.3 (231.8) MB, 5.3 / 0.0 ms (average mu = 0.187, current mu = 0.027) allocation failure
[25147:0x28e49d8] 251037 ms: Mark-sweep 228.7 (232.1) -> 227.5 (231.6) MB, 691.9 / 0.1 ms (average mu = 0.359, current mu = 0.525) allocation failure scavenge might not succeed
[25147:0x28e49d8] 251066 ms: Scavenge 227.9 (231.6) -> 227.5 (231.6) MB, 7.7 / 0.0 ms (average mu = 0.359, current mu = 0.525) allocation failure

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0xe1edbc]

Security context: 0x5514e3ad
1: toString [0x29a08d41] [buffer.js:~771] [pc=0x5d0a0b14](this=0x4e585f51 ,0x23540279 ,0x23540279 ,0x23540279 )
2: arguments adaptor frame: 0->3
3: InternalFrame [pc: 0xe1ae54]
4: EntryFrame [pc: 0xe1ab54]
5: builtin exit frame: parse(this=0x55145f35 ,0x4e585f51 ...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Aborted
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! thunderhub@0.9.3 build: next build
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the thunderhub@0.9.3 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/thunderhub/.npm/_logs/2020-08-13T17_17_27_738Z-debug.log

Log output:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/lib/nodejs/node-v12.16.3-linux-armv7l/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.16.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle thunderhub@0.9.3prebuild: thunderhub@0.9.3
6 info lifecycle thunderhub@0.9.3
build: thunderhub@0.9.3
7 verbose lifecycle thunderhub@0.9.3build: unsafe-perm in lifecycle true
8 verbose lifecycle thunderhub@0.9.3
build: PATH: /usr/local/lib/nodejs/node-v12.16.3-linux-armv7l/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/thunderhub/thunderhub/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/sbin:/usr/local/lib/nodejs/node--/bin/
9 verbose lifecycle thunderhub@0.9.3build: CWD: /home/thunderhub/thunderhub
10 silly lifecycle thunderhub@0.9.3
build: Args: [ '-c', 'next build' ]
11 silly lifecycle thunderhub@0.9.3build: Returned: code: 134 signal: null
12 info lifecycle thunderhub@0.9.3
build: Failed to exec build script
13 verbose stack Error: thunderhub@0.9.3 build: next build
13 verbose stack Exit status 134
13 verbose stack at EventEmitter. (/usr/local/lib/nodejs/node-v12.16.3-linux-armv7l/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:310:20)
13 verbose stack at ChildProcess. (/usr/local/lib/nodejs/node-v12.16.3-linux-armv7l/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:310:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid thunderhub@0.9.3
15 verbose cwd /home/thunderhub/thunderhub
16 verbose Linux 4.19.118-v7+
17 verbose argv "/usr/local/lib/nodejs/node-v12.16.3-linux-armv7l/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v12.16.3
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 134
22 error thunderhub@0.9.3 build: next build
22 error Exit status 134
23 error Failed at the thunderhub@0.9.3 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 134, true ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.