From f5eb1f3253e5a8e716c7304ae42de372dff31ceb Mon Sep 17 00:00:00 2001 From: boufni95 Date: Mon, 2 Feb 2026 21:15:42 +0000 Subject: [PATCH] amount input --- proto/autogenerated/client.md | 2 +- proto/autogenerated/go/types.go | 2 +- proto/autogenerated/ts/types.ts | 8 ++++---- proto/service/structs.proto | 2 +- src/services/main/adminManager.ts | 4 +++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index 60dd284e..75b44d4e 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -1405,7 +1405,7 @@ The nostr server will send back a message response, and inside the body there wi - __quotes__: ARRAY of: _[InvoiceSwapQuote](#InvoiceSwapQuote)_ ### InvoiceSwapRequest - - __invoice__: _string_ + - __amount_sats__: _number_ ### InvoiceSwapsList - __quotes__: ARRAY of: _[InvoiceSwapQuote](#InvoiceSwapQuote)_ diff --git a/proto/autogenerated/go/types.go b/proto/autogenerated/go/types.go index d5b21b2f..2c79cb0a 100644 --- a/proto/autogenerated/go/types.go +++ b/proto/autogenerated/go/types.go @@ -382,7 +382,7 @@ type InvoiceSwapQuoteList struct { Quotes []InvoiceSwapQuote `json:"quotes"` } type InvoiceSwapRequest struct { - Invoice string `json:"invoice"` + Amount_sats int64 `json:"amount_sats"` } type InvoiceSwapsList struct { Quotes []InvoiceSwapQuote `json:"quotes"` diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index a738a06c..17fec2b1 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -2251,19 +2251,19 @@ export const InvoiceSwapQuoteListValidate = (o?: InvoiceSwapQuoteList, opts: Inv } export type InvoiceSwapRequest = { - invoice: string + amount_sats: number } export const InvoiceSwapRequestOptionalFields: [] = [] export type InvoiceSwapRequestOptions = OptionsBaseMessage & { 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 => { 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.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + if (typeof o.amount_sats !== 'number') return new Error(`${path}.amount_sats: is not a number`) + if (opts.amount_sats_CustomCheck && !opts.amount_sats_CustomCheck(o.amount_sats)) return new Error(`${path}.amount_sats: custom check failed`) return null } diff --git a/proto/service/structs.proto b/proto/service/structs.proto index 5b25c699..2ce6adc3 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -834,7 +834,7 @@ message MessagingToken { } message InvoiceSwapRequest { - string invoice = 1; + int64 amount_sats = 1; } message InvoiceSwapQuote { diff --git a/src/services/main/adminManager.ts b/src/services/main/adminManager.ts index 8fae2b5d..1c54d12f 100644 --- a/src/services/main/adminManager.ts +++ b/src/services/main/adminManager.ts @@ -6,6 +6,7 @@ import * as Types from '../../../proto/autogenerated/ts/types.js' import LND from "../lnd/lnd.js"; import SettingsManager from "./settingsManager.js"; import { Swaps } from "../lnd/swaps/swaps.js"; +import { defaultInvoiceExpiry } from "../storage/paymentStorage.js"; export class AdminManager { settings: SettingsManager storage: Storage @@ -265,7 +266,8 @@ export class AdminManager { } async GetAdminInvoiceSwapQuotes(req: Types.InvoiceSwapRequest): Promise { - 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 } }