fix lnaddr autowithdraw
This commit is contained in:
parent
35d212573e
commit
57917d47a2
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue