Remove TODO about errors in createInvoice (#1300)
This commit is contained in:
parent
4000522773
commit
8e18fa0760
|
@ -11,19 +11,25 @@ export const createInvoice = async (
|
|||
{ msats, description, descriptionHash, expiry },
|
||||
{ cert, macaroon, socket }
|
||||
) => {
|
||||
const { lnd } = await authenticatedLndGrpc({
|
||||
cert,
|
||||
macaroon,
|
||||
socket
|
||||
})
|
||||
try {
|
||||
const { lnd } = await authenticatedLndGrpc({
|
||||
cert,
|
||||
macaroon,
|
||||
socket
|
||||
})
|
||||
|
||||
const invoice = await lndCreateInvoice({
|
||||
lnd,
|
||||
description,
|
||||
description_hash: descriptionHash,
|
||||
mtokens: String(msats),
|
||||
expires_at: datePivot(new Date(), { seconds: expiry })
|
||||
})
|
||||
const invoice = await lndCreateInvoice({
|
||||
lnd,
|
||||
description,
|
||||
description_hash: descriptionHash,
|
||||
mtokens: String(msats),
|
||||
expires_at: datePivot(new Date(), { seconds: expiry })
|
||||
})
|
||||
|
||||
return invoice.request
|
||||
return invoice.request
|
||||
} catch (err) {
|
||||
// LND errors can be in this shape: [code, type, { err: { code, details, metadata } }]
|
||||
const details = err[2]?.err?.details || err.message || err.toString?.()
|
||||
throw new Error(details)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,15 +59,10 @@ export async function createInvoice (userId, { msats, description, descriptionHa
|
|||
return { invoice, wallet }
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
// TODO: I think this is a bug, `createInvoice` should parse the error
|
||||
|
||||
// LND errors are in this shape: [code, type, { err: { code, details, metadata } }]
|
||||
const details = error[2]?.err?.details || error.message || error.toString?.()
|
||||
await addWalletLog({
|
||||
wallet,
|
||||
level: 'ERROR',
|
||||
message: `creating invoice for ${description ?? ''} failed: ` + details
|
||||
message: `creating invoice for ${description ?? ''} failed: ` + error
|
||||
}, { models })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue