disable self sends in autowithdraw
This commit is contained in:
parent
1d388942e9
commit
b530b611f5
@ -522,7 +522,7 @@ export default {
|
|||||||
throw new GraphQLError('you must be logged in', { extensions: { code: 'UNAUTHENTICATED' } })
|
throw new GraphQLError('you must be logged in', { extensions: { code: 'UNAUTHENTICATED' } })
|
||||||
}
|
}
|
||||||
|
|
||||||
await ssValidate(lnAddrAutowithdrawSchema, data, { models })
|
await ssValidate(lnAddrAutowithdrawSchema, data, { me, models })
|
||||||
|
|
||||||
await models.user.update({
|
await models.user.update({
|
||||||
where: { id: me.id },
|
where: { id: me.id },
|
||||||
|
@ -204,9 +204,15 @@ export function advSchema (args) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function lnAddrAutowithdrawSchema (args) {
|
export function lnAddrAutowithdrawSchema ({ me } = {}) {
|
||||||
return object({
|
return object({
|
||||||
lnAddr: lightningAddressValidator.required('required'),
|
lnAddr: lightningAddressValidator.required('required').test({
|
||||||
|
name: 'lnAddr',
|
||||||
|
test: async addr => {
|
||||||
|
return addr !== `${me.name}@stacker.news` && !addr.startsWith(`${me.name}@localhost`)
|
||||||
|
},
|
||||||
|
message: 'cannot send to yourself'
|
||||||
|
}),
|
||||||
autoWithdrawThreshold: intValidator.required('required').min(0, 'must be at least 0').max(msatsToSats(BALANCE_LIMIT_MSATS), `must be at most ${abbrNum(msatsToSats(BALANCE_LIMIT_MSATS))}`),
|
autoWithdrawThreshold: intValidator.required('required').min(0, 'must be at least 0').max(msatsToSats(BALANCE_LIMIT_MSATS), `must be at most ${abbrNum(msatsToSats(BALANCE_LIMIT_MSATS))}`),
|
||||||
autoWithdrawMaxFeePercent: floatValidator.required('required').min(0, 'must be at least 0').max(50, 'must not exceed 50')
|
autoWithdrawMaxFeePercent: floatValidator.required('required').min(0, 'must be at least 0').max(50, 'must not exceed 50')
|
||||||
})
|
})
|
||||||
|
@ -42,7 +42,7 @@ export default function LightningAddress () {
|
|||||||
autoWithdrawThreshold: isNaN(me?.privates?.autoWithdrawThreshold) ? 10000 : me?.privates?.autoWithdrawThreshold,
|
autoWithdrawThreshold: isNaN(me?.privates?.autoWithdrawThreshold) ? 10000 : me?.privates?.autoWithdrawThreshold,
|
||||||
autoWithdrawMaxFeePercent: isNaN(me?.privantes?.autoWithdrawMaxFeePercent) ? 1 : me?.privantes?.autoWithdrawMaxFeePercent
|
autoWithdrawMaxFeePercent: isNaN(me?.privantes?.autoWithdrawMaxFeePercent) ? 1 : me?.privantes?.autoWithdrawMaxFeePercent
|
||||||
}}
|
}}
|
||||||
schema={lnAddrAutowithdrawSchema}
|
schema={lnAddrAutowithdrawSchema({ me })}
|
||||||
onSubmit={async ({ autoWithdrawThreshold, autoWithdrawMaxFeePercent, ...values }) => {
|
onSubmit={async ({ autoWithdrawThreshold, autoWithdrawMaxFeePercent, ...values }) => {
|
||||||
try {
|
try {
|
||||||
await setAutoWithdraw({
|
await setAutoWithdraw({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user