Building a Lightning App (Lapp) - Discussion

You’re right. The error occurs when trying to create the Merchant Key.
node -e “const btcpay=require(‘btcpay’); new btcpay.BTCPayClient(‘https://lightning.filipmartinsson.com/’, btcpay.crypto.load_keypair(Buffer.from(’<BTCPAY_KEY>’, ‘hex’))).pair_client(’<BTCPAY_PAIRCODE>’).then(console.log).catch(console.error)”

The course was great, thanks a lot Filip!

I want to build my own website with a Lightning App using the knowledge I’ve just learned. I live in a small place and don’t really want to run a bitcoin node at home 24/7. Is there a way I can maybe run a light client node on AWS for cheaply? If you have any advice please let me know. Cheers

1 Like

Sorry for the slow response. I have been sick for the past week.

Maybe a stupid question, but you are replacing the <BTCPAY_KEY> and <BTCPAY_PAIRCODE> with the actual codes right?

Thank you very much! Yeah you can definitely run it on aws. You can check out this blog post for guidance: https://medium.com/andreas-tries-blockchain/bitcoin-lightning-network-1-can-i-compile-and-run-a-node-cd3138c68c15

Hi no worries, hope your getting better! Yes i replaced the BTCPAY_KEY and BTC_PIARCODE with the right codes, just didn’t want to post them in the forum. I have also tried both variants of code (original on GitHub and the correction for windows) and also tried to reset everything and started from scratch, unfortunately so far without success.

Do you get the same error now regardless of which script you use?

Could you please paste your script into a text file (including the keys) and send that file to me in a DM here in the forum? I want it in a text file in order to avoid the forums own formatting of certain special characters.

Just a disclaimer for everyone: In normal circumstances you should never send your keys to anyone that asks you, including me. These are not private keys that are used for anything valuable. They are just a random generated keypair from my lightning server.

1 Like

Hey, I’m getting a RequestError when trying to get the merchant token. I’m running BTCPay locally for development and running the following command:

node -e “const btcpay=require(‘btcpay’); new btcpay.BTCPayClient(‘https://192.168.0.12:23001’, btcpay.crypto.load_keypair(Buffer.from(‘XXXX’, ‘hex’))).pair_client(‘XXXX’).then(console.log).catch(console.error)”

Error:

name: ‘RequestError’,
message: ‘Error: write EPROTO 4347239872:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:…/deps/openssl/openssl/ssl/record/ssl3_record.c:332:\n’,
cause: Error: write EPROTO 4347239872:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:…/deps/openssl/openssl/ssl/record/ssl3_record.c:332

Any idea what’s causing this?

1 Like

Oh found it, I’m not using a secure connection so https should be http.

1 Like

Great, I’m glad you solved it :slight_smile:

what is your lightning public key (its not posted above the video) ?

You shouldn’t need my public key? You generate your own keypair with the paircode.

Hey @filip I’m stuck with the following error: TypeError: Cannot read property ‘fromRed’ of null - while trying to generate the Merchant key.

I am running the recommended script for Windows users - exact the same case as for @KnutKurbel. What’s the solution to this error? I notice there’s been a debate but no clear solution has been given yet.

1 Like

Hi @Karolis_Abramavicius. In my case I had to remove the < > around the keys. That helped to create the merchant keys.

2 Likes

Works fine. Thanks !

2 Likes

I fail to create Lightning Invoices for the error shown in the picture.
Please Help.

1 Like

Hi.
I see the error message says that "no wallet has been linked to the BTCPay Store. Have you checked that the settings in your BTCpay Store is correct?

Ivo

1 Like

I have followed all the procedure in the video. Do I need to do something extra?

1 Like

I also see that you get the error «unauthorized access to API, premium plan needed» I remember i got the same error when I tried to show BTC_NKR instead of BTC_USD.

Is this the first time you run the code? Or did it work before?
Can you post a screenshot of your code? Maybe we can spot the error?

Ivo

It is my first time to run the code and I am using windows.
Here is the code in the invoice.js .
Thanks a lot.

var express = require(‘express’);
var router = express.Router();
const BTCPAY_PRIV_KEY = “”;
const BTCPAY_MERCHANT_KEY = “”;

// Initialize the client
const btcpay = require(‘btcpay’)
const keypair = btcpay.crypto.load_keypair(new Buffer.from(BTCPAY_PRIV_KEY, ‘hex’));
const client = new btcpay.BTCPayClient(‘https://lightning.filipmartinsson.com’, keypair, {merchant: BTCPAY_MERCHANT_KEY})

/* get & verify invoice. */
router.get(’/:id’, async function(req, res, next) {

});

/* Create invoice. */
router.post(’/’, function(req, res, next) {
var dollarAmount = req.body.amount;
client.create_invoice({price: dollarAmount, currency: “USD”})
.then(function(invoice){
console.log(invoice);
res.render(“invoice”, {invoiceId: invoice.id})
})
.catch(err => console.log(err));
});

module.exports = router;

HI.
I`ll take a look at it and come back to you. Can you check the settings in btcpay store and see if everything is correct in the mean time?

Ivo

1 Like