fix lnaddr autowithdraw

This commit is contained in:
keyan 2024-02-15 08:59:45 -06:00
parent 35d212573e
commit 57917d47a2
2 changed files with 4 additions and 9 deletions

View File

@ -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')
}

View File

@ -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 })
}