assets and liabilities

This commit is contained in:
boufni95 2026-02-26 21:54:28 +00:00
parent e411b7aa7f
commit ef14ec9ddf
No known key found for this signature in database
20 changed files with 843 additions and 11 deletions

View file

@ -108,6 +108,11 @@ The nostr server will send back a message response, and inside the body there wi
- input: [AppsMetricsRequest](#AppsMetricsRequest)
- output: [AppsMetrics](#AppsMetrics)
- GetAssetsAndLiabilities
- auth type: __Admin__
- input: [AssetsAndLiabilitiesReq](#AssetsAndLiabilitiesReq)
- output: [AssetsAndLiabilities](#AssetsAndLiabilities)
- GetBundleMetrics
- auth type: __Metrics__
- input: [LatestBundleMetricReq](#LatestBundleMetricReq)
@ -602,6 +607,13 @@ The nostr server will send back a message response, and inside the body there wi
- input: [AppsMetricsRequest](#AppsMetricsRequest)
- output: [AppsMetrics](#AppsMetrics)
- GetAssetsAndLiabilities
- auth type: __Admin__
- http method: __post__
- http route: __/api/admin/assets/liabilities__
- input: [AssetsAndLiabilitiesReq](#AssetsAndLiabilitiesReq)
- output: [AssetsAndLiabilities](#AssetsAndLiabilities)
- GetBundleMetrics
- auth type: __Metrics__
- http method: __post__
@ -1186,6 +1198,21 @@ The nostr server will send back a message response, and inside the body there wi
- __include_operations__: _boolean_ *this field is optional
- __to_unix__: _number_ *this field is optional
### AssetOperation
- __amount__: _number_
- __tracked__: _[TrackedOperation](#TrackedOperation)_ *this field is optional
- __ts__: _number_
### AssetsAndLiabilities
- __liquidity_providers__: ARRAY of: _[LiquidityAssetProvider](#LiquidityAssetProvider)_
- __lnds__: ARRAY of: _[LndAssetProvider](#LndAssetProvider)_
- __users_balance__: _number_
### AssetsAndLiabilitiesReq
- __limit_invoices__: _number_ *this field is optional
- __limit_payments__: _number_ *this field is optional
- __limit_providers__: _number_ *this field is optional
### AuthApp
- __app__: _[Application](#Application)_
- __auth_token__: _string_
@ -1421,6 +1448,10 @@ The nostr server will send back a message response, and inside the body there wi
### LinkNPubThroughTokenRequest
- __token__: _string_
### LiquidityAssetProvider
- __pubkey__: _string_
- __tracked__: _[TrackedLiquidityProvider](#TrackedLiquidityProvider)_ *this field is optional
### LiveDebitRequest
- __debit__: _[LiveDebitRequest_debit](#LiveDebitRequest_debit)_
- __npub__: _string_
@ -1434,6 +1465,10 @@ The nostr server will send back a message response, and inside the body there wi
- __latest_balance__: _number_
- __operation__: _[UserOperation](#UserOperation)_
### LndAssetProvider
- __pubkey__: _string_
- __tracked__: _[TrackedLndProvider](#TrackedLndProvider)_ *this field is optional
### LndChannels
- __open_channels__: ARRAY of: _[OpenChannel](#OpenChannel)_
@ -1738,6 +1773,25 @@ The nostr server will send back a message response, and inside the body there wi
- __page__: _number_
- __request_id__: _number_ *this field is optional
### TrackedLiquidityProvider
- __balance__: _number_
- __invoices__: ARRAY of: _[AssetOperation](#AssetOperation)_
- __payments__: ARRAY of: _[AssetOperation](#AssetOperation)_
### TrackedLndProvider
- __channels_balance__: _number_
- __confirmed_balance__: _number_
- __incoming_tx__: ARRAY of: _[AssetOperation](#AssetOperation)_
- __invoices__: ARRAY of: _[AssetOperation](#AssetOperation)_
- __outgoing_tx__: ARRAY of: _[AssetOperation](#AssetOperation)_
- __payments__: ARRAY of: _[AssetOperation](#AssetOperation)_
- __unconfirmed_balance__: _number_
### TrackedOperation
- __amount__: _number_
- __ts__: _number_
- __type__: _[TrackedOperationType](#TrackedOperationType)_
### TransactionSwapQuote
- __chain_fee_sats__: _number_
- __invoice_amount_sats__: _number_
@ -1870,6 +1924,10 @@ The nostr server will send back a message response, and inside the body there wi
- __BUNDLE_METRIC__
- __USAGE_METRIC__
### TrackedOperationType
- __ROOT__
- __USER__
### UserOperationType
- __INCOMING_INVOICE__
- __INCOMING_TX__

View file

@ -80,6 +80,7 @@ type Client struct {
GetAppUser func(req GetAppUserRequest) (*AppUser, error)
GetAppUserLNURLInfo func(req GetAppUserLNURLInfoRequest) (*LnurlPayInfoResponse, error)
GetAppsMetrics func(req AppsMetricsRequest) (*AppsMetrics, error)
GetAssetsAndLiabilities func(req AssetsAndLiabilitiesReq) (*AssetsAndLiabilities, error)
GetBundleMetrics func(req LatestBundleMetricReq) (*BundleMetrics, error)
GetDebitAuthorizations func() (*DebitAuthorizations, error)
GetErrorStats func() (*ErrorStats, error)
@ -842,6 +843,35 @@ func NewClient(params ClientParams) *Client {
}
return &res, nil
},
GetAssetsAndLiabilities: func(req AssetsAndLiabilitiesReq) (*AssetsAndLiabilities, error) {
auth, err := params.RetrieveAdminAuth()
if err != nil {
return nil, err
}
finalRoute := "/api/admin/assets/liabilities"
body, err := json.Marshal(req)
if err != nil {
return nil, err
}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return nil, err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return nil, err
}
if result.Status == "ERROR" {
return nil, fmt.Errorf(result.Reason)
}
res := AssetsAndLiabilities{}
err = json.Unmarshal(resBody, &res)
if err != nil {
return nil, err
}
return &res, nil
},
GetBundleMetrics: func(req LatestBundleMetricReq) (*BundleMetrics, error) {
auth, err := params.RetrieveMetricsAuth()
if err != nil {

View file

@ -79,6 +79,13 @@ const (
USAGE_METRIC SingleMetricType = "USAGE_METRIC"
)
type TrackedOperationType string
const (
ROOT TrackedOperationType = "ROOT"
USER TrackedOperationType = "USER"
)
type UserOperationType string
const (
@ -163,6 +170,21 @@ type AppsMetricsRequest struct {
Include_operations bool `json:"include_operations"`
To_unix int64 `json:"to_unix"`
}
type AssetOperation struct {
Amount int64 `json:"amount"`
Tracked *TrackedOperation `json:"tracked"`
Ts int64 `json:"ts"`
}
type AssetsAndLiabilities struct {
Liquidity_providers []LiquidityAssetProvider `json:"liquidity_providers"`
Lnds []LndAssetProvider `json:"lnds"`
Users_balance int64 `json:"users_balance"`
}
type AssetsAndLiabilitiesReq struct {
Limit_invoices int64 `json:"limit_invoices"`
Limit_payments int64 `json:"limit_payments"`
Limit_providers int64 `json:"limit_providers"`
}
type AuthApp struct {
App *Application `json:"app"`
Auth_token string `json:"auth_token"`
@ -398,6 +420,10 @@ type LatestUsageMetricReq struct {
type LinkNPubThroughTokenRequest struct {
Token string `json:"token"`
}
type LiquidityAssetProvider struct {
Pubkey string `json:"pubkey"`
Tracked *TrackedLiquidityProvider `json:"tracked"`
}
type LiveDebitRequest struct {
Debit *LiveDebitRequest_debit `json:"debit"`
Npub string `json:"npub"`
@ -411,6 +437,10 @@ type LiveUserOperation struct {
Latest_balance int64 `json:"latest_balance"`
Operation *UserOperation `json:"operation"`
}
type LndAssetProvider struct {
Pubkey string `json:"pubkey"`
Tracked *TrackedLndProvider `json:"tracked"`
}
type LndChannels struct {
Open_channels []OpenChannel `json:"open_channels"`
}
@ -715,6 +745,25 @@ type SingleMetricReq struct {
Page int64 `json:"page"`
Request_id int64 `json:"request_id"`
}
type TrackedLiquidityProvider struct {
Balance int64 `json:"balance"`
Invoices []AssetOperation `json:"invoices"`
Payments []AssetOperation `json:"payments"`
}
type TrackedLndProvider struct {
Channels_balance int64 `json:"channels_balance"`
Confirmed_balance int64 `json:"confirmed_balance"`
Incoming_tx []AssetOperation `json:"incoming_tx"`
Invoices []AssetOperation `json:"invoices"`
Outgoing_tx []AssetOperation `json:"outgoing_tx"`
Payments []AssetOperation `json:"payments"`
Unconfirmed_balance int64 `json:"unconfirmed_balance"`
}
type TrackedOperation struct {
Amount int64 `json:"amount"`
Ts int64 `json:"ts"`
Type TrackedOperationType `json:"type"`
}
type TransactionSwapQuote struct {
Chain_fee_sats int64 `json:"chain_fee_sats"`
Invoice_amount_sats int64 `json:"invoice_amount_sats"`

View file

@ -998,6 +998,28 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
})
if (!opts.allowNotImplementedMethods && !methods.GetAssetsAndLiabilities) throw new Error('method: GetAssetsAndLiabilities is not implemented')
app.post('/api/admin/assets/liabilities', async (req, res) => {
const info: Types.RequestInfo = { rpcName: 'GetAssetsAndLiabilities', batch: false, nostr: false, batchSize: 0}
const stats: Types.RequestStats = { startMs:req.startTimeMs || 0, start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n }
let authCtx: Types.AuthContext = {}
try {
if (!methods.GetAssetsAndLiabilities) throw new Error('method: GetAssetsAndLiabilities is not implemented')
const authContext = await opts.AdminAuthGuard(req.headers['authorization'])
authCtx = authContext
stats.guard = process.hrtime.bigint()
const request = req.body
const error = Types.AssetsAndLiabilitiesReqValidate(request)
stats.validate = process.hrtime.bigint()
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger, { ...info, ...stats, ...authContext }, opts.metricsCallback)
const query = req.query
const params = req.params
const response = await methods.GetAssetsAndLiabilities({rpcName:'GetAssetsAndLiabilities', ctx:authContext , req: request})
stats.handle = process.hrtime.bigint()
res.json({status: 'OK', ...response})
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
})
if (!opts.allowNotImplementedMethods && !methods.GetBundleMetrics) throw new Error('method: GetBundleMetrics is not implemented')
app.post('/api/reports/bundle', async (req, res) => {
const info: Types.RequestInfo = { rpcName: 'GetBundleMetrics', batch: false, nostr: false, batchSize: 0}

View file

@ -357,6 +357,20 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetAssetsAndLiabilities: async (request: Types.AssetsAndLiabilitiesReq): Promise<ResultError | ({ status: 'OK' }& Types.AssetsAndLiabilities)> => {
const auth = await params.retrieveAdminAuth()
if (auth === null) throw new Error('retrieveAdminAuth() returned null')
let finalRoute = '/api/admin/assets/liabilities'
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.AssetsAndLiabilitiesValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetBundleMetrics: async (request: Types.LatestBundleMetricReq): Promise<ResultError | ({ status: 'OK' }& Types.BundleMetrics)> => {
const auth = await params.retrieveMetricsAuth()
if (auth === null) throw new Error('retrieveMetricsAuth() returned null')

View file

@ -275,6 +275,21 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetAssetsAndLiabilities: async (request: Types.AssetsAndLiabilitiesReq): Promise<ResultError | ({ status: 'OK' }& Types.AssetsAndLiabilities)> => {
const auth = await params.retrieveNostrAdminAuth()
if (auth === null) throw new Error('retrieveNostrAdminAuth() returned null')
const nostrRequest: NostrRequest = {}
nostrRequest.body = request
const data = await send(params.pubDestination, {rpcName:'GetAssetsAndLiabilities',authIdentifier:auth, ...nostrRequest })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.AssetsAndLiabilitiesValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetBundleMetrics: async (request: Types.LatestBundleMetricReq): Promise<ResultError | ({ status: 'OK' }& Types.BundleMetrics)> => {
const auth = await params.retrieveNostrMetricsAuth()
if (auth === null) throw new Error('retrieveNostrMetricsAuth() returned null')

View file

@ -735,6 +735,22 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
break
case 'GetAssetsAndLiabilities':
try {
if (!methods.GetAssetsAndLiabilities) throw new Error('method: GetAssetsAndLiabilities is not implemented')
const authContext = await opts.NostrAdminAuthGuard(req.appId, req.authIdentifier)
stats.guard = process.hrtime.bigint()
authCtx = authContext
const request = req.body
const error = Types.AssetsAndLiabilitiesReqValidate(request)
stats.validate = process.hrtime.bigint()
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback)
const response = await methods.GetAssetsAndLiabilities({rpcName:'GetAssetsAndLiabilities', ctx:authContext , req: request})
stats.handle = process.hrtime.bigint()
res({status: 'OK', ...response})
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
break
case 'GetBundleMetrics':
try {
if (!methods.GetBundleMetrics) throw new Error('method: GetBundleMetrics is not implemented')

View file

@ -7,8 +7,8 @@ export type RequestMetric = AuthContext & RequestInfo & RequestStats & { error?:
export type AdminContext = {
admin_id: string
}
export type AdminMethodInputs = AddApp_Input | AddPeer_Input | AuthApp_Input | BanUser_Input | CloseChannel_Input | CreateOneTimeInviteLink_Input | GetAdminInvoiceSwapQuotes_Input | GetAdminTransactionSwapQuotes_Input | GetInviteLinkState_Input | GetSeed_Input | ListAdminInvoiceSwaps_Input | ListAdminTxSwaps_Input | ListChannels_Input | LndGetInfo_Input | OpenChannel_Input | PayAdminInvoiceSwap_Input | PayAdminTransactionSwap_Input | RefundAdminInvoiceSwap_Input | UpdateChannelPolicy_Input
export type AdminMethodOutputs = AddApp_Output | AddPeer_Output | AuthApp_Output | BanUser_Output | CloseChannel_Output | CreateOneTimeInviteLink_Output | GetAdminInvoiceSwapQuotes_Output | GetAdminTransactionSwapQuotes_Output | GetInviteLinkState_Output | GetSeed_Output | ListAdminInvoiceSwaps_Output | ListAdminTxSwaps_Output | ListChannels_Output | LndGetInfo_Output | OpenChannel_Output | PayAdminInvoiceSwap_Output | PayAdminTransactionSwap_Output | RefundAdminInvoiceSwap_Output | UpdateChannelPolicy_Output
export type AdminMethodInputs = AddApp_Input | AddPeer_Input | AuthApp_Input | BanUser_Input | CloseChannel_Input | CreateOneTimeInviteLink_Input | GetAdminInvoiceSwapQuotes_Input | GetAdminTransactionSwapQuotes_Input | GetAssetsAndLiabilities_Input | GetInviteLinkState_Input | GetSeed_Input | ListAdminInvoiceSwaps_Input | ListAdminTxSwaps_Input | ListChannels_Input | LndGetInfo_Input | OpenChannel_Input | PayAdminInvoiceSwap_Input | PayAdminTransactionSwap_Input | RefundAdminInvoiceSwap_Input | UpdateChannelPolicy_Input
export type AdminMethodOutputs = AddApp_Output | AddPeer_Output | AuthApp_Output | BanUser_Output | CloseChannel_Output | CreateOneTimeInviteLink_Output | GetAdminInvoiceSwapQuotes_Output | GetAdminTransactionSwapQuotes_Output | GetAssetsAndLiabilities_Output | GetInviteLinkState_Output | GetSeed_Output | ListAdminInvoiceSwaps_Output | ListAdminTxSwaps_Output | ListChannels_Output | LndGetInfo_Output | OpenChannel_Output | PayAdminInvoiceSwap_Output | PayAdminTransactionSwap_Output | RefundAdminInvoiceSwap_Output | UpdateChannelPolicy_Output
export type AppContext = {
app_id: string
}
@ -117,6 +117,9 @@ export type GetAppUserLNURLInfo_Output = ResultError | ({ status: 'OK' } & Lnurl
export type GetAppsMetrics_Input = {rpcName:'GetAppsMetrics', req: AppsMetricsRequest}
export type GetAppsMetrics_Output = ResultError | ({ status: 'OK' } & AppsMetrics)
export type GetAssetsAndLiabilities_Input = {rpcName:'GetAssetsAndLiabilities', req: AssetsAndLiabilitiesReq}
export type GetAssetsAndLiabilities_Output = ResultError | ({ status: 'OK' } & AssetsAndLiabilities)
export type GetBundleMetrics_Input = {rpcName:'GetBundleMetrics', req: LatestBundleMetricReq}
export type GetBundleMetrics_Output = ResultError | ({ status: 'OK' } & BundleMetrics)
@ -375,6 +378,7 @@ export type ServerMethods = {
GetAppUser?: (req: GetAppUser_Input & {ctx: AppContext }) => Promise<AppUser>
GetAppUserLNURLInfo?: (req: GetAppUserLNURLInfo_Input & {ctx: AppContext }) => Promise<LnurlPayInfoResponse>
GetAppsMetrics?: (req: GetAppsMetrics_Input & {ctx: MetricsContext }) => Promise<AppsMetrics>
GetAssetsAndLiabilities?: (req: GetAssetsAndLiabilities_Input & {ctx: AdminContext }) => Promise<AssetsAndLiabilities>
GetBundleMetrics?: (req: GetBundleMetrics_Input & {ctx: MetricsContext }) => Promise<BundleMetrics>
GetDebitAuthorizations?: (req: GetDebitAuthorizations_Input & {ctx: UserContext }) => Promise<DebitAuthorizations>
GetErrorStats?: (req: GetErrorStats_Input & {ctx: MetricsContext }) => Promise<ErrorStats>
@ -481,6 +485,14 @@ export const enumCheckSingleMetricType = (e?: SingleMetricType): boolean => {
for (const v in SingleMetricType) if (e === v) return true
return false
}
export enum TrackedOperationType {
ROOT = 'ROOT',
USER = 'USER',
}
export const enumCheckTrackedOperationType = (e?: TrackedOperationType): boolean => {
for (const v in TrackedOperationType) if (e === v) return true
return false
}
export enum UserOperationType {
INCOMING_INVOICE = 'INCOMING_INVOICE',
INCOMING_TX = 'INCOMING_TX',
@ -929,6 +941,105 @@ export const AppsMetricsRequestValidate = (o?: AppsMetricsRequest, opts: AppsMet
return null
}
export type AssetOperation = {
amount: number
tracked?: TrackedOperation
ts: number
}
export type AssetOperationOptionalField = 'tracked'
export const AssetOperationOptionalFields: AssetOperationOptionalField[] = ['tracked']
export type AssetOperationOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: AssetOperationOptionalField[]
amount_CustomCheck?: (v: number) => boolean
tracked_Options?: TrackedOperationOptions
ts_CustomCheck?: (v: number) => boolean
}
export const AssetOperationValidate = (o?: AssetOperation, opts: AssetOperationOptions = {}, path: string = 'AssetOperation::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.amount !== 'number') return new Error(`${path}.amount: is not a number`)
if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`)
if (typeof o.tracked === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('tracked')) {
const trackedErr = TrackedOperationValidate(o.tracked, opts.tracked_Options, `${path}.tracked`)
if (trackedErr !== null) return trackedErr
}
if (typeof o.ts !== 'number') return new Error(`${path}.ts: is not a number`)
if (opts.ts_CustomCheck && !opts.ts_CustomCheck(o.ts)) return new Error(`${path}.ts: custom check failed`)
return null
}
export type AssetsAndLiabilities = {
liquidity_providers: LiquidityAssetProvider[]
lnds: LndAssetProvider[]
users_balance: number
}
export const AssetsAndLiabilitiesOptionalFields: [] = []
export type AssetsAndLiabilitiesOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
liquidity_providers_ItemOptions?: LiquidityAssetProviderOptions
liquidity_providers_CustomCheck?: (v: LiquidityAssetProvider[]) => boolean
lnds_ItemOptions?: LndAssetProviderOptions
lnds_CustomCheck?: (v: LndAssetProvider[]) => boolean
users_balance_CustomCheck?: (v: number) => boolean
}
export const AssetsAndLiabilitiesValidate = (o?: AssetsAndLiabilities, opts: AssetsAndLiabilitiesOptions = {}, path: string = 'AssetsAndLiabilities::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 (!Array.isArray(o.liquidity_providers)) return new Error(`${path}.liquidity_providers: is not an array`)
for (let index = 0; index < o.liquidity_providers.length; index++) {
const liquidity_providersErr = LiquidityAssetProviderValidate(o.liquidity_providers[index], opts.liquidity_providers_ItemOptions, `${path}.liquidity_providers[${index}]`)
if (liquidity_providersErr !== null) return liquidity_providersErr
}
if (opts.liquidity_providers_CustomCheck && !opts.liquidity_providers_CustomCheck(o.liquidity_providers)) return new Error(`${path}.liquidity_providers: custom check failed`)
if (!Array.isArray(o.lnds)) return new Error(`${path}.lnds: is not an array`)
for (let index = 0; index < o.lnds.length; index++) {
const lndsErr = LndAssetProviderValidate(o.lnds[index], opts.lnds_ItemOptions, `${path}.lnds[${index}]`)
if (lndsErr !== null) return lndsErr
}
if (opts.lnds_CustomCheck && !opts.lnds_CustomCheck(o.lnds)) return new Error(`${path}.lnds: custom check failed`)
if (typeof o.users_balance !== 'number') return new Error(`${path}.users_balance: is not a number`)
if (opts.users_balance_CustomCheck && !opts.users_balance_CustomCheck(o.users_balance)) return new Error(`${path}.users_balance: custom check failed`)
return null
}
export type AssetsAndLiabilitiesReq = {
limit_invoices?: number
limit_payments?: number
limit_providers?: number
}
export type AssetsAndLiabilitiesReqOptionalField = 'limit_invoices' | 'limit_payments' | 'limit_providers'
export const AssetsAndLiabilitiesReqOptionalFields: AssetsAndLiabilitiesReqOptionalField[] = ['limit_invoices', 'limit_payments', 'limit_providers']
export type AssetsAndLiabilitiesReqOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: AssetsAndLiabilitiesReqOptionalField[]
limit_invoices_CustomCheck?: (v?: number) => boolean
limit_payments_CustomCheck?: (v?: number) => boolean
limit_providers_CustomCheck?: (v?: number) => boolean
}
export const AssetsAndLiabilitiesReqValidate = (o?: AssetsAndLiabilitiesReq, opts: AssetsAndLiabilitiesReqOptions = {}, path: string = 'AssetsAndLiabilitiesReq::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.limit_invoices || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('limit_invoices')) && typeof o.limit_invoices !== 'number') return new Error(`${path}.limit_invoices: is not a number`)
if (opts.limit_invoices_CustomCheck && !opts.limit_invoices_CustomCheck(o.limit_invoices)) return new Error(`${path}.limit_invoices: custom check failed`)
if ((o.limit_payments || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('limit_payments')) && typeof o.limit_payments !== 'number') return new Error(`${path}.limit_payments: is not a number`)
if (opts.limit_payments_CustomCheck && !opts.limit_payments_CustomCheck(o.limit_payments)) return new Error(`${path}.limit_payments: custom check failed`)
if ((o.limit_providers || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('limit_providers')) && typeof o.limit_providers !== 'number') return new Error(`${path}.limit_providers: is not a number`)
if (opts.limit_providers_CustomCheck && !opts.limit_providers_CustomCheck(o.limit_providers)) return new Error(`${path}.limit_providers: custom check failed`)
return null
}
export type AuthApp = {
app: Application
auth_token: string
@ -2358,6 +2469,33 @@ export const LinkNPubThroughTokenRequestValidate = (o?: LinkNPubThroughTokenRequ
return null
}
export type LiquidityAssetProvider = {
pubkey: string
tracked?: TrackedLiquidityProvider
}
export type LiquidityAssetProviderOptionalField = 'tracked'
export const LiquidityAssetProviderOptionalFields: LiquidityAssetProviderOptionalField[] = ['tracked']
export type LiquidityAssetProviderOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: LiquidityAssetProviderOptionalField[]
pubkey_CustomCheck?: (v: string) => boolean
tracked_Options?: TrackedLiquidityProviderOptions
}
export const LiquidityAssetProviderValidate = (o?: LiquidityAssetProvider, opts: LiquidityAssetProviderOptions = {}, path: string = 'LiquidityAssetProvider::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.pubkey !== 'string') return new Error(`${path}.pubkey: is not a string`)
if (opts.pubkey_CustomCheck && !opts.pubkey_CustomCheck(o.pubkey)) return new Error(`${path}.pubkey: custom check failed`)
if (typeof o.tracked === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('tracked')) {
const trackedErr = TrackedLiquidityProviderValidate(o.tracked, opts.tracked_Options, `${path}.tracked`)
if (trackedErr !== null) return trackedErr
}
return null
}
export type LiveDebitRequest = {
debit: LiveDebitRequest_debit
npub: string
@ -2434,6 +2572,33 @@ export const LiveUserOperationValidate = (o?: LiveUserOperation, opts: LiveUserO
return null
}
export type LndAssetProvider = {
pubkey: string
tracked?: TrackedLndProvider
}
export type LndAssetProviderOptionalField = 'tracked'
export const LndAssetProviderOptionalFields: LndAssetProviderOptionalField[] = ['tracked']
export type LndAssetProviderOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: LndAssetProviderOptionalField[]
pubkey_CustomCheck?: (v: string) => boolean
tracked_Options?: TrackedLndProviderOptions
}
export const LndAssetProviderValidate = (o?: LndAssetProvider, opts: LndAssetProviderOptions = {}, path: string = 'LndAssetProvider::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.pubkey !== 'string') return new Error(`${path}.pubkey: is not a string`)
if (opts.pubkey_CustomCheck && !opts.pubkey_CustomCheck(o.pubkey)) return new Error(`${path}.pubkey: custom check failed`)
if (typeof o.tracked === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('tracked')) {
const trackedErr = TrackedLndProviderValidate(o.tracked, opts.tracked_Options, `${path}.tracked`)
if (trackedErr !== null) return trackedErr
}
return null
}
export type LndChannels = {
open_channels: OpenChannel[]
}
@ -4230,6 +4395,140 @@ export const SingleMetricReqValidate = (o?: SingleMetricReq, opts: SingleMetricR
return null
}
export type TrackedLiquidityProvider = {
balance: number
invoices: AssetOperation[]
payments: AssetOperation[]
}
export const TrackedLiquidityProviderOptionalFields: [] = []
export type TrackedLiquidityProviderOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
balance_CustomCheck?: (v: number) => boolean
invoices_ItemOptions?: AssetOperationOptions
invoices_CustomCheck?: (v: AssetOperation[]) => boolean
payments_ItemOptions?: AssetOperationOptions
payments_CustomCheck?: (v: AssetOperation[]) => boolean
}
export const TrackedLiquidityProviderValidate = (o?: TrackedLiquidityProvider, opts: TrackedLiquidityProviderOptions = {}, path: string = 'TrackedLiquidityProvider::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.balance !== 'number') return new Error(`${path}.balance: is not a number`)
if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`)
if (!Array.isArray(o.invoices)) return new Error(`${path}.invoices: is not an array`)
for (let index = 0; index < o.invoices.length; index++) {
const invoicesErr = AssetOperationValidate(o.invoices[index], opts.invoices_ItemOptions, `${path}.invoices[${index}]`)
if (invoicesErr !== null) return invoicesErr
}
if (opts.invoices_CustomCheck && !opts.invoices_CustomCheck(o.invoices)) return new Error(`${path}.invoices: custom check failed`)
if (!Array.isArray(o.payments)) return new Error(`${path}.payments: is not an array`)
for (let index = 0; index < o.payments.length; index++) {
const paymentsErr = AssetOperationValidate(o.payments[index], opts.payments_ItemOptions, `${path}.payments[${index}]`)
if (paymentsErr !== null) return paymentsErr
}
if (opts.payments_CustomCheck && !opts.payments_CustomCheck(o.payments)) return new Error(`${path}.payments: custom check failed`)
return null
}
export type TrackedLndProvider = {
channels_balance: number
confirmed_balance: number
incoming_tx: AssetOperation[]
invoices: AssetOperation[]
outgoing_tx: AssetOperation[]
payments: AssetOperation[]
unconfirmed_balance: number
}
export const TrackedLndProviderOptionalFields: [] = []
export type TrackedLndProviderOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
channels_balance_CustomCheck?: (v: number) => boolean
confirmed_balance_CustomCheck?: (v: number) => boolean
incoming_tx_ItemOptions?: AssetOperationOptions
incoming_tx_CustomCheck?: (v: AssetOperation[]) => boolean
invoices_ItemOptions?: AssetOperationOptions
invoices_CustomCheck?: (v: AssetOperation[]) => boolean
outgoing_tx_ItemOptions?: AssetOperationOptions
outgoing_tx_CustomCheck?: (v: AssetOperation[]) => boolean
payments_ItemOptions?: AssetOperationOptions
payments_CustomCheck?: (v: AssetOperation[]) => boolean
unconfirmed_balance_CustomCheck?: (v: number) => boolean
}
export const TrackedLndProviderValidate = (o?: TrackedLndProvider, opts: TrackedLndProviderOptions = {}, path: string = 'TrackedLndProvider::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.channels_balance !== 'number') return new Error(`${path}.channels_balance: is not a number`)
if (opts.channels_balance_CustomCheck && !opts.channels_balance_CustomCheck(o.channels_balance)) return new Error(`${path}.channels_balance: custom check failed`)
if (typeof o.confirmed_balance !== 'number') return new Error(`${path}.confirmed_balance: is not a number`)
if (opts.confirmed_balance_CustomCheck && !opts.confirmed_balance_CustomCheck(o.confirmed_balance)) return new Error(`${path}.confirmed_balance: custom check failed`)
if (!Array.isArray(o.incoming_tx)) return new Error(`${path}.incoming_tx: is not an array`)
for (let index = 0; index < o.incoming_tx.length; index++) {
const incoming_txErr = AssetOperationValidate(o.incoming_tx[index], opts.incoming_tx_ItemOptions, `${path}.incoming_tx[${index}]`)
if (incoming_txErr !== null) return incoming_txErr
}
if (opts.incoming_tx_CustomCheck && !opts.incoming_tx_CustomCheck(o.incoming_tx)) return new Error(`${path}.incoming_tx: custom check failed`)
if (!Array.isArray(o.invoices)) return new Error(`${path}.invoices: is not an array`)
for (let index = 0; index < o.invoices.length; index++) {
const invoicesErr = AssetOperationValidate(o.invoices[index], opts.invoices_ItemOptions, `${path}.invoices[${index}]`)
if (invoicesErr !== null) return invoicesErr
}
if (opts.invoices_CustomCheck && !opts.invoices_CustomCheck(o.invoices)) return new Error(`${path}.invoices: custom check failed`)
if (!Array.isArray(o.outgoing_tx)) return new Error(`${path}.outgoing_tx: is not an array`)
for (let index = 0; index < o.outgoing_tx.length; index++) {
const outgoing_txErr = AssetOperationValidate(o.outgoing_tx[index], opts.outgoing_tx_ItemOptions, `${path}.outgoing_tx[${index}]`)
if (outgoing_txErr !== null) return outgoing_txErr
}
if (opts.outgoing_tx_CustomCheck && !opts.outgoing_tx_CustomCheck(o.outgoing_tx)) return new Error(`${path}.outgoing_tx: custom check failed`)
if (!Array.isArray(o.payments)) return new Error(`${path}.payments: is not an array`)
for (let index = 0; index < o.payments.length; index++) {
const paymentsErr = AssetOperationValidate(o.payments[index], opts.payments_ItemOptions, `${path}.payments[${index}]`)
if (paymentsErr !== null) return paymentsErr
}
if (opts.payments_CustomCheck && !opts.payments_CustomCheck(o.payments)) return new Error(`${path}.payments: custom check failed`)
if (typeof o.unconfirmed_balance !== 'number') return new Error(`${path}.unconfirmed_balance: is not a number`)
if (opts.unconfirmed_balance_CustomCheck && !opts.unconfirmed_balance_CustomCheck(o.unconfirmed_balance)) return new Error(`${path}.unconfirmed_balance: custom check failed`)
return null
}
export type TrackedOperation = {
amount: number
ts: number
type: TrackedOperationType
}
export const TrackedOperationOptionalFields: [] = []
export type TrackedOperationOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
amount_CustomCheck?: (v: number) => boolean
ts_CustomCheck?: (v: number) => boolean
type_CustomCheck?: (v: TrackedOperationType) => boolean
}
export const TrackedOperationValidate = (o?: TrackedOperation, opts: TrackedOperationOptions = {}, path: string = 'TrackedOperation::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.amount !== 'number') return new Error(`${path}.amount: is not a number`)
if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`)
if (typeof o.ts !== 'number') return new Error(`${path}.ts: is not a number`)
if (opts.ts_CustomCheck && !opts.ts_CustomCheck(o.ts)) return new Error(`${path}.ts: custom check failed`)
if (!enumCheckTrackedOperationType(o.type)) return new Error(`${path}.type: is not a valid TrackedOperationType`)
if (opts.type_CustomCheck && !opts.type_CustomCheck(o.type)) return new Error(`${path}.type: custom check failed`)
return null
}
export type TransactionSwapQuote = {
chain_fee_sats: number
invoice_amount_sats: number