address amt validation

This commit is contained in:
boufni95 2026-02-25 18:14:56 +00:00
parent f8fe946b40
commit 2c8d57dd6e
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

View file

@ -595,9 +595,15 @@ export default class {
async PayInternalAddress(ctx: Types.UserContext, req: Types.PayAddressRequest): Promise<Types.PayAddressResponse> { async PayInternalAddress(ctx: Types.UserContext, req: Types.PayAddressRequest): Promise<Types.PayAddressResponse> {
this.log("paying internal address") this.log("paying internal address")
let amount = req.amountSats
if (req.swap_operation_id) { if (req.swap_operation_id) {
const swap = await this.storage.paymentStorage.GetTransactionSwap(req.swap_operation_id, ctx.app_user_id)
amount = amount > 0 ? amount : swap?.invoice_amount || 0
await this.storage.paymentStorage.DeleteTransactionSwap(req.swap_operation_id) await this.storage.paymentStorage.DeleteTransactionSwap(req.swap_operation_id)
} }
if (amount <= 0) {
throw new Error("invalid tx amount")
}
const { blockHeight } = await this.lnd.GetInfo() const { blockHeight } = await this.lnd.GetInfo()
const app = await this.storage.applicationStorage.GetApplication(ctx.app_id) const app = await this.storage.applicationStorage.GetApplication(ctx.app_id)
const isManagedUser = ctx.user_id !== app.owner.user_id const isManagedUser = ctx.user_id !== app.owner.user_id

View file

@ -184,7 +184,7 @@ export default (mainHandler: Main): Types.ServerMethods => {
PayAddress: async ({ ctx, req }) => { PayAddress: async ({ ctx, req }) => {
const err = Types.PayAddressRequestValidate(req, { const err = Types.PayAddressRequestValidate(req, {
address_CustomCheck: addr => addr !== '', address_CustomCheck: addr => addr !== '',
amountSats_CustomCheck: amt => amt > 0, // amountSats_CustomCheck: amt => amt > 0,
// satsPerVByte_CustomCheck: spb => spb > 0 // satsPerVByte_CustomCheck: spb => spb > 0
}) })
if (err != null) throw new Error(err.message) if (err != null) throw new Error(err.message)