elementsproject / lightning-charge Goto Github PK
View Code? Open in Web Editor NEWA simple drop-in solution for accepting lightning payments
License: MIT License
A simple drop-in solution for accepting lightning payments
License: MIT License
Like the title describes this path still uses the default timeout of Express which is set to 120 seconds.
Since Express is build on top of the built-in Node.js HTTP server, check this out:
https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_server_timeout
So if you tell the /invoice/wait
call to timeout after 600 seconds it still gives you a empty reply after 120 seconds have passed. After that any lightning-charged-client wont understand this http code and will just throw an exception.
How to reproduce:
After 120 seconds will result in:
curl: (52) Empty reply from server
The RPC port needs to be expose in order to create channels.
Just changed the readme for future references in PR #56
So that the e-commerce orders server doesn't miss notifications due to downtime.
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone -q git://github.com/shesek/lightning-client-js.git /home/parmax/.npm/_cacache/tmp/git-clone-b5410c31
npm ERR! /home/parmax/.npm/_cacache/tmp/git-clone-b5410c31/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/parmax/.npm/_logs/2018-02-02T17_00_55_324Z-debug.log
Hey there, thanks for releasing this!
In the README it says the docker image contains bitcoind, c-lightning and charged -- I am getting quite a few lightning-rpc errors though?
Here's my docker-compose.yml
:
version: '2'
services:
charge:
image: shesek/lightning-charge
volumes:
- ~/.lightning:/root.lightning
- ~/.bitcoin:/root/.bitcoin
- ~/.charged/charge.db:/opt/charged/sqlite.db
environment:
- API_TOKEN=tacquitos
ports:
- 9112:9112
And here's the output I'm getting when trying to make an invoice:
charge_1 | 2018-01-17T05:31:58.274Z lightning-client #1 --> invoice ["10000","NFOcWboDN0Z~KxMQezbbh","Lightning Charge Invoice",null]
charge_1 | Lightning client connection error Error: This socket is closed
charge_1 | at Socket._writeGeneric (net.js:726:18)
charge_1 | at Socket._write (net.js:786:8)
charge_1 | at doWrite (_stream_writable.js:387:12)
charge_1 | at writeOrBuffer (_stream_writable.js:373:5)
charge_1 | at Socket.Writable.write (_stream_writable.js:290:11)
charge_1 | at Socket.write (net.js:704:40)
charge_1 | at Promise (/opt/charged/node_modules/lightning-client/index.js:149:30)
charge_1 | at new Promise (<anonymous>)
charge_1 | at clientConnectionPromise.then (/opt/charged/node_modules/lightning-client/index.js:137:25)
charge_1 | at <anonymous>
charge_1 | at process._tickCallback (internal/process/next_tick.js:188:7)
charge_1 | 2018-01-17T05:32:11.173Z lightning-client Trying to reconnect...
charge_1 | Lightning client connection error { Error: connect ECONNREFUSED /root/.lightning/lightning-rpc
charge_1 | at Object._errnoException (util.js:1022:11)
charge_1 | at _exceptionWithHostPort (util.js:1044:20)
charge_1 | at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
charge_1 | code: 'ECONNREFUSED',
charge_1 | errno: 'ECONNREFUSED',
charge_1 | syscall: 'connect',
charge_1 | address: '/root/.lightning/lightning-rpc' }
charge_1 | 2018-01-17T05:32:11.179Z lightning-client Trying to reconnect...
charge_1 | Lightning client connection error { Error: connect ECONNREFUSED /root/.lightning/lightning-rpc
charge_1 | at Object._errnoException (util.js:1022:11)
charge_1 | at _exceptionWithHostPort (util.js:1044:20)
charge_1 | at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
charge_1 | code: 'ECONNREFUSED',
charge_1 | errno: 'ECONNREFUSED',
charge_1 | syscall: 'connect',
charge_1 | address: '/root/.lightning/lightning-rpc' }
Thanks again for all the hard work, so excited to use this!
EDIT:
If it helps, I can successfully ping the server normally to check for invoices, and get an empty list back:
$ curl -u api-token:tacquitos http://hotness:9112/invoices
[]
Just a noobs question: I have a RaspiBlitz running. Can i implement this on my RaspiBlitz?
https://github.com/rootzoll/raspiblitz
Even though in #20 I was obviously not having the rights to listen to the correct port the problem is still valid:
as u can see after starting chared I was able to handle an incoming request and then when a new http request came in GET http://clientapi.ipip.net/echo.php?info=20180128151721
(which some person directed to mu IP adress on my open port 9112) the server crashed... this should not happen
rpickhardt@ip-172-31-5-23:~/lightning-charge$ ./bin/charged -i 0.0.0.0 --port 9112 HTTP server running on 0.0.0.0:9112
POST /invoice 201 3737.292 ms - 631
GET /invoice/9f1eJsPicXnHdhdtKlTL3 200 2.643 ms - 668
GET /invoice/9f1eJsPicXnHdhdtKlTL3/wait?timeout=24 402 24175.133 ms - 16
GET /invoice/9f1eJsPicXnHdhdtKlTL3 200 1.446 ms - 668
GET /invoice/9f1eJsPicXnHdhdtKlTL3/wait?timeout=24 402 24021.948 ms - 16
GET /invoice/9f1eJsPicXnHdhdtKlTL3/wait?timeout=24 402 24007.696 ms - 16
GET /invoice/9f1eJsPicXnHdhdtKlTL3/wait?timeout=24 402 24014.377 ms - 16
GET /invoice/9f1eJsPicXnHdhdtKlTL3/wait?timeout=24 402 24020.857 ms - 16
GET http://clientapi.ipip.net/echo.php?info=20180128151721 404 27.217 ms - 147
Error: Database error
at LightningClient.once.response (/export/home/rpickhardt/lightning-
charge/node_modules/lightning-client/index.js:145:28)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at LightningClient.emit (events.js:211:7)
at _.each.str (/export/home/rpickhardt/lightning-charge/node_modules/lightning-
client/index.js:61:23)
at arrayEach (/export/home/rpickhardt/lightning-charge/node_modules/lodash/lodash.js:537:11)
at Function.forEach (/export/home/rpickhardt/lightning-
charge/node_modules/lodash/lodash.js:9359:14)
at Socket.LightningClient.client.on.data (/export/home/rpickhardt/lightning-
charge/node_modules/lightning-client/index.js:52:15)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
/export/home/rpickhardt/lightning-charge/src/app.js:14
throw err;
^
Error: Database error
at LightningClient.once.response (/export/home/rpickhardt/lightning-
charge/node_modules/lightning-client/index.js:145:28)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at LightningClient.emit (events.js:211:7)
at _.each.str (/export/home/rpickhardt/lightning-charge/node_modules/lightning-
client/index.js:61:23)
at arrayEach (/export/home/rpickhardt/lightning-charge/node_modules/lodash/lodash.js:537:11)
at Function.forEach (/export/home/rpickhardt/lightning-
charge/node_modules/lodash/lodash.js:9359:14)
at Socket.LightningClient.client.on.data (/export/home/rpickhardt/lightning-
charge/node_modules/lightning-client/index.js:52:15)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
actually the bash tells me c-lightning crashed and therefor probably charge could not connect via cli. I open another bug in the c-lightning repo
Do you have any plans to release this to run on ARM processors? If not do you have any suggestions on how to change it to run on ARM?
charged --api-token password
Knex: run
$ npm install sqlite3 --save
Error: Cannot find module '/home/pi/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v51-linux-arm/node_sqlite3.node'
and the followings always errors
npm install sqlite3 --save
Any idea?
hello there ,
please make auto deploy button to heroku.com for easy build gear
thanks & fine regards
POST /invoice
can accept a webhook
parameter directly, rather than adding it via POST /invoice/:inv/webhook
. The tests and docs should be updated to reflect this.
I know I'm skating on thin ice and risk breaking some eggshells ๐, but in the spirit of interoperability and friendly cooperation:
using ubuntu 16.04 LTS, intel core i7-3770
$charged --api-token ??????? # defaults: --ln-path ~/.lightning --db-path ./charge.db --port 9112 --host 192.168.1.5
results in...
HTTP server running on localhost:9112
No GET /invoice/blaaa messages are being generated when I try to connect to http://192.168.1.5:9112/invoice/blaaa , I just get "connection refused".
I tried setting the ip and host on both lightningd (using --ipaddr) and charged, with no change.
I disabled firewall (ufw). no change.
If I connect to
http://127.0.0.1:9112/invoice/blaaa.
then everything works as expected.
so as far as I can tell, changing hosts from localhost, does nothing, and trying to connect to the server from any other interface other than localhost is refused.
The charge's docker is messed up if I use a separate lightningd.
if [ -S /etc/lightning/lightning-rpc ]; then
problem is: When the dependent lightningd start the socket is not yet created
So charge fire its own lightningd instance...
I think you should keep SKIP_BITCOIND and SKIP_LIGHTNINGD and wait for the file to be created.
First I tried setting up your docker image and tried connecting to my remote bitcoind instance.
The error said: error parsing command line arguments: invalid argument -bitcoin.
After examining this line https://github.com/ElementsProject/lightning-charge/blob/master/bin/docker-entrypoint.sh#L52 , I removed -$NETWORK flag, build the docker image again and then everything seemed to work.
Allow specifying invoice amounts in other currencies and convert to bitcoins. The invoice should lock-in the exchange rate for some pre-determined time, then expire.
Command : sudo npm install -g lightning-charge
Hardware: raspberry pi 3
OS: Raspbian
Error
$ sudo npm install -g lightning-charge
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone -q git://github.com/shesek/lightning-client-js.git /root/.npm/_cacache/tmp/git-clone-42cb7618
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-42cb7618': Permission denied
npm ERR!
Im possibly doing something stupid here. Any insights?
Hi,
I was setting up lightning-charge to integrate with the WordPress Plugin. I had some difficulties with installation in my environment so I thought this might useful to other devs. Please let me know if this would be better closed.
Environment
Installation
Nodejs 7 and 10 were not compatible with lightning-charge, had to install nodejs8
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash
$ apt-get install nodejs
Errors running npm install lightning-charge, had to include the following flags
$ npm install --unsafe-perm --verbose -g lightning-charge
Sqlite3 dependency weren't found in the node_modules, had to run npm rebuild
$ cd /usr/lib/node_modules/lightning-charge
$ npm rebuild
After the above steps everything worked well following the steps in the README to run the server.
Running charged gives me this error:
Knex: run
$ npm install sqlite3 --save
Error: Cannot find module '/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v57-linux-x64/node_sqlite3.node'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Client_SQLite3._driver (/usr/local/lib/node_modules/lightning-charge/node_modules/knex/lib/dialects/sqlite3/index.js:79:12)
at Client_SQLite3.initializeDriver (/usr/local/lib/node_modules/lightning-charge/node_modules/knex/lib/client.js:249:26)
at Client_SQLite3.Client (/usr/local/lib/node_modules/lightning-charge/node_modules/knex/lib/client.js:126:10)
at new Client_SQLite3 (/usr/local/lib/node_modules/lightning-charge/node_modules/knex/lib/dialects/sqlite3/index.js:62:20)
I tried to find the node-v57-linux-x64 folder, but I could only find the node-v48-linux-x64 folder instead.
npm install -g lightning-charge
npm ERR! path /usr/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/abbrev
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/abbrev' -> '/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/.abbrev.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-04-12T16_09_42_127Z-debug.log
My environment is Ubuntu
For stupid reasons I had to run the charge server on port 25. As soon as SMTP sockets have been opened the server crashed:
rpickhardt@ip-172-31-5-23:~/lightning-charge$ ./bin/charged -i 0.0.0.0 --port 25 events.js:183 throw er; // Unhandled 'error' event ^ Error: listen EACCES 0.0.0.0:25 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at Server.setupListenHandle [as _listen2] (net.js:1334:19) at listenInCluster (net.js:1392:12) at doListen (net.js:1501:7) at _combinedTickCallback (internal/process/next_tick.js:141:11) Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16", at process._tickCallback (internal/process/next_tick.js:180:9)
I think the error is in the following file at line 4 (completely not sure though since I don't get the flow of data within java script. That language will stay strange to me for the rest of my life):
Line 4 in 7c0294f
I could be totally wrong I tried to look at the code but as you know I am totally not a javascript kind of person so I won't provide a patch for this. However I think the server should / must be robust against invalid api requests... if you point me to the correct part of the code I am happy to provide a patch that doesn't die if the sytax of an request is wrong but rather puts something to the log files
Running the following versions on a Centos 7.5.1804 box:
node v6.14.3
charged 0.4.0
Trying to start charged with either ...
charged -t NstxQtqsWHubkdbimZ -l /home/username/.lightning -d /home/username/.charged -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t NstxQtqsWHubkdbimZ -l /home/username/.lightning/ -d /home/username/.charged/ -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t 1127589647 -l /home/username/.lightning -d /home/username/.charged -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t 1127589647 -l /home/username/.lightning -d /home/username/.charged/ -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t 1127589647 -l /home/username/.lightning -d /home/username/.charged -w 90 -p 9112 -i 0.0.0.0
... results in the following error being thrown:
Error: SQLITE_CANTOPEN: unable to open database file
at Error (native)
/usr/lib/node_modules/lightning-charge/dist/app.js:21
throw err;
^
Error: SQLITE_CANTOPEN: unable to open database file
at Error (native)
The sqlite.db file can be red and written by any user:
[username@host .charged]$ ls -al
total 20
drwxrwxr-x. 2 username username 23 Jul 10 21:28 .
drwx------. 12 username username 4096 Jul 10 21:33 ..
-rw-rw-rw-. 1 username username 16384 Jul 10 21:02 sqlite.db
I don't know if this is the right place to ask for this. But the irc channel at freenode is kinda empty.
I have the following set up: A full bitcoin node and lightning node running c-lightning.
On top of my lighting node I have lightning charge and nanotip.
But in https://github.com/ElementsProject/lightning-charge it says the following
Note that Charge does not have TLS encryption and should not normally be exposed directly to the public internet. For remote access, you should setup an SSH tunnel or a TLS-enabled reverse proxy like nginx.
So a searched online and get my nanotip working using a ssh tunnel like this
$ ssh user@external_ip -R 9000:localhost:9112 -f -N
It is working and I think I did everything right!
My nanotip can be reached from the web but to create a invoice it uses port 9000. And that port has a ssh tunnel to 9112 port of lighting charge.
Is the correct approach?
An initial simple implementation could require a shared secret token configure in .env
to be provided using HTTP basic authentication headers. Once support is added here, authentication support should be added to the client libraries as well.
Hello
c-lightning is working almost fine, I opened a few channels and made some payments.
I tried to install "lightning charge" but no success :( Can you help?
`root@vmi178998:~# sudo npm install -g lightning-charge
/usr/local/bin/charged -> /usr/local/lib/node_modules/lightning-charge/bin/charged
[email protected] install /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3
node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! UNCAUGHT EXCEPTION
node-pre-gyp ERR! stack TypeError: Buffer.alloc is not a function
node-pre-gyp ERR! stack at Object. (/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/tar/lib/pack.js:32:20)
node-pre-gyp ERR! stack at Module._compile (module.js:410:26)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:417:10)
node-pre-gyp ERR! stack at Module.load (module.js:344:32)
node-pre-gyp ERR! stack at Function.Module._load (module.js:301:12)
node-pre-gyp ERR! stack at Module.require (module.js:354:17)
node-pre-gyp ERR! stack at require (internal/module.js:12:17)
node-pre-gyp ERR! stack at Object. (/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/tar/lib/create.js:6:14)
node-pre-gyp ERR! stack at Module._compile (module.js:410:26)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:417:10)
node-pre-gyp ERR! System Linux 4.4.0-121-generic
node-pre-gyp ERR! command "/usr/bin/nodejs" "/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3
node-pre-gyp ERR! node -v v4.2.6
node-pre-gyp ERR! node-pre-gyp -v v0.9.0
node-pre-gyp ERR! This is a bug in node-pre-gyp
.
node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help:
node-pre-gyp ERR! https://github.com/mapbox/node-pre-gyp/issues
/usr/local/lib
โโโ (empty)
npm ERR! Linux 4.4.0-121-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "lightning-charge"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
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 sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log
npm ERR! code 1
`
npm-debug.log file here: https://pastebin.com/y7FvRBc0
Thank you
P.
Invoices should expire after some pre-determined timeout is reached. Especially important for invoices quoted in fiat currencies, where the exchange rate should only be locked-in for limited time.
I have setup the docker image and connected to an external bitcoind through the environment variables. When I ssh into the docker box and try to run "lightning-cli getaddr" I am shown the error, "lightning-cli: Connecting to 'lightning-rpc': Connection refused". All my charge rest requests work fine, but unless I can run these commands how do I open an channel?
This is useful if the user doesn't have a path to your node yet or if all inbound channels are full. It could be an optional setting.
Would it be a good enhancement to enable throttling on creation of invoices?
For accessing lightning-charge from a remote machine it is necessary to specify the host parameter to listen on all devices like so:
charged -t [API-TOKEN] -i 0.0.0.0
Is there any reason this is not documented?
I think it's uncommon to have the nodes and the store on the same machine so i would be glad having at least one hint in the documentation commenting this.
Hi,
Trying the Getting Started section for the first time on a fresh machine and I get the below error when attempting to run $ charged
. It's probably something I messed up or missed in the config.
/usr/local/lib/node_modules/lightning-charge/migrations/20180120115425_completed-fields.js:8
exports.down = async db => {
^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
...
at /usr/local/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:136:25
...
at Promise._settlePromise (/usr/local/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:569:18)
Anything obvious? Any suggestions?
My apologies in advance if it's something I missed and thanks for this awesome project!!!!
When trying to create an invoice through any of the POST /invoice
examples in the README, I always get the same error:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: SQLITE_CONSTRAINT: NOT NULL constraint failed: invoice.rhash</pre>
</body>
</html>
charged
daemon shows:
lightning-client #1 --> invoice ["10000","8gcq7sOTkiqZiTODgfNZY","Lightning Charge Invoice",null] +17s
lightning-client #1 <-- {"payment_hash":"42fa88fbe1f85516866a6fb4e4a0bcece294bca0428e947509305c6808317181","expiry_time":1516535310,"expires_at":1516535310,"bolt11":"lnbc100n1pdxgml7pp5gtag37lplp23dpn2d76wfg9uan3ff09qg28fgagfxpwxszp3wxqsdp8f35kw6r5de5kueeqgd5xzun8v5syjmnkda5kxegcqpggwmectjsfxeeuxwnpyccz8mhz2s7s5uv6kdzj3mnmq5ju0hctgmyyqrrrafmmma0sxuv2c9xvseg0cgxrvlmuf8fggh83hdjmsq32dgpr36dlj"} +40ms
lightning-charge saving invoice: { id: '8gcq7sOTkiqZiTODgfNZY',
description: undefined,
metadata: undefined,
msatoshi: '10000',
quoted_currency: undefined,
quoted_amount: undefined,
rhash: undefined,
payreq: 'lnbc100n1pdxgml7pp5gtag37lplp23dpn2d76wfg9uan3ff09qg28fgagfxpwxszp3wxqsdp8f35kw6r5de5kueeqgd5xzun8v5syjmnkda5kxegcqpggwmectjsfxeeuxwnpyccz8mhz2s7s5uv6kdzj3mnmq5ju0hctgmyyqrrrafmmma0sxuv2c9xvseg0cgxrvlmuf8fggh83hdjmsq32dgpr36dlj',
expires_at: 1516535310,
created_at: 1516531710,
completed: false } +0ms
knex:query insert into `invoice` (`completed`, `created_at`, `description`, `expires_at`, `id`, `metadata`, `msatoshi`, `payreq`, `quoted_amount`, `quoted_currency`, `rhash`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +17s
knex:bindings [ false,
knex:bindings 1516531710,
knex:bindings null,
knex:bindings 1516535310,
knex:bindings '8gcq7sOTkiqZiTODgfNZY',
knex:bindings 'null',
knex:bindings '10000',
knex:bindings 'lnbc100n1pdxgml7pp5gtag37lplp23dpn2d76wfg9uan3ff09qg28fgagfxpwxszp3wxqsdp8f35kw6r5de5kueeqgd5xzun8v5syjmnkda5kxegcqpggwmectjsfxeeuxwnpyccz8mhz2s7s5uv6kdzj3mnmq5ju0hctgmyyqrrrafmmma0sxuv2c9xvseg0cgxrvlmuf8fggh83hdjmsq32dgpr36dlj',
knex:bindings null,
knex:bindings null,
knex:bindings null ] +17s
POST /invoice 500 28.228 ms - 194
Error: SQLITE_CONSTRAINT: NOT NULL constraint failed: invoice.rhash
lightningd
gets the request and creates the invoice, but charged
doesn't seem to be mapping the response properly to its own invoice model.
These should be rejected I think.
LightningError: '0' is not a valid positive number
at createError (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/error/typed.js:31:22)
at LightningClient.once.res (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/lightning-client/index.js:109:28)
at Object.onceWrapper (events.js:272:13)
at LightningClient.emit (events.js:180:13)
at Parser.LightningClient.parser.onValue (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/lightning-client/index.js:59:17)
at Parser.proto.emit (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/jsonparse/jsonparse.js:337:8)
at Parser.proto.pop (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/jsonparse/jsonparse.js:332:8)
at Parser.proto.onToken (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/jsonparse/jsonparse.js:402:12)
at Parser.proto.write (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/jsonparse/jsonparse.js:135:34)
at Socket.LightningClient.client.on.data (/home/[redacted]/.npm-packages/lib/node_modules/lightning-charge/node_modules/lightning-client/index.js:54:53)
at Socket.emit (events.js:180:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
at Socket.Readable.push (_stream_readable.js:213:10)
at Pipe.onread (net.js:581:20)
So if I create an app with charged, does it automatically open/close channels? How do you "fund" charged?
If charged apps only rely on channels opened by customers, won't that have poor connectivity to the LN graph? Shouldn't you, from your own charged app, open a channel with some large node everyone else is already connected to?
Thanks!
Add a server-hosted payment page with instructions for the lightning payment that e-commerce stores can redirect customers to (similarly to how the checkout process with PayPal and other payment providers works), as an alternative to embedding the payment directly into the store.
Maybe I am missing something but it seems this tool is incomplete? I have the image up and running and figured out that I had to ssh into the box and open some channels via lightning-cli manually. But even after doing this (and being able to successfully send a payment to starblocks) I am never able to find a route to receive an incoming payment. That is with both my eclair for android and my lightning-charge node being connected to the same acinq node. Given the whole point of this project appears to be accepting payments I don't see any documentation on what I could be missing to actually be able to receive the payment? It doesn't even appear this image exposes the right port for the lightningd to even be discovered?
What's the recommended way to start lightning-charge automatically on boot?
Hi,
I would like to know if there is a plain (or if it is possible?) to create multiple api keys without runnning multiple charged instances?
Thank you!
I would like to give Lightning Charge a try on a cloud server, but I'm concerned about bandwidth.
How much bandwidth should I expect to use in a month?
Depending on how much bandwidth is needed, I may need to look into a home server for Lightning Charge.
Running the following versions on a Centos 7.5.1804 box:
node v6.14.3
charged 0.4.0
Steps to reproduce:
Except for #45 trying to start charged with either:
charged --api-token NstxQtqsWHubkdbimZ --ln-path /home/username/.lightning --max-wait 90 --port 9112 --host xxx.xxx.xxx.xxx
charged --api-token NstxQtqsWHubkdbimZ --ln-path /home/username/.lightning --port 9112 --host xxx.xxx.xxx.xxx
charged --api-token NstxQtqsWHubkdbimZ --ln-path /home/username/.lightning/ --host xxx.xxx.xxx.xxx
charged --api-token NstxQtqsWHubkdbimZ --host xxx.xxx.xxx.xxx
charged --api-token NstxQtqsWHubkdbimZ --host 0.0.0.0
charged --api-token NstxQtqsWHubkdbimZ
charged --api-token NstxQtqsWHubk
charged -t NstxQtqsWHubkdbimZ -l /home/username/.lightning/ -d /home/username/.charged/sqlite.db -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t NstxQtqsWHubkdbimZ -l /home/username/.lightning/ -d ./.charged/sqlite.db -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t NstxQtqsWHubkdbimZ -l /home/username/.lightning -d ./.charged -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t NstxQtqsWHubkdbimZ -l /home/username/.lightning -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t NstxQtqsWHubkdbimZ -i xxx.xxx.xxx.xxx
charged -t NstxQtqsWHubkdbimZ
charged -t 1127589647 -l /home/username/.lightning -d /home/username/.charged/sqlite.db -w 90 -p 9112 -i xxx.xxx.xxx.xxx
charged -t 1127589647 -l /home/username/.lightning -d /home/username/.charged/sqlite.db -w 90 -p 9112 -i 0.0.0.0
charged -t 1127589647 -i 0.0.0.0
charged -t 1127589647 -l /home/username/.lightning -d /home/username/.charged/sqlite.db -w 90 -p 9112 -i 0.0.0.0
charged -t 1127589647 -l /home/username/.lightning --db-path ./charge.db -w 90 -p 9112 -i 0.0.0.0
... results in the following error being thrown:
/usr/lib/node_modules/lightning-charge/migrations/20180120115425_completed-fields.js:8
exports.down = async db => {
^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at /usr/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:137:25
at arrayFilter (/usr/lib/node_modules/lightning-charge/node_modules/knex/node_modules/lodash/_arrayFilter.js:18:9)
at filter (/usr/lib/node_modules/lightning-charge/node_modules/knex/node_modules/lodash/filter.js:45:10)
at /usr/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:136:112
at tryCatcher (/usr/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:509:35)
at Promise._settlePromise (/usr/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:569:18)
/usr/lib/node_modules/lightning-charge/migrations/20180120115425_completed-fields.js:8
exports.down = async db => {
^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at /usr/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:137:25
at arrayFilter (/usr/lib/node_modules/lightning-charge/node_modules/knex/node_modules/lodash/_arrayFilter.js:18:9)
at filter (/usr/lib/node_modules/lightning-charge/node_modules/knex/node_modules/lodash/filter.js:45:10)
at /usr/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:136:112
at tryCatcher (/usr/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:509:35)
at Promise._settlePromise (/usr/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:569:18)
Good day,
Sorry if this is a noob question.
I've already setup bitcoind
and lightningd
in my machine.
The problem is whenever I run charged
or charged --api-token mytokenhere
it shows this error.
exports.down = async db => {
^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:136:25
at arrayFilter (/home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/lodash/_arrayFilter.js:18:9)
at filter (/home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/lodash/filter.js:45:10)
at /home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/knex/lib/migrate/index.js:135:112
at tryCatcher (/home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:509:35)
at Promise._settlePromise (/home/bitcoin/.npm-global/lib/node_modules/lightning-charge/node_modules/bluebird/js/release/promise.js:569:18)
/home/bitcoin/.npm-global/lib/node_modules/lightning-charge/migrations/20180120115425_completed-fields.js:8
Thanks
Use case:
In BTCPay, the user can decide to pay the invoice partly in BTC, partly in LTC, and soon, partly on lightning.
When the invoice is created I create all the addresses in all the alts, and soon, all the invoices on lightning charge. When an address receive a payment, I generate a fresh address.
But I will also need to generate a new lightning invoice, because the amount due changed.
I would like to invalidate the previous invoice (which has the wrong amount now) if that happen.
This is a "nice to have feature" because I can be sure the user can't screw up and pay too much by mistake. But I can do without, as merchants are kind of used to deal with users sending not enough/too much already.
I donno the bitcoinaverage's rate limit, but sometimes in my test env it happen that I get a 429 that is pretty annoying. Also there is no reason to overload bitcoinaverage of request when they update the ticket only every 15s.
exchange-rate.js could be replaced with:
import big from 'big.js'
import request from 'superagent'
const FIXED_RATES = { BTC: 1 }
, BTC_MSAT_RATIO = big('100000000000')
const enc = encodeURIComponent
const now = () => Date.now()
// Fetch current exchange rate from BitcoinAverage
const getRate_ = millisecDelta => {
const cache = {}
return (async (currency) => {
const cached = cache[currency]
if (cached && (now() - cached.time) <= millisecDelta) {
return cached.rate
}
else {
try {
const rate = (await request.get(`https://apiv2.bitcoinaverage.com/indices/global/ticker/short?crypto=BTC&fiat=${enc(currency)}`))
.body['BTC'+currency].last
cache[currency] = {rate, time: now()}
return rate
}
catch(err) {
return Promise.reject(err.status == 404 ? new Error('Unknown currency: '+currency) : err)
}
}
})
}
// bitcoinaverage update the ticker every 15 seconds
// one minute old prices seems resonable?
const cacheDelta = Number.isNaN(parseInt(process.env.CACHE_D)) ? 0 : parseInt(process.env.CACHE_D)
const getRate = getRate_(cacheDelta)
// Convert `amount` units of `currency` to msatoshis
const toMsat = async (currency, amount) =>
big(amount)
.div(FIXED_RATES[currency] || await getRate(currency))
.mul(BTC_MSAT_RATIO)
.round(0, 3) // round up to nearest msatoshi
.toFixed(0)
module.exports = { getRate, toMsat }
Note that we use env varse to set our cache, for example declared in a docker-compose file. And that there are no breaking changes cause the default behavior is to set the cache to 0ms.
Failed to install package with npm@node10 on FreeBSD10. If npm@node8 is used package install is succesfull.
Errorlog:
npm install --unsafe-perm -g lightning-charge --sqlite=/usr/local
16159 info lifecycle [email protected]
install: [email protected]install: unsafe-perm in lifecycle true
16160 verbose lifecycle [email protected]
16161 verbose lifecycle [email protected]install: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/node_modules/.bin:/usr/local/lib/node_modules/lightning-charge/node_modules/.bin:/usr/local/lib/node_modules/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bininstall: CWD: /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3
16162 verbose lifecycle [email protected]
16163 silly lifecycle [email protected]install: Args: [ '-c', 'node-pre-gyp install --fallback-to-build' ]install: Returned: code: 1 signal: null
16164 silly lifecycle [email protected]
16165 info lifecycle [email protected]~install: Failed to exec install script
16166 timing action:install Completed in 14059ms
16167 verbose unlock done using /root/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
16168 timing stage:rollbackFailedOptional Completed in 2041ms
16169 timing stage:runTopLevelLifecycles Completed in 34196ms
16170 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/lightning-charge/node_modules/fsevents):
16171 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"freebsd","arch":"x64"})
16172 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
16172 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
16172 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: freebsd
16172 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
16173 verbose stack Error: [email protected] install:node-pre-gyp install --fallback-to-build
16173 verbose stack Exit status 1
16173 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
16173 verbose stack at EventEmitter.emit (events.js:189:13)
16173 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
16173 verbose stack at ChildProcess.emit (events.js:189:13)
16173 verbose stack at maybeClose (internal/child_process.js:970:16)
16173 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
16174 verbose pkgid [email protected]
16175 verbose cwd /root
16176 verbose FreeBSD 12.0-RELEASE
16177 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--unsafe-perm" "-g" "lightning-charge" "--sqlite=/usr/local"
16178 verbose node v10.15.3
16179 verbose npm v6.9.0
16180 error code ELIFECYCLE
16181 error errno 1
16182 error [email protected] install:node-pre-gyp install --fallback-to-build
16182 error Exit status 1
16183 error Failed at the [email protected] install script.
16183 error This is probably not a problem with npm. There is likely additional logging output above.
16184 verbose exit [ 1, true ]
Requested by @NicolasDorier
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.