amount input
This commit is contained in:
parent
3255730ae2
commit
f5eb1f3253
5 changed files with 10 additions and 8 deletions
|
|
@ -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)_
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -834,7 +834,7 @@ message MessagingToken {
|
|||
}
|
||||
|
||||
message InvoiceSwapRequest {
|
||||
string invoice = 1;
|
||||
int64 amount_sats = 1;
|
||||
}
|
||||
|
||||
message InvoiceSwapQuote {
|
||||
|
|
|
|||
|
|
@ -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<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 }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue