user_receiving_invoice multi column index, and timestamp + serial_id cursor

This commit is contained in:
Mothana 2025-07-22 17:58:31 +04:00
parent 5d0b5a1c7b
commit 44870aa667
11 changed files with 156 additions and 83 deletions

View file

@ -1224,12 +1224,12 @@ The nostr server will send back a message response, and inside the body there wi
- __offer_id__: _string_
### GetUserOperationsRequest
- __latestIncomingInvoice__: _number_
- __latestIncomingTx__: _number_
- __latestIncomingUserToUserPayment__: _number_
- __latestOutgoingInvoice__: _number_
- __latestOutgoingTx__: _number_
- __latestOutgoingUserToUserPayment__: _number_
- __latestIncomingInvoice__: _[OperationsCursor](#OperationsCursor)_
- __latestIncomingTx__: _[OperationsCursor](#OperationsCursor)_
- __latestIncomingUserToUserPayment__: _[OperationsCursor](#OperationsCursor)_
- __latestOutgoingInvoice__: _[OperationsCursor](#OperationsCursor)_
- __latestOutgoingTx__: _[OperationsCursor](#OperationsCursor)_
- __latestOutgoingUserToUserPayment__: _[OperationsCursor](#OperationsCursor)_
- __max_size__: _number_
### GetUserOperationsResponse
@ -1431,6 +1431,10 @@ The nostr server will send back a message response, and inside the body there wi
### OpenChannelResponse
- __channel_id__: _string_
### OperationsCursor
- __id__: _number_
- __ts__: _number_
### PayAddressRequest
- __address__: _string_
- __amoutSats__: _number_
@ -1601,9 +1605,9 @@ The nostr server will send back a message response, and inside the body there wi
- __type__: _[UserOperationType](#UserOperationType)_
### UserOperations
- __fromIndex__: _number_
- __fromIndex__: _[OperationsCursor](#OperationsCursor)_
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
- __toIndex__: _number_
- __toIndex__: _[OperationsCursor](#OperationsCursor)_
### UsersInfo
- __always_been_inactive__: _number_

View file

@ -309,13 +309,13 @@ type GetUserOfferInvoicesReq struct {
Offer_id string `json:"offer_id"`
}
type GetUserOperationsRequest struct {
Latestincominginvoice int64 `json:"latestIncomingInvoice"`
Latestincomingtx int64 `json:"latestIncomingTx"`
Latestincomingusertouserpayment int64 `json:"latestIncomingUserToUserPayment"`
Latestoutgoinginvoice int64 `json:"latestOutgoingInvoice"`
Latestoutgoingtx int64 `json:"latestOutgoingTx"`
Latestoutgoingusertouserpayment int64 `json:"latestOutgoingUserToUserPayment"`
Max_size int64 `json:"max_size"`
Latestincominginvoice *OperationsCursor `json:"latestIncomingInvoice"`
Latestincomingtx *OperationsCursor `json:"latestIncomingTx"`
Latestincomingusertouserpayment *OperationsCursor `json:"latestIncomingUserToUserPayment"`
Latestoutgoinginvoice *OperationsCursor `json:"latestOutgoingInvoice"`
Latestoutgoingtx *OperationsCursor `json:"latestOutgoingTx"`
Latestoutgoingusertouserpayment *OperationsCursor `json:"latestOutgoingUserToUserPayment"`
Max_size int64 `json:"max_size"`
}
type GetUserOperationsResponse struct {
Latestincominginvoiceoperations *UserOperations `json:"latestIncomingInvoiceOperations"`
@ -516,6 +516,10 @@ type OpenChannelRequest struct {
type OpenChannelResponse struct {
Channel_id string `json:"channel_id"`
}
type OperationsCursor struct {
Id int64 `json:"id"`
Ts int64 `json:"ts"`
}
type PayAddressRequest struct {
Address string `json:"address"`
Amoutsats int64 `json:"amoutSats"`
@ -686,9 +690,9 @@ type UserOperation struct {
Type UserOperationType `json:"type"`
}
type UserOperations struct {
Fromindex int64 `json:"fromIndex"`
Operations []UserOperation `json:"operations"`
Toindex int64 `json:"toIndex"`
Fromindex *OperationsCursor `json:"fromIndex"`
Operations []UserOperation `json:"operations"`
Toindex *OperationsCursor `json:"toIndex"`
}
type UsersInfo struct {
Always_been_inactive int64 `json:"always_been_inactive"`

View file

@ -1775,46 +1775,52 @@ export const GetUserOfferInvoicesReqValidate = (o?: GetUserOfferInvoicesReq, opt
}
export type GetUserOperationsRequest = {
latestIncomingInvoice: number
latestIncomingTx: number
latestIncomingUserToUserPayment: number
latestOutgoingInvoice: number
latestOutgoingTx: number
latestOutgoingUserToUserPayment: number
latestIncomingInvoice: OperationsCursor
latestIncomingTx: OperationsCursor
latestIncomingUserToUserPayment: OperationsCursor
latestOutgoingInvoice: OperationsCursor
latestOutgoingTx: OperationsCursor
latestOutgoingUserToUserPayment: OperationsCursor
max_size: number
}
export const GetUserOperationsRequestOptionalFields: [] = []
export type GetUserOperationsRequestOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
latestIncomingInvoice_CustomCheck?: (v: number) => boolean
latestIncomingTx_CustomCheck?: (v: number) => boolean
latestIncomingUserToUserPayment_CustomCheck?: (v: number) => boolean
latestOutgoingInvoice_CustomCheck?: (v: number) => boolean
latestOutgoingTx_CustomCheck?: (v: number) => boolean
latestOutgoingUserToUserPayment_CustomCheck?: (v: number) => boolean
latestIncomingInvoice_Options?: OperationsCursorOptions
latestIncomingTx_Options?: OperationsCursorOptions
latestIncomingUserToUserPayment_Options?: OperationsCursorOptions
latestOutgoingInvoice_Options?: OperationsCursorOptions
latestOutgoingTx_Options?: OperationsCursorOptions
latestOutgoingUserToUserPayment_Options?: OperationsCursorOptions
max_size_CustomCheck?: (v: number) => boolean
}
export const GetUserOperationsRequestValidate = (o?: GetUserOperationsRequest, opts: GetUserOperationsRequestOptions = {}, path: string = 'GetUserOperationsRequest::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.latestIncomingInvoice !== 'number') return new Error(`${path}.latestIncomingInvoice: is not a number`)
if (opts.latestIncomingInvoice_CustomCheck && !opts.latestIncomingInvoice_CustomCheck(o.latestIncomingInvoice)) return new Error(`${path}.latestIncomingInvoice: custom check failed`)
const latestIncomingInvoiceErr = OperationsCursorValidate(o.latestIncomingInvoice, opts.latestIncomingInvoice_Options, `${path}.latestIncomingInvoice`)
if (latestIncomingInvoiceErr !== null) return latestIncomingInvoiceErr
if (typeof o.latestIncomingTx !== 'number') return new Error(`${path}.latestIncomingTx: is not a number`)
if (opts.latestIncomingTx_CustomCheck && !opts.latestIncomingTx_CustomCheck(o.latestIncomingTx)) return new Error(`${path}.latestIncomingTx: custom check failed`)
const latestIncomingTxErr = OperationsCursorValidate(o.latestIncomingTx, opts.latestIncomingTx_Options, `${path}.latestIncomingTx`)
if (latestIncomingTxErr !== null) return latestIncomingTxErr
if (typeof o.latestIncomingUserToUserPayment !== 'number') return new Error(`${path}.latestIncomingUserToUserPayment: is not a number`)
if (opts.latestIncomingUserToUserPayment_CustomCheck && !opts.latestIncomingUserToUserPayment_CustomCheck(o.latestIncomingUserToUserPayment)) return new Error(`${path}.latestIncomingUserToUserPayment: custom check failed`)
const latestIncomingUserToUserPaymentErr = OperationsCursorValidate(o.latestIncomingUserToUserPayment, opts.latestIncomingUserToUserPayment_Options, `${path}.latestIncomingUserToUserPayment`)
if (latestIncomingUserToUserPaymentErr !== null) return latestIncomingUserToUserPaymentErr
if (typeof o.latestOutgoingInvoice !== 'number') return new Error(`${path}.latestOutgoingInvoice: is not a number`)
if (opts.latestOutgoingInvoice_CustomCheck && !opts.latestOutgoingInvoice_CustomCheck(o.latestOutgoingInvoice)) return new Error(`${path}.latestOutgoingInvoice: custom check failed`)
const latestOutgoingInvoiceErr = OperationsCursorValidate(o.latestOutgoingInvoice, opts.latestOutgoingInvoice_Options, `${path}.latestOutgoingInvoice`)
if (latestOutgoingInvoiceErr !== null) return latestOutgoingInvoiceErr
if (typeof o.latestOutgoingTx !== 'number') return new Error(`${path}.latestOutgoingTx: is not a number`)
if (opts.latestOutgoingTx_CustomCheck && !opts.latestOutgoingTx_CustomCheck(o.latestOutgoingTx)) return new Error(`${path}.latestOutgoingTx: custom check failed`)
const latestOutgoingTxErr = OperationsCursorValidate(o.latestOutgoingTx, opts.latestOutgoingTx_Options, `${path}.latestOutgoingTx`)
if (latestOutgoingTxErr !== null) return latestOutgoingTxErr
if (typeof o.latestOutgoingUserToUserPayment !== 'number') return new Error(`${path}.latestOutgoingUserToUserPayment: is not a number`)
if (opts.latestOutgoingUserToUserPayment_CustomCheck && !opts.latestOutgoingUserToUserPayment_CustomCheck(o.latestOutgoingUserToUserPayment)) return new Error(`${path}.latestOutgoingUserToUserPayment: custom check failed`)
const latestOutgoingUserToUserPaymentErr = OperationsCursorValidate(o.latestOutgoingUserToUserPayment, opts.latestOutgoingUserToUserPayment_Options, `${path}.latestOutgoingUserToUserPayment`)
if (latestOutgoingUserToUserPaymentErr !== null) return latestOutgoingUserToUserPaymentErr
if (typeof o.max_size !== 'number') return new Error(`${path}.max_size: is not a number`)
if (opts.max_size_CustomCheck && !opts.max_size_CustomCheck(o.max_size)) return new Error(`${path}.max_size: custom check failed`)
@ -3031,6 +3037,29 @@ export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenC
return null
}
export type OperationsCursor = {
id: number
ts: number
}
export const OperationsCursorOptionalFields: [] = []
export type OperationsCursorOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
id_CustomCheck?: (v: number) => boolean
ts_CustomCheck?: (v: number) => boolean
}
export const OperationsCursorValidate = (o?: OperationsCursor, opts: OperationsCursorOptions = {}, path: string = 'OperationsCursor::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.id !== 'number') return new Error(`${path}.id: is not a number`)
if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: 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`)
return null
}
export type PayAddressRequest = {
address: string
amoutSats: number
@ -3998,24 +4027,25 @@ export const UserOperationValidate = (o?: UserOperation, opts: UserOperationOpti
}
export type UserOperations = {
fromIndex: number
fromIndex: OperationsCursor
operations: UserOperation[]
toIndex: number
toIndex: OperationsCursor
}
export const UserOperationsOptionalFields: [] = []
export type UserOperationsOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
fromIndex_CustomCheck?: (v: number) => boolean
fromIndex_Options?: OperationsCursorOptions
operations_ItemOptions?: UserOperationOptions
operations_CustomCheck?: (v: UserOperation[]) => boolean
toIndex_CustomCheck?: (v: number) => boolean
toIndex_Options?: OperationsCursorOptions
}
export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsOptions = {}, path: string = 'UserOperations::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.fromIndex !== 'number') return new Error(`${path}.fromIndex: is not a number`)
if (opts.fromIndex_CustomCheck && !opts.fromIndex_CustomCheck(o.fromIndex)) return new Error(`${path}.fromIndex: custom check failed`)
const fromIndexErr = OperationsCursorValidate(o.fromIndex, opts.fromIndex_Options, `${path}.fromIndex`)
if (fromIndexErr !== null) return fromIndexErr
if (!Array.isArray(o.operations)) return new Error(`${path}.operations: is not an array`)
for (let index = 0; index < o.operations.length; index++) {
@ -4024,8 +4054,9 @@ export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsO
}
if (opts.operations_CustomCheck && !opts.operations_CustomCheck(o.operations)) return new Error(`${path}.operations: custom check failed`)
if (typeof o.toIndex !== 'number') return new Error(`${path}.toIndex: is not a number`)
if (opts.toIndex_CustomCheck && !opts.toIndex_CustomCheck(o.toIndex)) return new Error(`${path}.toIndex: custom check failed`)
const toIndexErr = OperationsCursorValidate(o.toIndex, opts.toIndex_Options, `${path}.toIndex`)
if (toIndexErr !== null) return toIndexErr
return null
}

View file

@ -534,13 +534,19 @@ message UserInfo{
string bridge_url = 11;
string nmanage = 12;
}
message OperationsCursor {
int64 ts = 1; // last timestamp
int64 id = 2; // last serial_id
}
message GetUserOperationsRequest{
int64 latestIncomingInvoice = 1;
int64 latestOutgoingInvoice = 2;
int64 latestIncomingTx = 3;
int64 latestOutgoingTx = 4;
int64 latestIncomingUserToUserPayment = 5;
int64 latestOutgoingUserToUserPayment = 6;
OperationsCursor latestIncomingInvoice = 1;
OperationsCursor latestOutgoingInvoice = 2;
OperationsCursor latestIncomingTx = 3;
OperationsCursor latestOutgoingTx = 4;
OperationsCursor latestIncomingUserToUserPayment = 5;
OperationsCursor latestOutgoingUserToUserPayment = 6;
int64 max_size = 7;
}
enum UserOperationType {
@ -566,8 +572,8 @@ message UserOperation {
bool internal = 11;
}
message UserOperations {
int64 fromIndex=1;
int64 toIndex=2;
OperationsCursor fromIndex=1;
OperationsCursor toIndex=2;
repeated UserOperation operations=3;
}
message GetUserOperationsResponse{