mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-05-20 17:02:04 +00:00
Only return preimage if invoice settled lol
This commit is contained in:
parent
e81aeb4ead
commit
29c14bd772
@ -39,10 +39,11 @@ export default async function handler(req, res) {
|
|||||||
// - { status: "OK", settled: false, preimage: null, pr: "lnbc10..." }
|
// - { status: "OK", settled: false, preimage: null, pr: "lnbc10..." }
|
||||||
// - { status: "ERROR", reason: "error message" }
|
// - { status: "ERROR", reason: "error message" }
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
|
const isSettled = response.data.state === "SETTLED";
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: "OK",
|
status: "OK",
|
||||||
settled: response.data.state === "SETTLED",
|
settled: isSettled,
|
||||||
preimage: response.data.r_preimage ?
|
preimage: isSettled && response.data.r_preimage ?
|
||||||
Buffer.from(response.data.r_preimage, 'base64').toString('hex') :
|
Buffer.from(response.data.r_preimage, 'base64').toString('hex') :
|
||||||
null,
|
null,
|
||||||
pr: response.data.payment_request
|
pr: response.data.payment_request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user