djbooth007 / tallycoin_connect

Install on bitcoin node for retrieval of payment information by Tallycoin
GNU General Public License v3.0
32 stars 6 forks source link

SyntaxError on Umbrel node: Unexpected token u in JSON at position 0 #14

Closed quillie closed 2 years ago

quillie commented 3 years ago

Hi,

I was trying to set up tallycoin_connect on my umbrel node using Docker. I ran into the following issue:

umbrel@umbrel:~/tallycoin_connect $ docker run -ti -p 8123:8123 tallycoin_connect

> tallycoin_connect@1.0.0 start
> node tallycoin_connect.js

Starting websocket
Running on http://localhost:8123
undefined:1
undefined
^

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at ReadFileContext.callback (/opt/tallycoin_connect/tallycoin_connect.js:15:17)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:281:13)

Any idea where I'm going wrong?

br, Q

quillie commented 3 years ago

Okay. I realized the missing "tallycoin_api.key" file was causing that error.

Setup.py educates us how that file should be constructed:

json =  '{ "tallycoin_api":"'+key+'", "tls_cert":"'+cert+'", "macaroon":"'+macaroon+'", "lnd_socket":"127.0.0.1:10009" }';

On umbrel, tls_cert and macaroon can be found at:

stream = os.popen("base64 /home/umbrel/umbrel/lnd/tls.cert | tr -d '\n'");
cert = stream.read();

stream = os.popen("base64 /home/umbrel/umbrel/lnd/data/chain/bitcoin/mainnet/admin.macaroon | tr -d '\n'");
macaroon = stream.read();

So, I created that file by myself. Thanks to that file, the Docker container can be started (also removed the key file from dockerignore).

Here is where it gets weird. Though the Tallycoin Admin Dashboard (on tallycoin.in) says that my node is connected, my umbrel node gives me an error:

Screenshot 2021-10-04 at 23 41 03
quillie commented 3 years ago

When I tried to send a payment via Lightning (using the fundraiser interface on tallycoin.in), my node crashed:

/opt/tallycoin_connect/tallycoin_connect.js:201
        id: invoice['id'],
                   ^

TypeError: Cannot read property 'id' of undefined
    at /opt/tallycoin_connect/tallycoin_connect.js:201:20
    at /opt/tallycoin_connect/node_modules/asyncjs-util/return_result.js:22:40
    at wrapper (/opt/tallycoin_connect/node_modules/async/internal/once.js:12:16)
    at /opt/tallycoin_connect/node_modules/async/auto.js:283:17
    at /opt/tallycoin_connect/node_modules/async/internal/onlyOnce.js:12:16
    at Object.callback (/opt/tallycoin_connect/node_modules/lightning/lnd_methods/invoices/create_invoice.js:148:20)
    at Object.onReceiveStatus (/opt/tallycoin_connect/node_modules/@grpc/grpc-js/build/src/client.js:179:36)
    at Object.onReceiveStatus (/opt/tallycoin_connect/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
    at Object.onReceiveStatus (/opt/tallycoin_connect/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
    at /opt/tallycoin_connect/node_modules/@grpc/grpc-js/build/src/call-stream.js:145:78

Hope this will be useful for you at some point. Thanks for this awesome project!

djbooth007 commented 3 years ago

Here is where it gets weird. Though the Tallycoin Admin Dashboard (on tallycoin.in) says that my node is connected, my umbrel node gives me an error:

Screenshot 2021-10-04 at 23 41 03

I'm guessing Tallycoin Connect can establish a websocket connection to the Tallycoin server, so the website indicates a successful connection.

However, Tallycoin Connect on your node probably isn't hooked up to LND correctly, so invoices can't be created.

If you're able to solve the issue and package Tallycoin Connect as an Umbrel app, there is a bounty available. See https://tallyco.in/s/0988uq/

quillie commented 3 years ago

I see. Thanks for the feedback. I will try to fix it and share my findings.

dennisreimann commented 2 years ago

This can also be closed now :)