diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index 555d553d..9e3d025f 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -659,15 +659,10 @@ 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) { + if (autoWithdraw && decoded.destination === ourPubkey && process.env.NODE_ENV === 'production') { // unset lnaddr so we don't trigger another withdrawal with same destination - await models.user.update({ - where: { id: me.id }, - data: { - lnAddr: null, - autoWithdrawThreshold: null, - autoWithdrawMaxFeePercent: null - } + await models.wallet.deleteMany({ + where: { userId: me.id, type: 'LIGHTNING_ADDRESS' } }) throw new Error('automated withdrawals to other stackers are not allowed') } diff --git a/worker/autowithdraw.js b/worker/autowithdraw.js index 600a106d..55010aef 100644 --- a/worker/autowithdraw.js +++ b/worker/autowithdraw.js @@ -85,7 +85,7 @@ async function autowithdrawLNAddr ( throw new Error('no lightning address wallet found') } - const { walletLND: { address } } = wallet + const { walletLightningAddress: { address } } = wallet return await sendToLnAddr(null, { addr: address, amount, maxFee }, { me, models, lnd, autoWithdraw: true }) }