Skip to content

Commit 8337aad

Browse files
authored
Remove unreachable code (#2249)
* Remove unreachable code * Remove unnecessary exports
1 parent 0436bf6 commit 8337aad

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

api/resolvers/wallet.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import walletDefs from '@/wallets/server'
2222
import { generateResolverName, generateTypeDefName } from '@/wallets/graphql'
2323
import { lnAddrOptions } from '@/lib/lnurl'
2424
import { GqlAuthenticationError, GqlAuthorizationError, GqlInputError } from '@/lib/error'
25-
import { getNodeSockets, getOurPubkey } from '../lnd'
25+
import { getNodeSockets } from '../lnd'
2626
import validateWallet from '@/wallets/validate'
2727
import { canReceive, getWalletByType } from '@/wallets/common'
2828
import performPaidAction from '../paidAction'
@@ -987,7 +987,7 @@ export async function createWithdrawal (parent, { invoice, maxFee }, { me, model
987987
return await performPayingAction({ bolt11: invoice, maxFee, walletId: wallet?.id }, { me, models, lnd })
988988
}
989989

990-
export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer },
990+
async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer },
991991
{ me, models, lnd, headers }) {
992992
if (!me) {
993993
throw new GqlAuthenticationError()
@@ -1005,11 +1005,9 @@ export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...
10051005
return await createWithdrawal(parent, { invoice: res.pr, maxFee }, { me, models, lnd, headers })
10061006
}
10071007

1008-
export async function fetchLnAddrInvoice (
1008+
async function fetchLnAddrInvoice (
10091009
{ addr, amount, maxFee, comment, ...payer },
1010-
{
1011-
me, models, lnd, autoWithdraw = false
1012-
}) {
1010+
{ me, models, lnd }) {
10131011
const options = await lnAddrOptions(addr)
10141012
await validateSchema(lnAddrSchema, { addr, amount, maxFee, comment, ...payer }, options)
10151013

@@ -1046,14 +1044,6 @@ export async function fetchLnAddrInvoice (
10461044
// decode invoice
10471045
try {
10481046
const decoded = await parsePaymentRequest({ request: res.pr })
1049-
const ourPubkey = await getOurPubkey({ lnd })
1050-
if (autoWithdraw && decoded.destination === ourPubkey && process.env.NODE_ENV === 'production') {
1051-
// unset lnaddr so we don't trigger another withdrawal with same destination
1052-
await models.wallet.deleteMany({
1053-
where: { userId: me.id, type: 'LIGHTNING_ADDRESS' }
1054-
})
1055-
throw new Error('automated withdrawals to other stackers are not allowed')
1056-
}
10571047
if (!decoded.mtokens || BigInt(decoded.mtokens) !== BigInt(milliamount)) {
10581048
throw new Error('invoice has incorrect amount')
10591049
}

0 commit comments

Comments
 (0)