From fc781047d53ff43c68aeccef3f195dc3bec4d362 Mon Sep 17 00:00:00 2001 From: keyan Date: Sat, 6 Jul 2024 12:56:20 -0500 Subject: [PATCH] fix autowithdraw flag for lightning address --- api/resolvers/wallet.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index 8c081c24..c3485efd 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -745,7 +745,7 @@ export async function createWithdrawal (parent, { invoice, maxFee }, { me, model } export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer }, - { me, models, lnd, headers, autoWithdraw = false }) { + { me, models, lnd, headers, walletId }) { if (!me) { throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } }) } @@ -788,7 +788,7 @@ export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ... try { const decoded = await decodePaymentRequest({ lnd, request: res.pr }) const ourPubkey = (await getIdentity({ lnd })).public_key - if (autoWithdraw && decoded.destination === ourPubkey && process.env.NODE_ENV === 'production') { + if (walletId && decoded.destination === ourPubkey && process.env.NODE_ENV === 'production') { // unset lnaddr so we don't trigger another withdrawal with same destination await models.wallet.deleteMany({ where: { userId: me.id, type: Wallet.LnAddr.type } @@ -804,5 +804,5 @@ export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ... } // take pr and createWithdrawl - return await createWithdrawal(parent, { invoice: res.pr, maxFee }, { me, models, lnd, headers, autoWithdraw }) + return await createWithdrawal(parent, { invoice: res.pr, maxFee }, { me, models, lnd, headers, walletId }) }