Merge branch 'provider-fixes' into swaps-test

This commit is contained in:
boufni95 2025-11-28 16:24:00 +00:00
commit 7dc49e3f50
37 changed files with 674 additions and 330 deletions

View file

@ -1104,6 +1104,13 @@ The nostr server will send back a message response, and inside the body there wi
- __nostr_pub__: _string_
- __user_identifier__: _string_
### BeaconData
- __avatarUrl__: _string_ *this field is optional
- __fees__: _[CumulativeFees](#CumulativeFees)_ *this field is optional
- __name__: _string_
- __nextRelay__: _string_ *this field is optional
- __type__: _string_
### BundleData
- __available_chunks__: ARRAY of: _number_
- __base_64_data__: ARRAY of: _string_
@ -1149,6 +1156,10 @@ The nostr server will send back a message response, and inside the body there wi
### CreateOneTimeInviteLinkResponse
- __invitation_link__: _string_
### CumulativeFees
- __networkFeeFixed__: _number_
- __serviceFeeBps__: _number_
### DebitAuthorization
- __authorized__: _boolean_
- __debit_id__: _string_
@ -1287,6 +1298,7 @@ The nostr server will send back a message response, and inside the body there wi
- __request_id__: _string_
### LiveUserOperation
- __latest_balance__: _number_
- __operation__: _[UserOperation](#UserOperation)_
### LndChannels
@ -1473,16 +1485,19 @@ The nostr server will send back a message response, and inside the body there wi
### PayAppUserInvoiceRequest
- __amount__: _number_
- __debit_npub__: _string_ *this field is optional
- __expected_fees__: _[CumulativeFees](#CumulativeFees)_ *this field is optional
- __invoice__: _string_
- __user_identifier__: _string_
### PayInvoiceRequest
- __amount__: _number_
- __debit_npub__: _string_ *this field is optional
- __expected_fees__: _[CumulativeFees](#CumulativeFees)_ *this field is optional
- __invoice__: _string_
### PayInvoiceResponse
- __amount_paid__: _number_
- __latest_balance__: _number_
- __network_fee__: _number_
- __operation_id__: _string_
- __preimage__: _string_
@ -1570,7 +1585,6 @@ The nostr server will send back a message response, and inside the body there wi
### TransactionSwapQuote
- __chain_fee_sats__: _number_
- __invoice_amount_sats__: _number_
- __routing_fee_reserve_sats__: _number_
- __service_fee_sats__: _number_
- __swap_fee_sats__: _number_
- __swap_operation_id__: _string_

View file

@ -177,6 +177,13 @@ type BannedAppUser struct {
Nostr_pub string `json:"nostr_pub"`
User_identifier string `json:"user_identifier"`
}
type BeaconData struct {
Avatarurl string `json:"avatarUrl"`
Fees *CumulativeFees `json:"fees"`
Name string `json:"name"`
Nextrelay string `json:"nextRelay"`
Type string `json:"type"`
}
type BundleData struct {
Available_chunks []int64 `json:"available_chunks"`
Base_64_data []string `json:"base_64_data"`
@ -222,6 +229,10 @@ type CreateOneTimeInviteLinkRequest struct {
type CreateOneTimeInviteLinkResponse struct {
Invitation_link string `json:"invitation_link"`
}
type CumulativeFees struct {
Networkfeefixed int64 `json:"networkFeeFixed"`
Servicefeebps int64 `json:"serviceFeeBps"`
}
type DebitAuthorization struct {
Authorized bool `json:"authorized"`
Debit_id string `json:"debit_id"`
@ -360,7 +371,8 @@ type LiveManageRequest struct {
Request_id string `json:"request_id"`
}
type LiveUserOperation struct {
Operation *UserOperation `json:"operation"`
Latest_balance int64 `json:"latest_balance"`
Operation *UserOperation `json:"operation"`
}
type LndChannels struct {
Open_channels []OpenChannel `json:"open_channels"`
@ -544,22 +556,25 @@ type PayAddressResponse struct {
Txid string `json:"txId"`
}
type PayAppUserInvoiceRequest struct {
Amount int64 `json:"amount"`
Debit_npub string `json:"debit_npub"`
Invoice string `json:"invoice"`
User_identifier string `json:"user_identifier"`
Amount int64 `json:"amount"`
Debit_npub string `json:"debit_npub"`
Expected_fees *CumulativeFees `json:"expected_fees"`
Invoice string `json:"invoice"`
User_identifier string `json:"user_identifier"`
}
type PayInvoiceRequest struct {
Amount int64 `json:"amount"`
Debit_npub string `json:"debit_npub"`
Invoice string `json:"invoice"`
Amount int64 `json:"amount"`
Debit_npub string `json:"debit_npub"`
Expected_fees *CumulativeFees `json:"expected_fees"`
Invoice string `json:"invoice"`
}
type PayInvoiceResponse struct {
Amount_paid int64 `json:"amount_paid"`
Network_fee int64 `json:"network_fee"`
Operation_id string `json:"operation_id"`
Preimage string `json:"preimage"`
Service_fee int64 `json:"service_fee"`
Amount_paid int64 `json:"amount_paid"`
Latest_balance int64 `json:"latest_balance"`
Network_fee int64 `json:"network_fee"`
Operation_id string `json:"operation_id"`
Preimage string `json:"preimage"`
Service_fee int64 `json:"service_fee"`
}
type PayerData struct {
Data map[string]string `json:"data"`
@ -641,13 +656,12 @@ type SingleMetricReq struct {
Request_id int64 `json:"request_id"`
}
type TransactionSwapQuote struct {
Chain_fee_sats int64 `json:"chain_fee_sats"`
Invoice_amount_sats int64 `json:"invoice_amount_sats"`
Routing_fee_reserve_sats int64 `json:"routing_fee_reserve_sats"`
Service_fee_sats int64 `json:"service_fee_sats"`
Swap_fee_sats int64 `json:"swap_fee_sats"`
Swap_operation_id string `json:"swap_operation_id"`
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
Chain_fee_sats int64 `json:"chain_fee_sats"`
Invoice_amount_sats int64 `json:"invoice_amount_sats"`
Service_fee_sats int64 `json:"service_fee_sats"`
Swap_fee_sats int64 `json:"swap_fee_sats"`
Swap_operation_id string `json:"swap_operation_id"`
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
}
type TransactionSwapRequest struct {
Transaction_amount_sats int64 `json:"transaction_amount_sats"`

View file

@ -983,6 +983,48 @@ export const BannedAppUserValidate = (o?: BannedAppUser, opts: BannedAppUserOpti
return null
}
export type BeaconData = {
avatarUrl?: string
fees?: CumulativeFees
name: string
nextRelay?: string
type: string
}
export type BeaconDataOptionalField = 'avatarUrl' | 'fees' | 'nextRelay'
export const BeaconDataOptionalFields: BeaconDataOptionalField[] = ['avatarUrl', 'fees', 'nextRelay']
export type BeaconDataOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: BeaconDataOptionalField[]
avatarUrl_CustomCheck?: (v?: string) => boolean
fees_Options?: CumulativeFeesOptions
name_CustomCheck?: (v: string) => boolean
nextRelay_CustomCheck?: (v?: string) => boolean
type_CustomCheck?: (v: string) => boolean
}
export const BeaconDataValidate = (o?: BeaconData, opts: BeaconDataOptions = {}, path: string = 'BeaconData::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 ((o.avatarUrl || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('avatarUrl')) && typeof o.avatarUrl !== 'string') return new Error(`${path}.avatarUrl: is not a string`)
if (opts.avatarUrl_CustomCheck && !opts.avatarUrl_CustomCheck(o.avatarUrl)) return new Error(`${path}.avatarUrl: custom check failed`)
if (typeof o.fees === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('fees')) {
const feesErr = CumulativeFeesValidate(o.fees, opts.fees_Options, `${path}.fees`)
if (feesErr !== null) return feesErr
}
if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`)
if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`)
if ((o.nextRelay || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('nextRelay')) && typeof o.nextRelay !== 'string') return new Error(`${path}.nextRelay: is not a string`)
if (opts.nextRelay_CustomCheck && !opts.nextRelay_CustomCheck(o.nextRelay)) return new Error(`${path}.nextRelay: custom check failed`)
if (typeof o.type !== 'string') return new Error(`${path}.type: is not a string`)
if (opts.type_CustomCheck && !opts.type_CustomCheck(o.type)) return new Error(`${path}.type: custom check failed`)
return null
}
export type BundleData = {
available_chunks: number[]
base_64_data: string[]
@ -1256,6 +1298,29 @@ export const CreateOneTimeInviteLinkResponseValidate = (o?: CreateOneTimeInviteL
return null
}
export type CumulativeFees = {
networkFeeFixed: number
serviceFeeBps: number
}
export const CumulativeFeesOptionalFields: [] = []
export type CumulativeFeesOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
networkFeeFixed_CustomCheck?: (v: number) => boolean
serviceFeeBps_CustomCheck?: (v: number) => boolean
}
export const CumulativeFeesValidate = (o?: CumulativeFees, opts: CumulativeFeesOptions = {}, path: string = 'CumulativeFees::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.networkFeeFixed !== 'number') return new Error(`${path}.networkFeeFixed: is not a number`)
if (opts.networkFeeFixed_CustomCheck && !opts.networkFeeFixed_CustomCheck(o.networkFeeFixed)) return new Error(`${path}.networkFeeFixed: custom check failed`)
if (typeof o.serviceFeeBps !== 'number') return new Error(`${path}.serviceFeeBps: is not a number`)
if (opts.serviceFeeBps_CustomCheck && !opts.serviceFeeBps_CustomCheck(o.serviceFeeBps)) return new Error(`${path}.serviceFeeBps: custom check failed`)
return null
}
export type DebitAuthorization = {
authorized: boolean
debit_id: string
@ -2093,17 +2158,22 @@ export const LiveManageRequestValidate = (o?: LiveManageRequest, opts: LiveManag
}
export type LiveUserOperation = {
latest_balance: number
operation: UserOperation
}
export const LiveUserOperationOptionalFields: [] = []
export type LiveUserOperationOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
latest_balance_CustomCheck?: (v: number) => boolean
operation_Options?: UserOperationOptions
}
export const LiveUserOperationValidate = (o?: LiveUserOperation, opts: LiveUserOperationOptions = {}, path: string = 'LiveUserOperation::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.latest_balance !== 'number') return new Error(`${path}.latest_balance: is not a number`)
if (opts.latest_balance_CustomCheck && !opts.latest_balance_CustomCheck(o.latest_balance)) return new Error(`${path}.latest_balance: custom check failed`)
const operationErr = UserOperationValidate(o.operation, opts.operation_Options, `${path}.operation`)
if (operationErr !== null) return operationErr
@ -3202,15 +3272,17 @@ export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddr
export type PayAppUserInvoiceRequest = {
amount: number
debit_npub?: string
expected_fees?: CumulativeFees
invoice: string
user_identifier: string
}
export type PayAppUserInvoiceRequestOptionalField = 'debit_npub'
export const PayAppUserInvoiceRequestOptionalFields: PayAppUserInvoiceRequestOptionalField[] = ['debit_npub']
export type PayAppUserInvoiceRequestOptionalField = 'debit_npub' | 'expected_fees'
export const PayAppUserInvoiceRequestOptionalFields: PayAppUserInvoiceRequestOptionalField[] = ['debit_npub', 'expected_fees']
export type PayAppUserInvoiceRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: PayAppUserInvoiceRequestOptionalField[]
amount_CustomCheck?: (v: number) => boolean
debit_npub_CustomCheck?: (v?: string) => boolean
expected_fees_Options?: CumulativeFeesOptions
invoice_CustomCheck?: (v: string) => boolean
user_identifier_CustomCheck?: (v: string) => boolean
}
@ -3224,6 +3296,12 @@ export const PayAppUserInvoiceRequestValidate = (o?: PayAppUserInvoiceRequest, o
if ((o.debit_npub || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('debit_npub')) && typeof o.debit_npub !== 'string') return new Error(`${path}.debit_npub: is not a string`)
if (opts.debit_npub_CustomCheck && !opts.debit_npub_CustomCheck(o.debit_npub)) return new Error(`${path}.debit_npub: custom check failed`)
if (typeof o.expected_fees === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('expected_fees')) {
const expected_feesErr = CumulativeFeesValidate(o.expected_fees, opts.expected_fees_Options, `${path}.expected_fees`)
if (expected_feesErr !== null) return expected_feesErr
}
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`)
@ -3236,14 +3314,16 @@ export const PayAppUserInvoiceRequestValidate = (o?: PayAppUserInvoiceRequest, o
export type PayInvoiceRequest = {
amount: number
debit_npub?: string
expected_fees?: CumulativeFees
invoice: string
}
export type PayInvoiceRequestOptionalField = 'debit_npub'
export const PayInvoiceRequestOptionalFields: PayInvoiceRequestOptionalField[] = ['debit_npub']
export type PayInvoiceRequestOptionalField = 'debit_npub' | 'expected_fees'
export const PayInvoiceRequestOptionalFields: PayInvoiceRequestOptionalField[] = ['debit_npub', 'expected_fees']
export type PayInvoiceRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: PayInvoiceRequestOptionalField[]
amount_CustomCheck?: (v: number) => boolean
debit_npub_CustomCheck?: (v?: string) => boolean
expected_fees_Options?: CumulativeFeesOptions
invoice_CustomCheck?: (v: string) => boolean
}
export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::root.'): Error | null => {
@ -3256,6 +3336,12 @@ export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoic
if ((o.debit_npub || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('debit_npub')) && typeof o.debit_npub !== 'string') return new Error(`${path}.debit_npub: is not a string`)
if (opts.debit_npub_CustomCheck && !opts.debit_npub_CustomCheck(o.debit_npub)) return new Error(`${path}.debit_npub: custom check failed`)
if (typeof o.expected_fees === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('expected_fees')) {
const expected_feesErr = CumulativeFeesValidate(o.expected_fees, opts.expected_fees_Options, `${path}.expected_fees`)
if (expected_feesErr !== null) return expected_feesErr
}
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`)
@ -3264,6 +3350,7 @@ export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoic
export type PayInvoiceResponse = {
amount_paid: number
latest_balance: number
network_fee: number
operation_id: string
preimage: string
@ -3273,6 +3360,7 @@ export const PayInvoiceResponseOptionalFields: [] = []
export type PayInvoiceResponseOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
amount_paid_CustomCheck?: (v: number) => boolean
latest_balance_CustomCheck?: (v: number) => boolean
network_fee_CustomCheck?: (v: number) => boolean
operation_id_CustomCheck?: (v: string) => boolean
preimage_CustomCheck?: (v: string) => boolean
@ -3285,6 +3373,9 @@ export const PayInvoiceResponseValidate = (o?: PayInvoiceResponse, opts: PayInvo
if (typeof o.amount_paid !== 'number') return new Error(`${path}.amount_paid: is not a number`)
if (opts.amount_paid_CustomCheck && !opts.amount_paid_CustomCheck(o.amount_paid)) return new Error(`${path}.amount_paid: custom check failed`)
if (typeof o.latest_balance !== 'number') return new Error(`${path}.latest_balance: is not a number`)
if (opts.latest_balance_CustomCheck && !opts.latest_balance_CustomCheck(o.latest_balance)) return new Error(`${path}.latest_balance: custom check failed`)
if (typeof o.network_fee !== 'number') return new Error(`${path}.network_fee: is not a number`)
if (opts.network_fee_CustomCheck && !opts.network_fee_CustomCheck(o.network_fee)) return new Error(`${path}.network_fee: custom check failed`)
@ -3757,7 +3848,6 @@ export const SingleMetricReqValidate = (o?: SingleMetricReq, opts: SingleMetricR
export type TransactionSwapQuote = {
chain_fee_sats: number
invoice_amount_sats: number
routing_fee_reserve_sats: number
service_fee_sats: number
swap_fee_sats: number
swap_operation_id: string
@ -3768,7 +3858,6 @@ export type TransactionSwapQuoteOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
chain_fee_sats_CustomCheck?: (v: number) => boolean
invoice_amount_sats_CustomCheck?: (v: number) => boolean
routing_fee_reserve_sats_CustomCheck?: (v: number) => boolean
service_fee_sats_CustomCheck?: (v: number) => boolean
swap_fee_sats_CustomCheck?: (v: number) => boolean
swap_operation_id_CustomCheck?: (v: string) => boolean
@ -3784,9 +3873,6 @@ export const TransactionSwapQuoteValidate = (o?: TransactionSwapQuote, opts: Tra
if (typeof o.invoice_amount_sats !== 'number') return new Error(`${path}.invoice_amount_sats: is not a number`)
if (opts.invoice_amount_sats_CustomCheck && !opts.invoice_amount_sats_CustomCheck(o.invoice_amount_sats)) return new Error(`${path}.invoice_amount_sats: custom check failed`)
if (typeof o.routing_fee_reserve_sats !== 'number') return new Error(`${path}.routing_fee_reserve_sats: is not a number`)
if (opts.routing_fee_reserve_sats_CustomCheck && !opts.routing_fee_reserve_sats_CustomCheck(o.routing_fee_reserve_sats)) return new Error(`${path}.routing_fee_reserve_sats: custom check failed`)
if (typeof o.service_fee_sats !== 'number') return new Error(`${path}.service_fee_sats: is not a number`)
if (opts.service_fee_sats_CustomCheck && !opts.service_fee_sats_CustomCheck(o.service_fee_sats)) return new Error(`${path}.service_fee_sats: custom check failed`)