Hi
Iâm in the âCreating Lightning invoicesâ section of the course. Iâve added the create_invoice function call, but when I execute (ie. enter an amount and submit via the webpage) I get the error below. I tried about 5 hours ago and thought the BTCPay Server may be down, but trying again just now I get the same error. Any ideas of what might be going wrong?
Hereâs my invoice.js code (from the point after I assign my private key and merchant key to the const variables:
// 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);
})
.catch(err => console.log(err));
});
module.exports = router;```
MMB:lightning-app-boilerplate Mark$ npm start
[email protected] start /Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate
node ./bin/www
GET / 304 1688.277 ms - -
GET /favicon.ico 404 71.422 ms - 3398
StatusCodeError: 400 - {âerrorâ:â6/23/2020 6:57:19 PM: Creation of invoice starting\n6/23/2020 6:57:19 PM: BTC_USD: The rating rule is coingecko(BTC_USD)\n6/23/2020 6:57:19 PM: BTC_USD: The evaluated rating rule is 9667.938\n6/23/2020 6:57:19 PM: BTC (Off-Chain): Payment method details creation took 343 milliseconds\n6/23/2020 6:57:19 PM: BTC: Payment method unavailable (Impossible to create lightning invoice (Response status code does not indicate success: 400 (Bad Request).))\nâ}
at new StatusCodeError (/Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate/node_modules/request-promise-core/lib/errors.js:32:15)
at Request.plumbing.callback (/Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate/node_modules/request-promise-core/lib/plumbing.js:104:33)
at Request.RP$callback [as _callback] (/Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate/node_modules/request-promise-core/lib/plumbing.js:46:31)
at Request.self.callback (/Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate/node_modules/request/request.js:185:22)
at Request.emit (events.js:315:20)
at Request. (/Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate/node_modules/request/request.js:1161:10)
at Request.emit (events.js:315:20)
at IncomingMessage. (/Users/Mark/Documents/BlockChain/IvanOnTechAcademy/Lightning/LightningApp/lightning-app-boilerplate/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:421:28)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1221:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
statusCode: 400,
error: {
error: â6/23/2020 6:57:19 PM: Creation of invoice starting\nâ +
â6/23/2020 6:57:19 PM: BTC_USD: The rating rule is coingecko(BTC_USD)\nâ +
â6/23/2020 6:57:19 PM: BTC_USD: The evaluated rating rule is 9667.938\nâ +
â6/23/2020 6:57:19 PM: BTC (Off-Chain): Payment method details creation took 343 milliseconds\nâ +
â6/23/2020 6:57:19 PM: BTC: Payment method unavailable (Impossible to create lightning invoice (Response status code does not indicate success: 400 (Bad Request).))\nâ
},
options: {
headers: {
âContent-Typeâ: âapplication/jsonâ,
Accept: âapplication/jsonâ,
âUser-Agentâ: ânode-btcpayâ,
âX-Accept-Versionâ: â2.0.0â,
etc
etc
toJSON: [Function: responseToJSON],
caseless: Caseless { dict: [Object] },
body: {
error: '6/23/2020 6:57:19 PM: Creation of invoice starting\n' +
'6/23/2020 6:57:19 PM: BTC_USD: The rating rule is coingecko(BTC_USD)\n' +
'6/23/2020 6:57:19 PM: BTC_USD: The evaluated rating rule is 9667.938\n' +
'6/23/2020 6:57:19 PM: BTC (Off-Chain): Payment method details creation took 343 milliseconds\n' +
'6/23/2020 6:57:19 PM: BTC: Payment method unavailable (Impossible to create lightning invoice (Response status code does not indicate success: 400 (Bad Request).))\n'
},
[Symbol(kCapture)]: false
}
}
POST /invoice - - ms - -