amount input

This commit is contained in:
boufni95 2026-02-02 21:15:42 +00:00
parent 3255730ae2
commit f5eb1f3253
5 changed files with 10 additions and 8 deletions

View file

@ -1405,7 +1405,7 @@ The nostr server will send back a message response, and inside the body there wi
- __quotes__: ARRAY of: _[InvoiceSwapQuote](#InvoiceSwapQuote)_ - __quotes__: ARRAY of: _[InvoiceSwapQuote](#InvoiceSwapQuote)_
### InvoiceSwapRequest ### InvoiceSwapRequest
- __invoice__: _string_ - __amount_sats__: _number_
### InvoiceSwapsList ### InvoiceSwapsList
- __quotes__: ARRAY of: _[InvoiceSwapQuote](#InvoiceSwapQuote)_ - __quotes__: ARRAY of: _[InvoiceSwapQuote](#InvoiceSwapQuote)_

View file

@ -382,7 +382,7 @@ type InvoiceSwapQuoteList struct {
Quotes []InvoiceSwapQuote `json:"quotes"` Quotes []InvoiceSwapQuote `json:"quotes"`
} }
type InvoiceSwapRequest struct { type InvoiceSwapRequest struct {
Invoice string `json:"invoice"` Amount_sats int64 `json:"amount_sats"`
} }
type InvoiceSwapsList struct { type InvoiceSwapsList struct {
Quotes []InvoiceSwapQuote `json:"quotes"` Quotes []InvoiceSwapQuote `json:"quotes"`

View file

@ -2251,19 +2251,19 @@ export const InvoiceSwapQuoteListValidate = (o?: InvoiceSwapQuoteList, opts: Inv
} }
export type InvoiceSwapRequest = { export type InvoiceSwapRequest = {
invoice: string amount_sats: number
} }
export const InvoiceSwapRequestOptionalFields: [] = [] export const InvoiceSwapRequestOptionalFields: [] = []
export type InvoiceSwapRequestOptions = OptionsBaseMessage & { export type InvoiceSwapRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: [] checkOptionalsAreSet?: []
invoice_CustomCheck?: (v: string) => boolean amount_sats_CustomCheck?: (v: number) => boolean
} }
export const InvoiceSwapRequestValidate = (o?: InvoiceSwapRequest, opts: InvoiceSwapRequestOptions = {}, path: string = 'InvoiceSwapRequest::root.'): Error | null => { export const InvoiceSwapRequestValidate = (o?: InvoiceSwapRequest, opts: InvoiceSwapRequestOptions = {}, path: string = 'InvoiceSwapRequest::root.'): Error | null => {
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) if (typeof o.amount_sats !== 'number') return new Error(`${path}.amount_sats: is not a number`)
if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) if (opts.amount_sats_CustomCheck && !opts.amount_sats_CustomCheck(o.amount_sats)) return new Error(`${path}.amount_sats: custom check failed`)
return null return null
} }

View file

@ -834,7 +834,7 @@ message MessagingToken {
} }
message InvoiceSwapRequest { message InvoiceSwapRequest {
string invoice = 1; int64 amount_sats = 1;
} }
message InvoiceSwapQuote { message InvoiceSwapQuote {

View file

@ -6,6 +6,7 @@ import * as Types from '../../../proto/autogenerated/ts/types.js'
import LND from "../lnd/lnd.js"; import LND from "../lnd/lnd.js";
import SettingsManager from "./settingsManager.js"; import SettingsManager from "./settingsManager.js";
import { Swaps } from "../lnd/swaps/swaps.js"; import { Swaps } from "../lnd/swaps/swaps.js";
import { defaultInvoiceExpiry } from "../storage/paymentStorage.js";
export class AdminManager { export class AdminManager {
settings: SettingsManager settings: SettingsManager
storage: Storage storage: Storage
@ -265,7 +266,8 @@ export class AdminManager {
} }
async GetAdminInvoiceSwapQuotes(req: Types.InvoiceSwapRequest): Promise<Types.InvoiceSwapQuoteList> { async GetAdminInvoiceSwapQuotes(req: Types.InvoiceSwapRequest): Promise<Types.InvoiceSwapQuoteList> {
const quotes = await this.swaps.GetInvoiceSwapQuotes("admin", req.invoice) const invoice = await this.lnd.NewInvoice(req.amount_sats, "Admin Swap", defaultInvoiceExpiry, { useProvider: false, from: 'system' })
const quotes = await this.swaps.GetInvoiceSwapQuotes("admin", invoice.payRequest)
return { quotes } return { quotes }
} }