exact error handling
This commit is contained in:
parent
47f37b06d8
commit
e8ad0b854c
1 changed files with 9 additions and 7 deletions
|
|
@ -921,6 +921,11 @@ const sendPayment = async (to, amount, memo, gun, user, SEA) => {
|
|||
services: { lightning }
|
||||
} = LightningServices
|
||||
|
||||
/**
|
||||
* @typedef {object} SendErr
|
||||
* @prop {string} details
|
||||
*/
|
||||
|
||||
/**
|
||||
* Partial
|
||||
* https://api.lightning.community/#grpc-response-sendresponse-2
|
||||
|
|
@ -929,17 +934,14 @@ const sendPayment = async (to, amount, memo, gun, user, SEA) => {
|
|||
* @prop {any[]|null} payment_route
|
||||
*/
|
||||
|
||||
await new Promise((rej, resolve) => {
|
||||
await new Promise((resolve, rej) => {
|
||||
lightning.sendPaymentSync(
|
||||
{
|
||||
payment_request: decInvoice
|
||||
},
|
||||
(/*** @type {any} */ err, /** @type {SendResponse} */ res) => {
|
||||
console.log(`sendPaymentSync err: ${JSON.stringify(err)}`)
|
||||
console.log(`sendPaymentSync res: ${JSON.stringify(res)}`)
|
||||
|
||||
if (err || typeof err === 'number') {
|
||||
rej(new Error(`sendPaymentSync error: ${JSON.stringify(err)}`))
|
||||
(/** @type {SendErr=} */ err, /** @type {SendResponse} */ res) => {
|
||||
if (err) {
|
||||
rej(new Error(err.details))
|
||||
} else if (res) {
|
||||
if (res.payment_error) {
|
||||
rej(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue