BlueWallet / LndHub

Wrapper for Lightning Network Daemon. It provides separate accounts for end-users
http://LndHub.io
MIT License
786 stars 198 forks source link

Install issue #17

Closed bruceleeroy18 closed 3 years ago

bruceleeroy18 commented 5 years ago

Hey, trying to setup my own instance of LndHub. Not sure why the it denies access. Any suggestions?

$ git clone git@github.com:BlueWallet/LndHub.git

The authenticity of host 'github.com (192.30.253.113)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.


Linux 18.04 Ubuntu Mate

iamjackharper commented 5 years ago

You can just use, it works for me $ git clone https://github.com/BlueWallet/LndHub

alerobrod commented 5 years ago

Hi. Try this command:

ssh -vT git@github.com

Most likely you need to have a user in git and define your host's public key before you can connect. See following link on subject: https://help.github.com/articles/error-permission-denied-publickey/

Good luck!

bruceleeroy18 commented 5 years ago

You can just use, it works for me $ git clone https://github.com/BlueWallet/LndHub

Thanks, that's all I had to do. I wasn't sure about the notation I tried at first. I thought I would ask before trying a bunch of different things.

bruceleeroy18 commented 5 years ago

anyone able to help with these steps? "Edit config.js and set it up correctly. Copy admin.macaroon and tls.cert in root folder of LndHub." I would really like to connect to the LND node I already have running, but am a novice at these projects.

Is there a slack group for BlueWallet or LndHub?

alerobrod commented 5 years ago

I am new to this as well; just installed LndHub a couple of weeks ago. Concerning the config.js see below mine; not much had to be changed from the existing template:

fs = require('fs');
let l_data = fs.readFileSync('/home/bitcoin/.bitcoin/.cookie', 'utf8');
let config = {
  bitcoind: {
    rpc: `http://${l_data}@localhost:8332/`,
  },
  redis: {
    port: 6379,
    host: '127.0.0.1',
    family: 4,
    db: 0,
  },
  lnd: {
    url: '192.168.178.81:10009',
    password: '<password>',
  },
};

if (process.env.CONFIG) {
  console.log('using config from env');
  config = JSON.parse(process.env.CONFIG);
}

module.exports = config;

The first part is just to automate pulling the bitcoind RPC User/Password since I have not (yet) set one up (hence reading up the autogenerated when bitcoind starts up). If you have username/password pair just add it instead.

Apart from that Redis I did nothing at all. As for lnd only to set the host:port settings that applied for RPC and the wallet password to unlock it.

.. and last but not least, just copied as mentioned by the README instructions the tls.cert and admin.macaroon files from lnd's directories below (below my location but perhaps yours are different depending on how you installed lnd) into LndHub home directory:

/home/bitcoin/.lnd/tls.cer
/home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
bruceleeroy18 commented 5 years ago

Thanks so much. I will give all this another go tomorrow morning. If I get stumped along the way I will let you know. Thanks again.

Sent from ProtonMail mobile

-------- Original Message -------- On Feb 14, 2019, 12:50, alerobrod wrote:

I am new to this as well; just installed LndHub a couple of weeks ago. Concerning the config.js see below mine; not much had to be changed from the existing template:

fs = require('fs'); let l_data = fs.readFileSync('/home/bitcoin/.bitcoin/.cookie', 'utf8'); let config = { bitcoind: { rpc: http://${l_data}@localhost:8332/, }, redis: { port: 6379, host: '127.0.0.1', family: 4, db: 0, }, lnd: { url: '192.168.178.81:10009', password: 'Pralat0!', }, };

if (process.env.CONFIG) { console.log('using config from env'); config = JSON.parse(process.env.CONFIG); }

module.exports = config;

The first part is just to automate pulling the bitcoind RPC User/Password since I have not (yet) set one up (hence reading up the autogenerated when bitcoind starts up). If you have username/password pair just add it instead.

Apart from that Redis I did nothing at all. As for lnd only to set the host:port settings that applied for RPC and the wallet password to unlock it.

.. and last but not least, just copied as mentioned by the README instructions the tls.cert and admin.macaroon files from lnd's directories below (below my location but perhaps yours are different depending on how you installed lnd) into LndHub home directory:

/home/bitcoin/.lnd/tls.cer /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

Overtorment commented 5 years ago

@alerobrod would be nice if you could write a blogpost on how to install that thing!

bruceleeroy18 commented 5 years ago

I am new to this as well; just installed LndHub a couple of weeks ago. Concerning the config.js see below mine; not much had to be changed from the existing template:

fs = require('fs');
let l_data = fs.readFileSync('/home/bitcoin/.bitcoin/.cookie', 'utf8');
let config = {
  bitcoind: {
    rpc: `http://${l_data}@localhost:8332/`,
  },
  redis: {
    port: 6379,
    host: '127.0.0.1',
    family: 4,
    db: 0,
  },
  lnd: {
    url: '192.168.178.81:10009',
    password: '<password>',
  },
};

if (process.env.CONFIG) {
  console.log('using config from env');
  config = JSON.parse(process.env.CONFIG);
}

module.exports = config;

The first part is just to automate pulling the bitcoind RPC User/Password since I have not (yet) set one up (hence reading up the autogenerated when bitcoind starts up). If you have username/password pair just add it instead.

Apart from that Redis I did nothing at all. As for lnd only to set the host:port settings that applied for RPC and the wallet password to unlock it.

.. and last but not least, just copied as mentioned by the README instructions the tls.cert and admin.macaroon files from lnd's directories below (below my location but perhaps yours are different depending on how you installed lnd) into LndHub home directory:

/home/bitcoin/.lnd/tls.cer
/home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon

Thanks, I have followed your directions to the best of my ability. Now what? Not sure if I can connect LndHub to BlueWallet. Not sure if I need to run a command to run LndHub, or just find the URL to put into BlueWallet.

alerobrod commented 5 years ago

Well, you first need to start LndHub. To do so as a starting point (I have now added it as a service) and make sure all is good, simply run (from LndHub's home directory, by executing index.js file):

Note: I had an issue related to import statements in the code and had to add a wrapper to call index.js instead. If needed will share.

node index

If all is well, you'll see some output on the terminal and ultimately a message stating the port on which is listening on (default tcp 3000).

Now, to connect from BlueWallet, you would go into settings (top-right corner on main screen, shown as ...), and chose the Lightning Settings. Here you would enter the URI as:

http://<your-node's public IP address>:<LndHub's port e.g. 3000>

Note2: Here I assume your router and local firewall (where applicable) allow incoming tcp connections to this port

If you look at the terminal on which you started LndHub you should be able to see requests coming in, starting from the moment when you create a Lightning Wallet (here is where a user is created in LndHub and stored in Redis, etc.).

Not sure what else to mention, knowing little about how you have set things up. Give it another go and write here if and where you get stuck next.

Note3: @Overtorment I shall follow your advice and write something up (generic, as one size will not fit all, but at least the common themes should be covered).

bruceleeroy18 commented 5 years ago

Here is output after ~/LndHub $ node index

"/home/browning/LndHub/controllers/api.js:1 (function (exports, require, module, filename, dirname) { import { User, Lock } from '../class/'; ^^^^^^

SyntaxError: Unexpected token import at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:616:28) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (/home/browning/LndHub/index.js:38:9) Node NOT Exiting..."

Here is my config.js (minus my password.) let config = { bitcoind: { rpc: 'http://browning:****@192.168.2.1:8332', }, redis: { port: 12914, host: '127.0.0.1', family: 4, password: 'password', db: 0, }, lnd: { url: '192.168.2.1:10009', password: '****', }, };

if (process.env.CONFIG) { console.log('using config from env'); config = JSON.parse(process.env.CONFIG); }

module.exports = config;

alerobrod commented 5 years ago

It seems you had the same issue I did (refer to note in previous comment). To try and move past this issue, create a new file called e.g. start.js and place it under LndHub's home directory with following contents:

// Transpile all code following this line with babel and use 'env' (aka ES6) preset.
require('babel-register')({
  "presets": [
    ["env", {
      "targets": {
        "node": "current"
      }
    }]
  ]
})

// Import the rest of our application.
module.exports = require('./index.js')

Now instead of starting LndHub as previously mentioned, do as follows instead:

node start

Note: This requires you install babel as follows (if I recall correctly):

npm install babel-register babel-preset-env --save-dev
npm install babel-polyfill

Hope that resolves it and you can finally test BlueWallet with it; I am using it and even showed it around to non-techies, non-crypto-hobbyists to e.g. top up a prepaid phone and were stunned to say the least! Hang on and do not give up!

iamjackharper commented 5 years ago

Instead of "node index" try with "npm start" . I also planned to write a guide to go from zero to LndHub working on own and node with Bluewallet attached, so maybe will be easier for newcomers to install it. Will be ready in some days

alerobrod commented 5 years ago

@iamjackharper it seems I manage to overdo it, hehe ... thanks for the tip. And as for the install guide, good idea, saves everybody from unnecessary workarounds ;-)

bruceleeroy18 commented 5 years ago

Hey, I'm not giving up when I'm getting all this help. BlueWallet works great as custodial wallet and is super smooth. I have a couple friends who are also impressed with how easy it is.

There was some progress! $ node start using config {"bitcoind":{"rpc":"http://browning:****@192.168.2.1:8332"},"redis":{"port":12914,"host":"127.0.0.1","family":4,"password":"password","db":0},"lnd":{"url":"192.168.2.1:10009","password":"****"}} using tls.cert 2d….

trying to unlock the wallet updateLightning() updated (node:25252) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead 2019-02-15T16:53:38.201Z 'BOOTING UP' 'Listening on port 3000' bitcoind failure

bruceleeroy18 commented 5 years ago

Maybe I don't have the -deprecatedrpc=accounts pushed to bitcoind?

MrHash commented 5 years ago

need without the hyphen if set in your bitcoin.conf file

bruceleeroy18 commented 5 years ago

nah, i didn't place it in conf file. I will try that now though and see if it does the trick.

bruceleeroy18 commented 5 years ago

nah, i didn't place it in conf file. I will try that now though and see if it does the trick.

Nope, it had the same results with deprecatedrpc=accounts in the bitcoin.conf

MrHash commented 5 years ago

if lndhub is running on the same machine as bitcoind you can use 127.0.0.1, otherwise it may not be bound to other interfaces

alerobrod commented 5 years ago

@bruceleeroy18 , good it's moving forward! Can you check bitcoind is actually listening on the interface (IP address) and tcp port you provided to LndHub's config.js file? Also make sure the credentials are the correct ones (those provided, if indeed you did so, in bitcoin.conf file for the RPC interface).

If this does not do it we'll have to think harder...

bruceleeroy18 commented 5 years ago

Instead of "node index" try with "npm start" . I also planned to write a guide to go from zero to LndHub working on own and node with Bluewallet attached, so maybe will be easier for newcomers to install it. Will be ready in some days

Just to be thorough.

$ npm start trying to unlock the wallet updateLightning() updated (node:26016) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead 2019-02-15T17:06:49.127Z 'BOOTING UP' 'Listening on port 3000' bitcoind failure

npm ERR! Linux 4.15.0-45-generic npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start" npm ERR! node v8.10.0 npm ERR! npm v3.5.2 npm ERR! code ELIFECYCLE npm ERR! LndHub@1.1.1 start: babel-node index.js npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the LndHub@1.1.1 start script 'babel-node index.js'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the LndHub package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! babel-node index.js npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs LndHub npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls LndHub npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /home/browning/LndHub/npm-debug.log

bruceleeroy18 commented 5 years ago

@bruceleeroy18 , good it's moving forward! Can you check bitcoind is actually listening on the interface (IP address) and tcp port you provided to LndHub's config.js file? Also make sure the credentials are the correct ones (those provided, if indeed you did so, in bitcoin.conf file for the RPC interface).

If this does not do it we'll have to think harder...

(Not sure of the best way to check)

$ netstat -antlp | grep 8332

tcp 0 0 127.0.0.1:28332 0.0.0.0: LISTEN 25784/bitcoind
tcp 0 0 127.0.0.1:8332 0.0.0.0:
LISTEN 25784/bitcoind.....

Here is my bitcoin.conf server=1 txindex=1 daemon=1 externalip=192.168.2.1 maxconnections=18 rpcuser=browning rpcpassword=**** zmqpubrawblock=tcp://127.0.0.1:28332 zmqpubrawtx=tcp://127.0.0.1:28333

deprecatedrpc=accounts

I have to go into work. I will revisit this after 7pm Eastern time.

MrHash commented 5 years ago

rpc is not bound to 192.168.2.1 like this. Use rpcallowip setting but be aware of exposing rpc to network, otherwise externalip isn't needed so i'd try without that and run lndhub on the same machine as the node and point it to 127.0.0.1

alerobrod commented 5 years ago

If you checked that bitcoind configuration on LndHub's config is accurate (check with e.g. netstat to be sure is not listening on e.g. localhost, etc.) then I would suggest to place a small debug line in .controllers/api.js file as follows:

...
// ###################### SMOKE TESTS ########################

bitcoinclient.request('getblockchaininfo', false, function(err, info) {
  if (info && info.result && info.result.blocks) {
    if (info.result.blocks < 550000) {
      console.error('bitcoind is not caught up');
      process.exit(1);
    }
  } else {
    console.error('bitcoind failure:');  # <-- This is the line you see on the terminal.
    console.error(err);                         # <-- This is the added line to read the message.
    process.exit(2);
  }
});
...

Also having a bitcoind debug file being tail'ed could help in case LndHub is reaching it.

alerobrod commented 5 years ago

rpc is not bound to 192.168.2.1 like this. Use rpcallowip setting but be aware of exposing rpc to network, otherwise externalip isn't needed so i'd try without that and run lndhub on the same machine as the node and point it to 127.0.0.1

Indeed. @bruceleeroy18, if you just want to test if this resolves it all, change LndHub's config to use localhost or 127.0.0.1 instead of the 192.168.2.1 address. The debug line may come in handy if error persists (I had issues too on this area and this helped in here).

bruceleeroy18 commented 5 years ago

Hey, had time to pass localhost, then 127.0.0.1, to config.js. Here is the result. (I will try the debug line tonight.)

trying to unlock the wallet updateLightning() updated (node:27874) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead 2019-02-15T17:45:58.479Z 'BOOTING UP' 'Listening on port 3000' [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:12914 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:12914 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14) lnd failure: { Error: 14 UNAVAILABLE: Connect Failed at Object.exports.createStatusError (/home/browning/LndHub/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:1204:28) at InterceptingListener._callNext (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:618:8) at callback (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:845:24) code: 14, metadata: Metadata { _internal_repr: {} }, details: 'Connect Failed' } lnd failure: { Error: 14 UNAVAILABLE: Connect Failed at Object.exports.createStatusError (/home/browning/LndHub/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:1204:28) at InterceptingListener._callNext (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:618:8) at callback (/home/browning/LndHub/node_modules/grpc/src/client_interceptors.js:845:24) code: 14, metadata: Metadata { _internal_repr: {} }, details: 'Connect Failed' } lnd failure

MrHash commented 5 years ago

ok redis is on the wrong port, either reconfigure redis on port 12914 or set your config port to 6379

bruceleeroy18 commented 5 years ago

ok redis is on the wrong port, either reconfigure redis on port 12914 or set your config port to 6379

It was set to 12914, now it is on 6379. Still showing same error as above.

MrHash commented 5 years ago

sure you got redis running? this might help https://github.com/dangeross/guides/blob/master/raspibolt/raspibolt_6B_lndhub.md

bruceleeroy18 commented 5 years ago

If you checked that bitcoind configuration on LndHub's config is accurate (check with e.g. netstat to be sure is not listening on e.g. localhost, etc.) then I would suggest to place a small debug line in .controllers/api.js file as follows:

...
// ###################### SMOKE TESTS ########################

bitcoinclient.request('getblockchaininfo', false, function(err, info) {
  if (info && info.result && info.result.blocks) {
    if (info.result.blocks < 550000) {
      console.error('bitcoind is not caught up');
      process.exit(1);
    }
  } else {
    console.error('bitcoind failure:');  # <-- This is the line you see on the terminal.
    console.error(err);                         # <-- This is the added line to read the message.
    process.exit(2);
  }
});
...

Also having a bitcoind debug file being tail'ed could help in case LndHub is reaching it.

Do I just copy and append that code to the end of the api.js document inside the controller directory?

Note: I don't see a .controllers/api.js. I do have a .babelrc, .eslintrc, .gitignore.

bruceleeroy18 commented 5 years ago

@MrHash I will reinstall with these directions and see what happens.

alerobrod commented 5 years ago

Do I just copy and append that code to the end of the api.js document inside the controller directory?

Note: I don't see a .controllers/api.js. I do have a .babelrc, .eslintrc, .gitignore.

This does not apply anymore, it was to resolve the first error (connecting to bitcoind; the file meant was ./controllers/api.js though).

Note: Me to install redis I only did sudo apt-get install redis-server for my Raspbian system and it all worked impeccable.

Overtorment commented 5 years ago

Oh hey guys, sorry I was away for some time. Glad you figured all out! Big thanks to people who wrote their guides on how to install Lndhub. I'll link those in README.

https://github.com/dangeross/guides/blob/master/raspibolt/raspibolt_6B_lndhub.md https://medium.com/@jpthor/running-lndhub-on-mac-osx-5be6671b2e0c

bruceleeroy18 commented 5 years ago

@MrHash Hey, so it seems redis was not installed properly. When I try to reinstall it does not work.

make test returns one error: !!! WARNING The following tests failed:

[err]: slave buffer are counted correctly in tests/unit/maxmemory.tcl Expected condition '$slave_buf > 210241024' to be true (0 > 210241024) Cleanup: may take some time... OK Makefile:262: recipe for target 'test' failed make[1]: [test] Error 1 make[1]: Leaving directory '/home/browning/redis-5.0.3/src' Makefile:6: recipe for target 'test' failed make: *** [test] Error 2

Also I am running into a problem/confusion at the step " sudo mkdir /mnt/hdd/redis". I get the following error: mkdir: cannot create directory ‘/mnt/hdd/redis’: No such file or directory

Lastly, I skipped logging in as admin because I don't have that directory.

MrHash commented 5 years ago

depending on the OS you might be able to just run sudo apt-get install redis-server and move on to the next step

iamjackharper commented 5 years ago

Oh hey guys, sorry I was away for some time. Glad you figured all out! Big thanks to people who wrote their guides on how to install Lndhub. I'll link those in README.

https://github.com/dangeross/guides/blob/master/raspibolt/raspibolt_6B_lndhub.md https://medium.com/@jpthor/running-lndhub-on-mac-osx-5be6671b2e0c

I made mine for VPS nodes, if can be useful some way https://bitcoinmirror.ghost.io/how-to-install-bitcoin-lightning-and-lndhub-on-your-own-vps/

ghost commented 5 years ago

Hey guys, wanted to see if anyone had an idea of why i was getting this error?

Through the log, looks like everything is pulling in then when this error cycles through redis stops.

THanks. screen shot 2019-02-18 at 8 24 04 am

MrHash commented 5 years ago

Your redis server maybe on a different port or password protected. check configs

ghost commented 5 years ago

Thanks for the response! It was actually me not having redis-server started. Got everythng working and can see everything up on the computer.

What i am not able to get working is the app. I have my IP that pulls up on computer on there but just shows me the hosted wallet i had on there. Anything special i need to do?

ghost commented 5 years ago

So what i have noticed and tested is the app is linked, did a 10 sat test from a buddy and went to my node well. But it does not show my my node balance, so i can only send the 10 sat i requested, cant use what i actually have on the node. Is that normal?

iamjackharper commented 5 years ago

Yes that is normal cause LndHub allows you to have different accounts on the same node, and every account has access only to his funds.