From 8337aad59675502f7576eb41ff220730bf743bd3 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 27 Jun 2025 09:31:41 +0200 Subject: [PATCH] Remove unreachable code (#2249) * Remove unreachable code * Remove unnecessary exports --- api/resolvers/wallet.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index 1deb6ca7..c97eac79 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -22,7 +22,7 @@ import walletDefs from '@/wallets/server' import { generateResolverName, generateTypeDefName } from '@/wallets/graphql' import { lnAddrOptions } from '@/lib/lnurl' import { GqlAuthenticationError, GqlAuthorizationError, GqlInputError } from '@/lib/error' -import { getNodeSockets, getOurPubkey } from '../lnd' +import { getNodeSockets } from '../lnd' import validateWallet from '@/wallets/validate' import { canReceive, getWalletByType } from '@/wallets/common' import performPaidAction from '../paidAction' @@ -987,7 +987,7 @@ export async function createWithdrawal (parent, { invoice, maxFee }, { me, model return await performPayingAction({ bolt11: invoice, maxFee, walletId: wallet?.id }, { me, models, lnd }) } -export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer }, +async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer }, { me, models, lnd, headers }) { if (!me) { throw new GqlAuthenticationError() @@ -1005,11 +1005,9 @@ export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ... return await createWithdrawal(parent, { invoice: res.pr, maxFee }, { me, models, lnd, headers }) } -export async function fetchLnAddrInvoice ( +async function fetchLnAddrInvoice ( { addr, amount, maxFee, comment, ...payer }, - { - me, models, lnd, autoWithdraw = false - }) { + { me, models, lnd }) { const options = await lnAddrOptions(addr) await validateSchema(lnAddrSchema, { addr, amount, maxFee, comment, ...payer }, options) @@ -1046,14 +1044,6 @@ export async function fetchLnAddrInvoice ( // decode invoice try { const decoded = await parsePaymentRequest({ request: res.pr }) - const ourPubkey = await getOurPubkey({ lnd }) - if (autoWithdraw && 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: 'LIGHTNING_ADDRESS' } - }) - throw new Error('automated withdrawals to other stackers are not allowed') - } if (!decoded.mtokens || BigInt(decoded.mtokens) !== BigInt(milliamount)) { throw new Error('invoice has incorrect amount') }