Compare commits
3 Commits
40131da8bd
...
1faf309c00
Author | SHA1 | Date | |
---|---|---|---|
|
1faf309c00 | ||
|
448f028ec1 | ||
|
2ec0a1a559 |
@ -1,10 +1,10 @@
|
|||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import https from 'https'
|
import https from 'https'
|
||||||
|
import crypto from 'crypto'
|
||||||
|
|
||||||
export const createInvoice = async ({ socket, rune, cert, label, description, msats, expiry }) => {
|
export const createInvoice = async ({ socket, rune, cert, label, description, msats, expiry }) => {
|
||||||
const agent = cert ? new https.Agent({ ca: Buffer.from(cert, 'base64') }) : undefined
|
const agent = cert ? new https.Agent({ ca: Buffer.from(cert, 'base64') }) : undefined
|
||||||
const url = 'https://' + socket + '/v1/invoice'
|
const url = 'https://' + socket + '/v1/invoice'
|
||||||
const randomId = Math.floor(Math.random() * 1000)
|
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -16,8 +16,9 @@ export const createInvoice = async ({ socket, rune, cert, label, description, ms
|
|||||||
},
|
},
|
||||||
agent,
|
agent,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
// why does CLN require a unique label?
|
// CLN requires a unique label for every invoice
|
||||||
label: description ? `${description} ${randomId}` : randomId,
|
// see https://docs.corelightning.org/reference/lightning-invoice
|
||||||
|
label: crypto.randomBytes(16).toString('hex'),
|
||||||
description,
|
description,
|
||||||
amount_msat: msats,
|
amount_msat: msats,
|
||||||
expiry
|
expiry
|
||||||
|
19
package-lock.json
generated
19
package-lock.json
generated
@ -51,7 +51,7 @@
|
|||||||
"next-auth": "^4.23.2",
|
"next-auth": "^4.23.2",
|
||||||
"next-plausible": "^3.11.1",
|
"next-plausible": "^3.11.1",
|
||||||
"next-seo": "^6.1.0",
|
"next-seo": "^6.1.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.7",
|
||||||
"node-s3-url-encode": "^0.0.4",
|
"node-s3-url-encode": "^0.0.4",
|
||||||
"nodemailer": "^6.9.6",
|
"nodemailer": "^6.9.6",
|
||||||
"nostr": "^0.2.8",
|
"nostr": "^0.2.8",
|
||||||
@ -14738,11 +14738,22 @@
|
|||||||
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
|
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
|
||||||
},
|
},
|
||||||
"node_modules/node-fetch": {
|
"node_modules/node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-url": "^5.0.0"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "4.x || >=6.0.0"
|
"node": "4.x || >=6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"encoding": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"encoding": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-gyp-build": {
|
"node_modules/node-gyp-build": {
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
"next-auth": "^4.23.2",
|
"next-auth": "^4.23.2",
|
||||||
"next-plausible": "^3.11.1",
|
"next-plausible": "^3.11.1",
|
||||||
"next-seo": "^6.1.0",
|
"next-seo": "^6.1.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.7",
|
||||||
"node-s3-url-encode": "^0.0.4",
|
"node-s3-url-encode": "^0.0.4",
|
||||||
"nodemailer": "^6.9.6",
|
"nodemailer": "^6.9.6",
|
||||||
"nostr": "^0.2.8",
|
"nostr": "^0.2.8",
|
||||||
|
@ -87,7 +87,7 @@ export async function autoWithdraw ({ data: { id }, models, lnd }) {
|
|||||||
: wallet.type === 'CLN' ? 'walletCLN' : 'walletLightningAddress',
|
: wallet.type === 'CLN' ? 'walletCLN' : 'walletLightningAddress',
|
||||||
level: 'ERROR',
|
level: 'ERROR',
|
||||||
message: 'autowithdrawal failed: ' + details
|
message: 'autowithdrawal failed: ' + details
|
||||||
})
|
}, { me: user, models })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user