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 {
|
try {
|
||||||
const decoded = await decodePaymentRequest({ lnd, request: res.pr })
|
const decoded = await decodePaymentRequest({ lnd, request: res.pr })
|
||||||
const ourPubkey = (await getIdentity({ lnd })).public_key
|
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
|
// unset lnaddr so we don't trigger another withdrawal with same destination
|
||||||
await models.user.update({
|
await models.wallet.deleteMany({
|
||||||
where: { id: me.id },
|
where: { userId: me.id, type: 'LIGHTNING_ADDRESS' }
|
||||||
data: {
|
|
||||||
lnAddr: null,
|
|
||||||
autoWithdrawThreshold: null,
|
|
||||||
autoWithdrawMaxFeePercent: null
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
throw new Error('automated withdrawals to other stackers are not allowed')
|
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')
|
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 })
|
return await sendToLnAddr(null, { addr: address, amount, maxFee }, { me, models, lnd, autoWithdraw: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue