diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index 6b76b95e..bb5409c3 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -105,9 +105,9 @@ The nostr server will send back a message response, and inside the body there wi - __User__: - expected context content - - __app_user_id__: _string_ - __user_id__: _string_ - __app_id__: _string_ + - __app_user_id__: _string_ - __Admin__: - expected context content @@ -141,6 +141,13 @@ The nostr server will send back a message response, and inside the body there wi - input: [AuthAppRequest](#AuthAppRequest) - output: [AuthApp](#AuthApp) +- GetMetrics + - auth type: __Admin__ + - http method: __post__ + - http route: __/api/admin/metrics__ + - This methods has an __empty__ __request__ body + - output: [UsageMetrics](#UsageMetrics) + - Health - auth type: __Guest__ - http method: __get__ @@ -407,93 +414,42 @@ The nostr server will send back a message response, and inside the body there wi ## Messages ### The content of requests and response from the methods -### SetMockAppUserBalanceRequest - - __user_identifier__: _string_ - - __amount__: _number_ +### LnurlLinkResponse + - __lnurl__: _string_ + - __k1__: _string_ -### SetMockAppBalanceRequest - - __amount__: _number_ - -### GetAppUserLNURLInfoRequest - - __user_identifier__: _string_ - - __base_url_override__: _string_ - -### GetAppUserRequest - - __user_identifier__: _string_ - -### PayAppUserInvoiceRequest - - __user_identifier__: _string_ - - __invoice__: _string_ - - __amount__: _number_ - -### PayAddressRequest - - __address__: _string_ - - __amoutSats__: _number_ - - __satsPerVByte__: _number_ - -### PayInvoiceRequest - - __invoice__: _string_ - - __amount__: _number_ - -### GetUserOperationsResponse - - __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_ - - __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_ - - __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_ - - __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_ - - __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_ - - __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_ - -### MigrationUpdate - - __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional - - __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional - -### Empty - -### LndGetInfoRequest - - __nodeId__: _number_ - -### SetMockInvoiceAsPaidRequest - - __invoice__: _string_ - - __amount__: _number_ +### RelaysMigration + - __relays__: ARRAY of: _string_ ### LndGetInfoResponse - __alias__: _string_ -### AuthAppRequest - - __name__: _string_ - - __allow_user_creation__: _boolean_ *this field is optional +### SendAppUserToAppPaymentRequest + - __from_user_identifier__: _string_ + - __amount__: _number_ -### AddAppUserInvoiceRequest - - __receiver_identifier__: _string_ - - __payer_identifier__: _string_ - - __http_callback_url__: _string_ - - __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_ +### NewAddressRequest + - __addressType__: _[AddressType](#AddressType)_ -### NewAddressResponse - - __address__: _string_ +### PayAddressResponse + - __txId__: _string_ + - __operation_id__: _string_ + - __service_fee__: _number_ + - __network_fee__: _number_ -### NewInvoiceRequest - - __amountSats__: _number_ - - __memo__: _string_ - -### EncryptionExchangeRequest - - __publicKey__: _string_ - - __deviceId__: _string_ - -### AddProductRequest - - __name__: _string_ - - __price_sats__: _number_ +### UsageMetrics + - __metrics__: ARRAY of: _[UsageMetric](#UsageMetric)_ ### AddAppUserRequest - __identifier__: _string_ - __fail_if_exists__: _boolean_ - __balance__: _number_ -### NewInvoiceResponse - - __invoice__: _string_ - -### OpenChannelResponse - - __channelId__: _string_ +### AddAppUserInvoiceRequest + - __receiver_identifier__: _string_ + - __payer_identifier__: _string_ + - __http_callback_url__: _string_ + - __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_ ### LnurlPayInfoResponse - __tag__: _string_ @@ -504,28 +460,44 @@ The nostr server will send back a message response, and inside the body there wi - __allowsNostr__: _boolean_ - __nostrPubkey__: _string_ -### HandleLnurlPayResponse - - __pr__: _string_ - - __routes__: ARRAY of: _[Empty](#Empty)_ - -### Product - - __id__: _string_ - - __name__: _string_ - - __price_sats__: _number_ - -### ClosureMigration - - __closes_at_unix__: _number_ - -### AuthApp - - __app__: _[Application](#Application)_ - - __auth_token__: _string_ - -### NewAddressRequest - - __addressType__: _[AddressType](#AddressType)_ +### SetMockAppUserBalanceRequest + - __user_identifier__: _string_ + - __amount__: _number_ ### DecodeInvoiceRequest - __invoice__: _string_ +### PayInvoiceRequest + - __invoice__: _string_ + - __amount__: _number_ + +### PayInvoiceResponse + - __preimage__: _string_ + - __amount_paid__: _number_ + - __operation_id__: _string_ + - __service_fee__: _number_ + - __network_fee__: _number_ + +### SetMockInvoiceAsPaidRequest + - __invoice__: _string_ + - __amount__: _number_ + +### AppUser + - __identifier__: _string_ + - __info__: _[UserInfo](#UserInfo)_ + - __max_withdrawable__: _number_ + +### GetAppUserRequest + - __user_identifier__: _string_ + +### GetAppUserLNURLInfoRequest + - __user_identifier__: _string_ + - __base_url_override__: _string_ + +### HandleLnurlPayResponse + - __pr__: _string_ + - __routes__: ARRAY of: _[Empty](#Empty)_ + ### UserInfo - __userId__: _string_ - __balance__: _number_ @@ -536,20 +508,48 @@ The nostr server will send back a message response, and inside the body there wi - __toIndex__: _number_ - __operations__: ARRAY of: _[UserOperation](#UserOperation)_ -### GetProductBuyLinkResponse - - __link__: _string_ +### Product + - __id__: _string_ + - __name__: _string_ + - __price_sats__: _number_ -### AppUser - - __identifier__: _string_ - - __info__: _[UserInfo](#UserInfo)_ - - __max_withdrawable__: _number_ +### OpenChannelResponse + - __channelId__: _string_ -### PayInvoiceResponse - - __preimage__: _string_ - - __amount_paid__: _number_ - - __operation_id__: _string_ - - __service_fee__: _number_ - - __network_fee__: _number_ +### AddProductRequest + - __name__: _string_ + - __price_sats__: _number_ + +### UsageMetric + - __processed_at_nano__: _string_ + - __parsed_in_nano__: _number_ + - __auth_in_nano__: _number_ + - __validate_in_nano__: _number_ + - __handle_in_nano__: _number_ + - __rpc_name__: _string_ + - __batch__: _boolean_ + - __nostr__: _boolean_ + - __batch_size__: _number_ + +### AddAppRequest + - __name__: _string_ + - __allow_user_creation__: _boolean_ + +### AuthApp + - __app__: _[Application](#Application)_ + - __auth_token__: _string_ + +### NewInvoiceResponse + - __invoice__: _string_ + +### AddAppInvoiceRequest + - __payer_identifier__: _string_ + - __http_callback_url__: _string_ + - __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_ + +### NewInvoiceRequest + - __amountSats__: _number_ + - __memo__: _string_ ### LnurlWithdrawInfoResponse - __tag__: _string_ @@ -561,53 +561,6 @@ The nostr server will send back a message response, and inside the body there wi - __balanceCheck__: _string_ - __payLink__: _string_ -### GetUserOperationsRequest - - __latestIncomingInvoice__: _number_ - - __latestOutgoingInvoice__: _number_ - - __latestIncomingTx__: _number_ - - __latestOutgoingTx__: _number_ - - __latestIncomingUserToUserPayment__: _number_ - - __latestOutgoingUserToUserPayment__: _number_ - -### SendAppUserToAppPaymentRequest - - __from_user_identifier__: _string_ - - __amount__: _number_ - -### AddAppInvoiceRequest - - __payer_identifier__: _string_ - - __http_callback_url__: _string_ - - __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_ - -### PayAddressResponse - - __txId__: _string_ - - __operation_id__: _string_ - - __service_fee__: _number_ - - __network_fee__: _number_ - -### DecodeInvoiceResponse - - __amount__: _number_ - -### LnurlLinkResponse - - __lnurl__: _string_ - - __k1__: _string_ - -### Application - - __name__: _string_ - - __id__: _string_ - - __balance__: _number_ - - __npub__: _string_ - -### SendAppUserToAppUserPaymentRequest - - __from_user_identifier__: _string_ - - __to_user_identifier__: _string_ - - __amount__: _number_ - -### OpenChannelRequest - - __destination__: _string_ - - __fundingAmount__: _number_ - - __pushAmount__: _number_ - - __closeAddress__: _string_ - ### UserOperation - __paidAtUnix__: _number_ - __type__: _[UserOperationType](#UserOperationType)_ @@ -619,15 +572,83 @@ The nostr server will send back a message response, and inside the body there wi - __network_fee__: _number_ - __confirmed__: _boolean_ +### SendAppUserToAppUserPaymentRequest + - __from_user_identifier__: _string_ + - __to_user_identifier__: _string_ + - __amount__: _number_ + +### SetMockAppBalanceRequest + - __amount__: _number_ + ### LiveUserOperation - __operation__: _[UserOperation](#UserOperation)_ -### RelaysMigration - - __relays__: ARRAY of: _string_ +### ClosureMigration + - __closes_at_unix__: _number_ -### AddAppRequest +### Empty + +### EncryptionExchangeRequest + - __publicKey__: _string_ + - __deviceId__: _string_ + +### LndGetInfoRequest + - __nodeId__: _number_ + +### Application - __name__: _string_ - - __allow_user_creation__: _boolean_ + - __id__: _string_ + - __balance__: _number_ + - __npub__: _string_ + +### GetUserOperationsResponse + - __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_ + - __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_ + - __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_ + - __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_ + - __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_ + - __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_ + +### GetProductBuyLinkResponse + - __link__: _string_ + +### MigrationUpdate + - __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional + - __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional + +### PayAppUserInvoiceRequest + - __user_identifier__: _string_ + - __invoice__: _string_ + - __amount__: _number_ + +### NewAddressResponse + - __address__: _string_ + +### DecodeInvoiceResponse + - __amount__: _number_ + +### GetUserOperationsRequest + - __latestIncomingInvoice__: _number_ + - __latestOutgoingInvoice__: _number_ + - __latestIncomingTx__: _number_ + - __latestOutgoingTx__: _number_ + - __latestIncomingUserToUserPayment__: _number_ + - __latestOutgoingUserToUserPayment__: _number_ + +### AuthAppRequest + - __name__: _string_ + - __allow_user_creation__: _boolean_ *this field is optional + +### PayAddressRequest + - __address__: _string_ + - __amoutSats__: _number_ + - __satsPerVByte__: _number_ + +### OpenChannelRequest + - __destination__: _string_ + - __fundingAmount__: _number_ + - __pushAmount__: _number_ + - __closeAddress__: _string_ ## Enums ### The enumerators used in the messages diff --git a/proto/autogenerated/debug.txt b/proto/autogenerated/debug.txt index e914a1e8..91d8a41a 100644 --- a/proto/autogenerated/debug.txt +++ b/proto/autogenerated/debug.txt @@ -1,5 +1,5 @@ -([]*main.Method) (len=38 cap=64) { - (*main.Method)(0xc0002ca730)({ +([]*main.Method) (len=39 cap=64) { + (*main.Method)(0xc00027a730)({ in: (main.MethodMessage) { name: (string) (len=17) "LndGetInfoRequest", hasZeroFields: (bool) false @@ -9,8 +9,8 @@ name: (string) (len=18) "LndGetInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006c480)({ - authType: (*main.supportedAuth)(0xc0001d4930)({ + opts: (*main.methodOptions)(0xc00006cae0)({ + authType: (*main.supportedAuth)(0xc000326cf0)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", context: (map[string]string) (len=1) { @@ -28,7 +28,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002ca8c0)({ + (*main.Method)(0xc00027a8c0)({ in: (main.MethodMessage) { name: (string) (len=13) "AddAppRequest", hasZeroFields: (bool) false @@ -38,8 +38,8 @@ name: (string) (len=7) "AuthApp", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006c600)({ - authType: (*main.supportedAuth)(0xc0001d49c0)({ + opts: (*main.methodOptions)(0xc00006cc60)({ + authType: (*main.supportedAuth)(0xc000326d80)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", context: (map[string]string) (len=1) { @@ -57,7 +57,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002ca960)({ + (*main.Method)(0xc00027a960)({ in: (main.MethodMessage) { name: (string) (len=14) "AuthAppRequest", hasZeroFields: (bool) false @@ -67,8 +67,8 @@ name: (string) (len=7) "AuthApp", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006c780)({ - authType: (*main.supportedAuth)(0xc0001d4a50)({ + opts: (*main.methodOptions)(0xc00006cde0)({ + authType: (*main.supportedAuth)(0xc000326e10)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", context: (map[string]string) (len=1) { @@ -86,7 +86,36 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002ca9b0)({ + (*main.Method)(0xc00027a9b0)({ + in: (main.MethodMessage) { + name: (string) (len=5) "Empty", + hasZeroFields: (bool) true + }, + name: (string) (len=10) "GetMetrics", + out: (main.MethodMessage) { + name: (string) (len=12) "UsageMetrics", + hasZeroFields: (bool) false + }, + opts: (*main.methodOptions)(0xc00006cfc0)({ + authType: (*main.supportedAuth)(0xc000326ea0)({ + id: (string) (len=5) "admin", + name: (string) (len=5) "Admin", + context: (map[string]string) (len=1) { + (string) (len=8) "admin_id": (string) (len=6) "string" + } + }), + method: (string) (len=4) "post", + route: (main.decodedRoute) { + route: (string) (len=18) "/api/admin/metrics", + params: ([]string) + }, + query: ([]string) , + nostr: (bool) false, + batch: (bool) false + }), + serverStream: (bool) false + }), + (*main.Method)(0xc00027aa00)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -96,8 +125,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00006c900)({ - authType: (*main.supportedAuth)(0xc0001d4ae0)({ + opts: (*main.methodOptions)(0xc00006d1a0)({ + authType: (*main.supportedAuth)(0xc000326f30)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -114,7 +143,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002caa00)({ + (*main.Method)(0xc00027aa50)({ in: (main.MethodMessage) { name: (string) (len=25) "EncryptionExchangeRequest", hasZeroFields: (bool) false @@ -124,8 +153,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00006ca80)({ - authType: (*main.supportedAuth)(0xc0001d4ba0)({ + opts: (*main.methodOptions)(0xc00006d320)({ + authType: (*main.supportedAuth)(0xc000326ff0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -142,7 +171,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002caa50)({ + (*main.Method)(0xc00027aaa0)({ in: (main.MethodMessage) { name: (string) (len=27) "SetMockInvoiceAsPaidRequest", hasZeroFields: (bool) false @@ -152,8 +181,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00006cc60)({ - authType: (*main.supportedAuth)(0xc0001d4c30)({ + opts: (*main.methodOptions)(0xc00032e000)({ + authType: (*main.supportedAuth)(0xc000327080)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -170,7 +199,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002caaf0)({ + (*main.Method)(0xc00027ab40)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -180,8 +209,8 @@ name: (string) (len=25) "LnurlWithdrawInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006cfc0)({ - authType: (*main.supportedAuth)(0xc0001d4d80)({ + opts: (*main.methodOptions)(0xc00032e360)({ + authType: (*main.supportedAuth)(0xc0003271d0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -200,7 +229,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cab90)({ + (*main.Method)(0xc00027abe0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -210,8 +239,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00006d320)({ - authType: (*main.supportedAuth)(0xc0001d4ed0)({ + opts: (*main.methodOptions)(0xc00032e6c0)({ + authType: (*main.supportedAuth)(0xc000327320)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -231,7 +260,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cac30)({ + (*main.Method)(0xc00027ac80)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -241,8 +270,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006d680)({ - authType: (*main.supportedAuth)(0xc0001d4ff0)({ + opts: (*main.methodOptions)(0xc00032ea20)({ + authType: (*main.supportedAuth)(0xc000327440)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -261,7 +290,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cacd0)({ + (*main.Method)(0xc00027ad20)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -271,8 +300,8 @@ name: (string) (len=22) "HandleLnurlPayResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006da40)({ - authType: (*main.supportedAuth)(0xc0001d5140)({ + opts: (*main.methodOptions)(0xc00032ede0)({ + authType: (*main.supportedAuth)(0xc000327590)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -294,7 +323,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cad20)({ + (*main.Method)(0xc00027ad70)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -304,8 +333,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006dbc0)({ - authType: (*main.supportedAuth)(0xc0001d51d0)({ + opts: (*main.methodOptions)(0xc00032ef60)({ + authType: (*main.supportedAuth)(0xc000327620)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", context: (map[string]string) { @@ -324,7 +353,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cad70)({ + (*main.Method)(0xc00027adc0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -334,8 +363,8 @@ name: (string) (len=11) "Application", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006dd40)({ - authType: (*main.supportedAuth)(0xc0001d5260)({ + opts: (*main.methodOptions)(0xc00032f0e0)({ + authType: (*main.supportedAuth)(0xc0003276b0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -353,7 +382,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cae10)({ + (*main.Method)(0xc00027ae60)({ in: (main.MethodMessage) { name: (string) (len=17) "AddAppUserRequest", hasZeroFields: (bool) false @@ -363,8 +392,8 @@ name: (string) (len=7) "AppUser", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00006dec0)({ - authType: (*main.supportedAuth)(0xc0001d52f0)({ + opts: (*main.methodOptions)(0xc00032f260)({ + authType: (*main.supportedAuth)(0xc000327740)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -382,7 +411,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002caeb0)({ + (*main.Method)(0xc00027af00)({ in: (main.MethodMessage) { name: (string) (len=20) "AddAppInvoiceRequest", hasZeroFields: (bool) false @@ -392,8 +421,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00009e4e0)({ - authType: (*main.supportedAuth)(0xc0001d5380)({ + opts: (*main.methodOptions)(0xc00032f3e0)({ + authType: (*main.supportedAuth)(0xc0003277d0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -411,7 +440,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002caf00)({ + (*main.Method)(0xc00027af50)({ in: (main.MethodMessage) { name: (string) (len=24) "AddAppUserInvoiceRequest", hasZeroFields: (bool) false @@ -421,8 +450,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00009e720)({ - authType: (*main.supportedAuth)(0xc0001d5410)({ + opts: (*main.methodOptions)(0xc00032f5c0)({ + authType: (*main.supportedAuth)(0xc000327860)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -440,7 +469,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cafa0)({ + (*main.Method)(0xc00027aff0)({ in: (main.MethodMessage) { name: (string) (len=17) "GetAppUserRequest", hasZeroFields: (bool) false @@ -450,8 +479,8 @@ name: (string) (len=7) "AppUser", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00009e8a0)({ - authType: (*main.supportedAuth)(0xc0001d54a0)({ + opts: (*main.methodOptions)(0xc00032f740)({ + authType: (*main.supportedAuth)(0xc0003278f0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -469,7 +498,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb040)({ + (*main.Method)(0xc00027b090)({ in: (main.MethodMessage) { name: (string) (len=24) "PayAppUserInvoiceRequest", hasZeroFields: (bool) false @@ -479,8 +508,8 @@ name: (string) (len=18) "PayInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00009ea20)({ - authType: (*main.supportedAuth)(0xc0001d5530)({ + opts: (*main.methodOptions)(0xc00032f8c0)({ + authType: (*main.supportedAuth)(0xc000327980)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -498,7 +527,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb090)({ + (*main.Method)(0xc00027b0e0)({ in: (main.MethodMessage) { name: (string) (len=34) "SendAppUserToAppUserPaymentRequest", hasZeroFields: (bool) false @@ -508,8 +537,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00009ec00)({ - authType: (*main.supportedAuth)(0xc0001d55c0)({ + opts: (*main.methodOptions)(0xc00032faa0)({ + authType: (*main.supportedAuth)(0xc000327a10)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -527,7 +556,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb130)({ + (*main.Method)(0xc00027b180)({ in: (main.MethodMessage) { name: (string) (len=30) "SendAppUserToAppPaymentRequest", hasZeroFields: (bool) false @@ -537,8 +566,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00009ed80)({ - authType: (*main.supportedAuth)(0xc0001d5650)({ + opts: (*main.methodOptions)(0xc00032fc20)({ + authType: (*main.supportedAuth)(0xc000327aa0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -556,7 +585,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb180)({ + (*main.Method)(0xc00027b1d0)({ in: (main.MethodMessage) { name: (string) (len=26) "GetAppUserLNURLInfoRequest", hasZeroFields: (bool) false @@ -566,8 +595,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00009ef60)({ - authType: (*main.supportedAuth)(0xc0001d56e0)({ + opts: (*main.methodOptions)(0xc00032fda0)({ + authType: (*main.supportedAuth)(0xc000327b30)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -585,7 +614,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb1d0)({ + (*main.Method)(0xc00027b220)({ in: (main.MethodMessage) { name: (string) (len=28) "SetMockAppUserBalanceRequest", hasZeroFields: (bool) false @@ -595,8 +624,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00009f140)({ - authType: (*main.supportedAuth)(0xc0001d5770)({ + opts: (*main.methodOptions)(0xc00032ff20)({ + authType: (*main.supportedAuth)(0xc000327bc0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -614,7 +643,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb220)({ + (*main.Method)(0xc00027b270)({ in: (main.MethodMessage) { name: (string) (len=24) "SetMockAppBalanceRequest", hasZeroFields: (bool) false @@ -624,8 +653,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00009f320)({ - authType: (*main.supportedAuth)(0xc0001d5800)({ + opts: (*main.methodOptions)(0xc000330120)({ + authType: (*main.supportedAuth)(0xc000327c50)({ id: (string) (len=3) "app", name: (string) (len=3) "App", context: (map[string]string) (len=1) { @@ -643,7 +672,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb270)({ + (*main.Method)(0xc00027b2c0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -653,14 +682,14 @@ name: (string) (len=8) "UserInfo", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021c060)({ - authType: (*main.supportedAuth)(0xc0001d58c0)({ + opts: (*main.methodOptions)(0xc000330300)({ + authType: (*main.supportedAuth)(0xc000327d10)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { + (string) (len=7) "user_id": (string) (len=6) "string", (string) (len=6) "app_id": (string) (len=6) "string", - (string) (len=11) "app_user_id": (string) (len=6) "string", - (string) (len=7) "user_id": (string) (len=6) "string" + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -674,7 +703,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb310)({ + (*main.Method)(0xc00027b360)({ in: (main.MethodMessage) { name: (string) (len=17) "AddProductRequest", hasZeroFields: (bool) false @@ -684,14 +713,14 @@ name: (string) (len=7) "Product", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021c240)({ - authType: (*main.supportedAuth)(0xc0001d5950)({ + opts: (*main.methodOptions)(0xc0003304e0)({ + authType: (*main.supportedAuth)(0xc000327da0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -705,7 +734,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb360)({ + (*main.Method)(0xc00027b3b0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -715,8 +744,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021c6c0)({ - authType: (*main.supportedAuth)(0xc0001d5a70)({ + opts: (*main.methodOptions)(0xc000330960)({ + authType: (*main.supportedAuth)(0xc000327ec0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { @@ -738,7 +767,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb3b0)({ + (*main.Method)(0xc00027b400)({ in: (main.MethodMessage) { name: (string) (len=24) "GetUserOperationsRequest", hasZeroFields: (bool) false @@ -748,14 +777,14 @@ name: (string) (len=25) "GetUserOperationsResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021c8a0)({ - authType: (*main.supportedAuth)(0xc0001d5b00)({ + opts: (*main.methodOptions)(0xc000330b40)({ + authType: (*main.supportedAuth)(0xc000327f50)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=7) "user_id": (string) (len=6) "string", (string) (len=6) "app_id": (string) (len=6) "string", - (string) (len=11) "app_user_id": (string) (len=6) "string" + (string) (len=11) "app_user_id": (string) (len=6) "string", + (string) (len=7) "user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -769,7 +798,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb450)({ + (*main.Method)(0xc00027b4a0)({ in: (main.MethodMessage) { name: (string) (len=17) "NewAddressRequest", hasZeroFields: (bool) false @@ -779,14 +808,14 @@ name: (string) (len=18) "NewAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021ca80)({ - authType: (*main.supportedAuth)(0xc0001d5b90)({ + opts: (*main.methodOptions)(0xc000330d20)({ + authType: (*main.supportedAuth)(0xc000334000)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -800,7 +829,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb4f0)({ + (*main.Method)(0xc00027b540)({ in: (main.MethodMessage) { name: (string) (len=17) "PayAddressRequest", hasZeroFields: (bool) false @@ -810,14 +839,14 @@ name: (string) (len=18) "PayAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021cc60)({ - authType: (*main.supportedAuth)(0xc0001d5c20)({ + opts: (*main.methodOptions)(0xc000330f00)({ + authType: (*main.supportedAuth)(0xc000334090)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -831,7 +860,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb590)({ + (*main.Method)(0xc00027b5e0)({ in: (main.MethodMessage) { name: (string) (len=17) "NewInvoiceRequest", hasZeroFields: (bool) false @@ -841,14 +870,14 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021ce40)({ - authType: (*main.supportedAuth)(0xc0001d5cb0)({ + opts: (*main.methodOptions)(0xc0003310e0)({ + authType: (*main.supportedAuth)(0xc000334120)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -862,7 +891,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb630)({ + (*main.Method)(0xc00027b680)({ in: (main.MethodMessage) { name: (string) (len=20) "DecodeInvoiceRequest", hasZeroFields: (bool) false @@ -872,14 +901,14 @@ name: (string) (len=21) "DecodeInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021d020)({ - authType: (*main.supportedAuth)(0xc0001d5d40)({ + opts: (*main.methodOptions)(0xc0003312c0)({ + authType: (*main.supportedAuth)(0xc0003341b0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -893,7 +922,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb6d0)({ + (*main.Method)(0xc00027b720)({ in: (main.MethodMessage) { name: (string) (len=17) "PayInvoiceRequest", hasZeroFields: (bool) false @@ -903,14 +932,14 @@ name: (string) (len=18) "PayInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021d200)({ - authType: (*main.supportedAuth)(0xc0001d5dd0)({ + opts: (*main.methodOptions)(0xc0003314a0)({ + authType: (*main.supportedAuth)(0xc000334240)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -924,7 +953,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb770)({ + (*main.Method)(0xc00027b7c0)({ in: (main.MethodMessage) { name: (string) (len=18) "OpenChannelRequest", hasZeroFields: (bool) false @@ -934,8 +963,8 @@ name: (string) (len=19) "OpenChannelResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021d3e0)({ - authType: (*main.supportedAuth)(0xc0001d5e60)({ + opts: (*main.methodOptions)(0xc000331680)({ + authType: (*main.supportedAuth)(0xc0003342d0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { @@ -955,7 +984,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb810)({ + (*main.Method)(0xc00027b860)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -965,14 +994,14 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021d5c0)({ - authType: (*main.supportedAuth)(0xc0001d5ef0)({ + opts: (*main.methodOptions)(0xc000331860)({ + authType: (*main.supportedAuth)(0xc000334360)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=3) "get", @@ -986,7 +1015,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb8b0)({ + (*main.Method)(0xc00027b900)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -996,14 +1025,14 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021d7a0)({ - authType: (*main.supportedAuth)(0xc0001d5f80)({ + opts: (*main.methodOptions)(0xc000331a40)({ + authType: (*main.supportedAuth)(0xc0003343f0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=3) "get", @@ -1017,7 +1046,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb950)({ + (*main.Method)(0xc00027b9a0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -1027,14 +1056,14 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021d980)({ - authType: (*main.supportedAuth)(0xc000250030)({ + opts: (*main.methodOptions)(0xc000331c20)({ + authType: (*main.supportedAuth)(0xc000334480)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -1048,7 +1077,7 @@ }), serverStream: (bool) false }), - (*main.Method)(0xc0002cb9f0)({ + (*main.Method)(0xc00027ba40)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -1058,14 +1087,14 @@ name: (string) (len=17) "LiveUserOperation", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021db60)({ - authType: (*main.supportedAuth)(0xc0002500c0)({ + opts: (*main.methodOptions)(0xc000331e00)({ + authType: (*main.supportedAuth)(0xc000334510)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { + (string) (len=7) "user_id": (string) (len=6) "string", (string) (len=6) "app_id": (string) (len=6) "string", - (string) (len=11) "app_user_id": (string) (len=6) "string", - (string) (len=7) "user_id": (string) (len=6) "string" + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -1079,7 +1108,7 @@ }), serverStream: (bool) true }), - (*main.Method)(0xc0002cba90)({ + (*main.Method)(0xc00027bae0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -1089,14 +1118,14 @@ name: (string) (len=15) "MigrationUpdate", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00021dd40)({ - authType: (*main.supportedAuth)(0xc000250150)({ + opts: (*main.methodOptions)(0xc000336000)({ + authType: (*main.supportedAuth)(0xc0003345a0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -1110,7 +1139,7 @@ }), serverStream: (bool) true }), - (*main.Method)(0xc0002cbae0)({ + (*main.Method)(0xc00027bb30)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -1120,14 +1149,14 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00021df80)({ - authType: (*main.supportedAuth)(0xc000250210)({ + opts: (*main.methodOptions)(0xc000336240)({ + authType: (*main.supportedAuth)(0xc000334660)({ id: (string) (len=4) "user", name: (string) (len=4) "User", context: (map[string]string) (len=3) { - (string) (len=11) "app_user_id": (string) (len=6) "string", (string) (len=7) "user_id": (string) (len=6) "string", - (string) (len=6) "app_id": (string) (len=6) "string" + (string) (len=6) "app_id": (string) (len=6) "string", + (string) (len=11) "app_user_id": (string) (len=6) "string" } }), method: (string) (len=4) "post", @@ -1144,7 +1173,7 @@ } ([]*main.Enum) (len=2 cap=2) { - (*main.Enum)(0xc0001d4120)({ + (*main.Enum)(0xc0003264e0)({ name: (string) (len=11) "AddressType", values: ([]main.EnumValue) (len=3 cap=4) { (main.EnumValue) { @@ -1161,7 +1190,7 @@ } } }), - (*main.Enum)(0xc0001d4180)({ + (*main.Enum)(0xc000326540)({ name: (string) (len=17) "UserOperationType", values: ([]main.EnumValue) (len=6 cap=8) { (main.EnumValue) { @@ -1192,12 +1221,12 @@ }) } -(map[string]*main.Message) (len=48) { - (string) (len=26) "GetAppUserLNURLInfoRequest": (*main.Message)(0xc00037ac80)({ +(map[string]*main.Message) (len=50) { + (string) (len=26) "GetAppUserLNURLInfoRequest": (*main.Message)(0xc00043ed00)({ fullName: (string) (len=26) "GetAppUserLNURLInfoRequest", name: (string) (len=26) "GetAppUserLNURLInfoRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00008f1a0)({ + (*main.Field)(0xc0001a5410)({ name: (string) (len=15) "user_identifier", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1206,7 +1235,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00008f1d0)({ + (*main.Field)(0xc0001a5440)({ name: (string) (len=17) "base_url_override", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1217,11 +1246,11 @@ }) } }), - (string) (len=28) "SetMockAppUserBalanceRequest": (*main.Message)(0xc00037acc0)({ + (string) (len=28) "SetMockAppUserBalanceRequest": (*main.Message)(0xc00043ed40)({ fullName: (string) (len=28) "SetMockAppUserBalanceRequest", name: (string) (len=28) "SetMockAppUserBalanceRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00008f200)({ + (*main.Field)(0xc0001a5470)({ name: (string) (len=15) "user_identifier", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1230,7 +1259,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00008f230)({ + (*main.Field)(0xc0001a54a0)({ name: (string) (len=6) "amount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1241,139 +1270,11 @@ }) } }), - (string) (len=24) "SetMockAppBalanceRequest": (*main.Message)(0xc00037ad00)({ - fullName: (string) (len=24) "SetMockAppBalanceRequest", - name: (string) (len=24) "SetMockAppBalanceRequest", + (string) (len=20) "DecodeInvoiceRequest": (*main.Message)(0xc00043ef40)({ + fullName: (string) (len=20) "DecodeInvoiceRequest", + name: (string) (len=20) "DecodeInvoiceRequest", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f260)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=25) "GetUserOperationsResponse": (*main.Message)(0xc00037b3c0)({ - fullName: (string) (len=25) "GetUserOperationsResponse", - name: (string) (len=25) "GetUserOperationsResponse", - fields: ([]*main.Field) (len=6 cap=8) { - (*main.Field)(0xc0001f98c0)({ - name: (string) (len=31) "latestOutgoingInvoiceOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f98f0)({ - name: (string) (len=31) "latestIncomingInvoiceOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f9c50)({ - name: (string) (len=26) "latestOutgoingTxOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f9c80)({ - name: (string) (len=26) "latestIncomingTxOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f9cb0)({ - name: (string) (len=32) "latestOutgoingUserToUserPayemnts", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f9ce0)({ - name: (string) (len=32) "latestIncomingUserToUserPayemnts", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }) - } - }), - (string) (len=15) "MigrationUpdate": (*main.Message)(0xc00037b500)({ - fullName: (string) (len=15) "MigrationUpdate", - name: (string) (len=15) "MigrationUpdate", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0001d4030)({ - name: (string) (len=7) "closure", - kind: (string) (len=16) "ClosureMigration", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) true - }), - (*main.Field)(0xc0001d4060)({ - name: (string) (len=6) "relays", - kind: (string) (len=15) "RelaysMigration", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) true - }) - } - }), - (string) (len=5) "Empty": (*main.Message)(0xc00037a840)({ - fullName: (string) (len=5) "Empty", - name: (string) (len=5) "Empty", - fields: ([]*main.Field) - }), - (string) (len=17) "GetAppUserRequest": (*main.Message)(0xc00037ab80)({ - fullName: (string) (len=17) "GetAppUserRequest", - name: (string) (len=17) "GetAppUserRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008ee70)({ - name: (string) (len=15) "user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=24) "PayAppUserInvoiceRequest": (*main.Message)(0xc00037abc0)({ - fullName: (string) (len=24) "PayAppUserInvoiceRequest", - name: (string) (len=24) "PayAppUserInvoiceRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00008eed0)({ - name: (string) (len=15) "user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008ef00)({ + (*main.Field)(0xc0001a5740)({ name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1381,56 +1282,14 @@ isEnum: (bool) false, isMessage: (bool) false, isOptional: (bool) false - }), - (*main.Field)(0xc00008ef30)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false }) } }), - (string) (len=17) "PayAddressRequest": (*main.Message)(0xc00037adc0)({ - fullName: (string) (len=17) "PayAddressRequest", - name: (string) (len=17) "PayAddressRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00008f2f0)({ - name: (string) (len=7) "address", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f320)({ - name: (string) (len=9) "amoutSats", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f350)({ - name: (string) (len=12) "satsPerVByte", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "PayInvoiceRequest": (*main.Message)(0xc00037af40)({ + (string) (len=17) "PayInvoiceRequest": (*main.Message)(0xc00043efc0)({ fullName: (string) (len=17) "PayInvoiceRequest", name: (string) (len=17) "PayInvoiceRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00008f530)({ + (*main.Field)(0xc0001a57a0)({ name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1439,7 +1298,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00008f560)({ + (*main.Field)(0xc0001a57d0)({ name: (string) (len=6) "amount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1450,12 +1309,12 @@ }) } }), - (string) (len=24) "AddAppUserInvoiceRequest": (*main.Message)(0xc00037ab40)({ - fullName: (string) (len=24) "AddAppUserInvoiceRequest", - name: (string) (len=24) "AddAppUserInvoiceRequest", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc00008e750)({ - name: (string) (len=19) "receiver_identifier", + (string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc00043f040)({ + fullName: (string) (len=18) "PayInvoiceResponse", + name: (string) (len=18) "PayInvoiceResponse", + fields: ([]*main.Field) (len=5 cap=8) { + (*main.Field)(0xc0001a5800)({ + name: (string) (len=8) "preimage", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1463,8 +1322,17 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00008ede0)({ - name: (string) (len=16) "payer_identifier", + (*main.Field)(0xc0001a5830)({ + name: (string) (len=11) "amount_paid", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5860)({ + name: (string) (len=12) "operation_id", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1472,8 +1340,32 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00008ee10)({ - name: (string) (len=17) "http_callback_url", + (*main.Field)(0xc0001a5890)({ + name: (string) (len=11) "service_fee", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a58c0)({ + name: (string) (len=11) "network_fee", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=27) "SetMockInvoiceAsPaidRequest": (*main.Message)(0xc00043e980)({ + fullName: (string) (len=27) "SetMockInvoiceAsPaidRequest", + name: (string) (len=27) "SetMockInvoiceAsPaidRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a4d80)({ + name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1481,86 +1373,41 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00008ee40)({ - name: (string) (len=11) "invoice_req", - kind: (string) (len=17) "NewInvoiceRequest", + (*main.Field)(0xc0001a4db0)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=7) "AppUser": (*main.Message)(0xc00043eb40)({ + fullName: (string) (len=7) "AppUser", + name: (string) (len=7) "AppUser", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001a5080)({ + name: (string) (len=10) "identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a50b0)({ + name: (string) (len=4) "info", + kind: (string) (len=8) "UserInfo", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, isMessage: (bool) true, isOptional: (bool) false - }) - } - }), - (string) (len=18) "NewAddressResponse": (*main.Message)(0xc00037ad80)({ - fullName: (string) (len=18) "NewAddressResponse", - name: (string) (len=18) "NewAddressResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f2c0)({ - name: (string) (len=7) "address", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "NewInvoiceRequest": (*main.Message)(0xc00037ae40)({ - fullName: (string) (len=17) "NewInvoiceRequest", - name: (string) (len=17) "NewInvoiceRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00008f440)({ - name: (string) (len=10) "amountSats", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false }), - (*main.Field)(0xc00008f470)({ - name: (string) (len=4) "memo", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=25) "EncryptionExchangeRequest": (*main.Message)(0xc00037a880)({ - fullName: (string) (len=25) "EncryptionExchangeRequest", - name: (string) (len=25) "EncryptionExchangeRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0004a7ce0)({ - name: (string) (len=9) "publicKey", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0004a7d10)({ - name: (string) (len=8) "deviceId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc00037a8c0)({ - fullName: (string) (len=17) "LndGetInfoRequest", - name: (string) (len=17) "LndGetInfoRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0004a7d40)({ - name: (string) (len=6) "nodeId", + (*main.Field)(0xc0001a50e0)({ + name: (string) (len=16) "max_withdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -1570,12 +1417,27 @@ }) } }), - (string) (len=27) "SetMockInvoiceAsPaidRequest": (*main.Message)(0xc00037a900)({ - fullName: (string) (len=27) "SetMockInvoiceAsPaidRequest", - name: (string) (len=27) "SetMockInvoiceAsPaidRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0004a7d70)({ - name: (string) (len=7) "invoice", + (string) (len=17) "GetAppUserRequest": (*main.Message)(0xc00043ec00)({ + fullName: (string) (len=17) "GetAppUserRequest", + name: (string) (len=17) "GetAppUserRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a5260)({ + name: (string) (len=15) "user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=7) "Product": (*main.Message)(0xc00043f4c0)({ + fullName: (string) (len=7) "Product", + name: (string) (len=7) "Product", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc000326300)({ + name: (string) (len=2) "id", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1583,37 +1445,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0004a7da0)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc00037a940)({ - fullName: (string) (len=18) "LndGetInfoResponse", - name: (string) (len=18) "LndGetInfoResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0004a7dd0)({ - name: (string) (len=5) "alias", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=14) "AuthAppRequest": (*main.Message)(0xc00037a9c0)({ - fullName: (string) (len=14) "AuthAppRequest", - name: (string) (len=14) "AuthAppRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0004a7e60)({ + (*main.Field)(0xc000326330)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1622,31 +1454,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0004a7e90)({ - name: (string) (len=19) "allow_user_creation", - kind: (string) (len=4) "bool", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) true - }) - } - }), - (string) (len=17) "AddProductRequest": (*main.Message)(0xc00037b400)({ - fullName: (string) (len=17) "AddProductRequest", - name: (string) (len=17) "AddProductRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0001f9e30)({ - name: (string) (len=4) "name", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f9e60)({ + (*main.Field)(0xc000326360)({ name: (string) (len=10) "price_sats", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1657,11 +1465,11 @@ }) } }), - (string) (len=22) "HandleLnurlPayResponse": (*main.Message)(0xc00037b1c0)({ + (string) (len=22) "HandleLnurlPayResponse": (*main.Message)(0xc00043f240)({ fullName: (string) (len=22) "HandleLnurlPayResponse", name: (string) (len=22) "HandleLnurlPayResponse", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0001f86c0)({ + (*main.Field)(0xc0001a5d10)({ name: (string) (len=2) "pr", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1670,7 +1478,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f87e0)({ + (*main.Field)(0xc0001a5d40)({ name: (string) (len=6) "routes", kind: (string) (len=5) "Empty", isMap: (bool) false, @@ -1681,293 +1489,11 @@ }) } }), - (string) (len=7) "Product": (*main.Message)(0xc00037b440)({ - fullName: (string) (len=7) "Product", - name: (string) (len=7) "Product", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0001f9e90)({ - name: (string) (len=2) "id", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f9ec0)({ - name: (string) (len=4) "name", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0002feae0)({ - name: (string) (len=10) "price_sats", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=16) "ClosureMigration": (*main.Message)(0xc00037b540)({ - fullName: (string) (len=16) "ClosureMigration", - name: (string) (len=16) "ClosureMigration", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0001d4090)({ - name: (string) (len=14) "closes_at_unix", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=7) "AuthApp": (*main.Message)(0xc00037aa40)({ - fullName: (string) (len=7) "AuthApp", - name: (string) (len=7) "AuthApp", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0004a7f80)({ - name: (string) (len=3) "app", - kind: (string) (len=11) "Application", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc0004a7fb0)({ - name: (string) (len=10) "auth_token", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "AddAppUserRequest": (*main.Message)(0xc00037aa80)({ - fullName: (string) (len=17) "AddAppUserRequest", - name: (string) (len=17) "AddAppUserRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00008e1e0)({ - name: (string) (len=10) "identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008e210)({ - name: (string) (len=14) "fail_if_exists", - kind: (string) (len=4) "bool", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008e270)({ - name: (string) (len=7) "balance", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc00037ae80)({ - fullName: (string) (len=18) "NewInvoiceResponse", - name: (string) (len=18) "NewInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f4a0)({ - name: (string) (len=7) "invoice", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=19) "OpenChannelResponse": (*main.Message)(0xc00037b040)({ - fullName: (string) (len=19) "OpenChannelResponse", - name: (string) (len=19) "OpenChannelResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f8c0)({ - name: (string) (len=9) "channelId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=20) "LnurlPayInfoResponse": (*main.Message)(0xc00037b180)({ - fullName: (string) (len=20) "LnurlPayInfoResponse", - name: (string) (len=20) "LnurlPayInfoResponse", - fields: ([]*main.Field) (len=7 cap=8) { - (*main.Field)(0xc0001f8000)({ - name: (string) (len=3) "tag", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8030)({ - name: (string) (len=8) "callback", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8060)({ - name: (string) (len=11) "maxSendable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8090)({ - name: (string) (len=11) "minSendable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8630)({ - name: (string) (len=8) "metadata", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8660)({ - name: (string) (len=11) "allowsNostr", - kind: (string) (len=4) "bool", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8690)({ - name: (string) (len=11) "nostrPubkey", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=25) "GetProductBuyLinkResponse": (*main.Message)(0xc00037b480)({ - fullName: (string) (len=25) "GetProductBuyLinkResponse", - name: (string) (len=25) "GetProductBuyLinkResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0002feb10)({ - name: (string) (len=4) "link", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=7) "AppUser": (*main.Message)(0xc00037aac0)({ - fullName: (string) (len=7) "AppUser", - name: (string) (len=7) "AppUser", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00008e2a0)({ - name: (string) (len=10) "identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008e300)({ - name: (string) (len=4) "info", - kind: (string) (len=8) "UserInfo", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc00008e330)({ - name: (string) (len=16) "max_withdrawable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "NewAddressRequest": (*main.Message)(0xc00037ad40)({ - fullName: (string) (len=17) "NewAddressRequest", - name: (string) (len=17) "NewAddressRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f290)({ - name: (string) (len=11) "addressType", - kind: (string) (len=11) "AddressType", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) true, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=20) "DecodeInvoiceRequest": (*main.Message)(0xc00037aec0)({ - fullName: (string) (len=20) "DecodeInvoiceRequest", - name: (string) (len=20) "DecodeInvoiceRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f4d0)({ - name: (string) (len=7) "invoice", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=8) "UserInfo": (*main.Message)(0xc00037b200)({ + (string) (len=8) "UserInfo": (*main.Message)(0xc00043f280)({ fullName: (string) (len=8) "UserInfo", name: (string) (len=8) "UserInfo", fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0001f8810)({ + (*main.Field)(0xc0001a5d70)({ name: (string) (len=6) "userId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1976,7 +1502,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f8840)({ + (*main.Field)(0xc0001a5da0)({ name: (string) (len=7) "balance", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1985,7 +1511,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f8870)({ + (*main.Field)(0xc0001a5dd0)({ name: (string) (len=16) "max_withdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1996,11 +1522,11 @@ }) } }), - (string) (len=14) "UserOperations": (*main.Message)(0xc00037b340)({ + (string) (len=14) "UserOperations": (*main.Message)(0xc00043f3c0)({ fullName: (string) (len=14) "UserOperations", name: (string) (len=14) "UserOperations", fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0001f96b0)({ + (*main.Field)(0xc0003260f0)({ name: (string) (len=9) "fromIndex", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2009,7 +1535,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9860)({ + (*main.Field)(0xc000326120)({ name: (string) (len=7) "toIndex", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2018,7 +1544,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9890)({ + (*main.Field)(0xc000326150)({ name: (string) (len=10) "operations", kind: (string) (len=13) "UserOperation", isMap: (bool) false, @@ -2029,224 +1555,41 @@ }) } }), - (string) (len=30) "SendAppUserToAppPaymentRequest": (*main.Message)(0xc00037ac40)({ - fullName: (string) (len=30) "SendAppUserToAppPaymentRequest", - name: (string) (len=30) "SendAppUserToAppPaymentRequest", + (string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc00043ef00)({ + fullName: (string) (len=18) "NewInvoiceResponse", + name: (string) (len=18) "NewInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a5710)({ + name: (string) (len=7) "invoice", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=19) "OpenChannelResponse": (*main.Message)(0xc00043f0c0)({ + fullName: (string) (len=19) "OpenChannelResponse", + name: (string) (len=19) "OpenChannelResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a59b0)({ + name: (string) (len=9) "channelId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "AddProductRequest": (*main.Message)(0xc00043f480)({ + fullName: (string) (len=17) "AddProductRequest", + name: (string) (len=17) "AddProductRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00008f140)({ - name: (string) (len=20) "from_user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f170)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc00037afc0)({ - fullName: (string) (len=18) "PayInvoiceResponse", - name: (string) (len=18) "PayInvoiceResponse", - fields: ([]*main.Field) (len=5 cap=8) { - (*main.Field)(0xc00008f590)({ - name: (string) (len=8) "preimage", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f5c0)({ - name: (string) (len=11) "amount_paid", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f5f0)({ - name: (string) (len=12) "operation_id", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f620)({ - name: (string) (len=11) "service_fee", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f650)({ - name: (string) (len=11) "network_fee", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=25) "LnurlWithdrawInfoResponse": (*main.Message)(0xc00037b100)({ - fullName: (string) (len=25) "LnurlWithdrawInfoResponse", - name: (string) (len=25) "LnurlWithdrawInfoResponse", - fields: ([]*main.Field) (len=8 cap=8) { - (*main.Field)(0xc00008fad0)({ - name: (string) (len=3) "tag", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fb00)({ - name: (string) (len=8) "callback", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fb30)({ - name: (string) (len=2) "k1", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fb60)({ - name: (string) (len=18) "defaultDescription", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fdd0)({ - name: (string) (len=15) "minWithdrawable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fe00)({ - name: (string) (len=15) "maxWithdrawable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fe30)({ - name: (string) (len=12) "balanceCheck", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008fe60)({ - name: (string) (len=7) "payLink", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=24) "GetUserOperationsRequest": (*main.Message)(0xc00037b280)({ - fullName: (string) (len=24) "GetUserOperationsRequest", - name: (string) (len=24) "GetUserOperationsRequest", - fields: ([]*main.Field) (len=6 cap=8) { - (*main.Field)(0xc0001f8a20)({ - name: (string) (len=21) "latestIncomingInvoice", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8a50)({ - name: (string) (len=21) "latestOutgoingInvoice", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8a80)({ - name: (string) (len=16) "latestIncomingTx", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8ab0)({ - name: (string) (len=16) "latestOutgoingTx", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8c30)({ - name: (string) (len=31) "latestIncomingUserToUserPayment", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0001f8c60)({ - name: (string) (len=31) "latestOutgoingUserToUserPayment", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=11) "Application": (*main.Message)(0xc00037aa00)({ - fullName: (string) (len=11) "Application", - name: (string) (len=11) "Application", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc0004a7ec0)({ + (*main.Field)(0xc0003262a0)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2255,101 +1598,8 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0004a7ef0)({ - name: (string) (len=2) "id", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0004a7f20)({ - name: (string) (len=7) "balance", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0004a7f50)({ - name: (string) (len=4) "npub", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=20) "AddAppInvoiceRequest": (*main.Message)(0xc00037ab00)({ - fullName: (string) (len=20) "AddAppInvoiceRequest", - name: (string) (len=20) "AddAppInvoiceRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00008e570)({ - name: (string) (len=16) "payer_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008e690)({ - name: (string) (len=17) "http_callback_url", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008e6c0)({ - name: (string) (len=11) "invoice_req", - kind: (string) (len=17) "NewInvoiceRequest", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "PayAddressResponse": (*main.Message)(0xc00037ae00)({ - fullName: (string) (len=18) "PayAddressResponse", - name: (string) (len=18) "PayAddressResponse", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc00008f380)({ - name: (string) (len=4) "txId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f3b0)({ - name: (string) (len=12) "operation_id", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f3e0)({ - name: (string) (len=11) "service_fee", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f410)({ - name: (string) (len=11) "network_fee", + (*main.Field)(0xc0003262d0)({ + name: (string) (len=10) "price_sats", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -2359,12 +1609,84 @@ }) } }), - (string) (len=21) "DecodeInvoiceResponse": (*main.Message)(0xc00037af00)({ - fullName: (string) (len=21) "DecodeInvoiceResponse", - name: (string) (len=21) "DecodeInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00008f500)({ - name: (string) (len=6) "amount", + (string) (len=11) "UsageMetric": (*main.Message)(0xc00043e8c0)({ + fullName: (string) (len=11) "UsageMetric", + name: (string) (len=11) "UsageMetric", + fields: ([]*main.Field) (len=9 cap=16) { + (*main.Field)(0xc0001a4b70)({ + name: (string) (len=17) "processed_at_nano", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4ba0)({ + name: (string) (len=14) "parsed_in_nano", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4bd0)({ + name: (string) (len=12) "auth_in_nano", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4c00)({ + name: (string) (len=16) "validate_in_nano", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4c30)({ + name: (string) (len=14) "handle_in_nano", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4c60)({ + name: (string) (len=8) "rpc_name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4c90)({ + name: (string) (len=5) "batch", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4cc0)({ + name: (string) (len=5) "nostr", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4cf0)({ + name: (string) (len=10) "batch_size", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -2374,50 +1696,11 @@ }) } }), - (string) (len=17) "LnurlLinkResponse": (*main.Message)(0xc00037b080)({ - fullName: (string) (len=17) "LnurlLinkResponse", - name: (string) (len=17) "LnurlLinkResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00008f8f0)({ - name: (string) (len=5) "lnurl", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f920)({ - name: (string) (len=2) "k1", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=15) "RelaysMigration": (*main.Message)(0xc00037b580)({ - fullName: (string) (len=15) "RelaysMigration", - name: (string) (len=15) "RelaysMigration", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0001d40c0)({ - name: (string) (len=6) "relays", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) true, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=13) "AddAppRequest": (*main.Message)(0xc00037a980)({ + (string) (len=13) "AddAppRequest": (*main.Message)(0xc00043ea00)({ fullName: (string) (len=13) "AddAppRequest", name: (string) (len=13) "AddAppRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0004a7e00)({ + (*main.Field)(0xc0001a4e10)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2426,7 +1709,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0004a7e30)({ + (*main.Field)(0xc0001a4e40)({ name: (string) (len=19) "allow_user_creation", kind: (string) (len=4) "bool", isMap: (bool) false, @@ -2437,72 +1720,21 @@ }) } }), - (string) (len=34) "SendAppUserToAppUserPaymentRequest": (*main.Message)(0xc00037ac00)({ - fullName: (string) (len=34) "SendAppUserToAppUserPaymentRequest", - name: (string) (len=34) "SendAppUserToAppUserPaymentRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00008ef60)({ - name: (string) (len=20) "from_user_identifier", - kind: (string) (len=6) "string", + (string) (len=7) "AuthApp": (*main.Message)(0xc00043eac0)({ + fullName: (string) (len=7) "AuthApp", + name: (string) (len=7) "AuthApp", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a4f90)({ + name: (string) (len=3) "app", + kind: (string) (len=11) "Application", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, - isMessage: (bool) false, + isMessage: (bool) true, isOptional: (bool) false }), - (*main.Field)(0xc00008ef90)({ - name: (string) (len=18) "to_user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f080)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "OpenChannelRequest": (*main.Message)(0xc00037b000)({ - fullName: (string) (len=18) "OpenChannelRequest", - name: (string) (len=18) "OpenChannelRequest", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc00008f680)({ - name: (string) (len=11) "destination", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f830)({ - name: (string) (len=13) "fundingAmount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f860)({ - name: (string) (len=10) "pushAmount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00008f890)({ - name: (string) (len=12) "closeAddress", + (*main.Field)(0xc0001a4fc0)({ + name: (string) (len=10) "auth_token", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -2512,11 +1744,11 @@ }) } }), - (string) (len=13) "UserOperation": (*main.Message)(0xc00037b300)({ + (string) (len=13) "UserOperation": (*main.Message)(0xc00043f380)({ fullName: (string) (len=13) "UserOperation", name: (string) (len=13) "UserOperation", fields: ([]*main.Field) (len=9 cap=16) { - (*main.Field)(0xc0001f8c90)({ + (*main.Field)(0xc0001a5f20)({ name: (string) (len=10) "paidAtUnix", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2525,7 +1757,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f8cc0)({ + (*main.Field)(0xc0001a5f50)({ name: (string) (len=4) "type", kind: (string) (len=17) "UserOperationType", isMap: (bool) false, @@ -2534,7 +1766,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f94a0)({ + (*main.Field)(0xc0001a5f80)({ name: (string) (len=7) "inbound", kind: (string) (len=4) "bool", isMap: (bool) false, @@ -2543,7 +1775,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f94d0)({ + (*main.Field)(0xc0001a5fb0)({ name: (string) (len=6) "amount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2552,7 +1784,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9500)({ + (*main.Field)(0xc000326000)({ name: (string) (len=10) "identifier", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2561,7 +1793,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9530)({ + (*main.Field)(0xc000326030)({ name: (string) (len=11) "operationId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2570,7 +1802,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9620)({ + (*main.Field)(0xc000326060)({ name: (string) (len=11) "service_fee", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2579,7 +1811,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9650)({ + (*main.Field)(0xc000326090)({ name: (string) (len=11) "network_fee", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2588,7 +1820,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0001f9680)({ + (*main.Field)(0xc0003260c0)({ name: (string) (len=9) "confirmed", kind: (string) (len=4) "bool", isMap: (bool) false, @@ -2599,11 +1831,236 @@ }) } }), - (string) (len=17) "LiveUserOperation": (*main.Message)(0xc00037b4c0)({ + (string) (len=20) "AddAppInvoiceRequest": (*main.Message)(0xc00043eb80)({ + fullName: (string) (len=20) "AddAppInvoiceRequest", + name: (string) (len=20) "AddAppInvoiceRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001a5110)({ + name: (string) (len=16) "payer_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5140)({ + name: (string) (len=17) "http_callback_url", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5170)({ + name: (string) (len=11) "invoice_req", + kind: (string) (len=17) "NewInvoiceRequest", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "NewInvoiceRequest": (*main.Message)(0xc00043eec0)({ + fullName: (string) (len=17) "NewInvoiceRequest", + name: (string) (len=17) "NewInvoiceRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a56b0)({ + name: (string) (len=10) "amountSats", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a56e0)({ + name: (string) (len=4) "memo", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=25) "LnurlWithdrawInfoResponse": (*main.Message)(0xc00043f180)({ + fullName: (string) (len=25) "LnurlWithdrawInfoResponse", + name: (string) (len=25) "LnurlWithdrawInfoResponse", + fields: ([]*main.Field) (len=8 cap=8) { + (*main.Field)(0xc0001a5a40)({ + name: (string) (len=3) "tag", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5a70)({ + name: (string) (len=8) "callback", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5aa0)({ + name: (string) (len=2) "k1", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5ad0)({ + name: (string) (len=18) "defaultDescription", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5b00)({ + name: (string) (len=15) "minWithdrawable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5b30)({ + name: (string) (len=15) "maxWithdrawable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5b60)({ + name: (string) (len=12) "balanceCheck", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5b90)({ + name: (string) (len=7) "payLink", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=11) "Application": (*main.Message)(0xc00043ea80)({ + fullName: (string) (len=11) "Application", + name: (string) (len=11) "Application", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc0001a4ed0)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4f00)({ + name: (string) (len=2) "id", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4f30)({ + name: (string) (len=7) "balance", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4f60)({ + name: (string) (len=4) "npub", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=34) "SendAppUserToAppUserPaymentRequest": (*main.Message)(0xc00043ec80)({ + fullName: (string) (len=34) "SendAppUserToAppUserPaymentRequest", + name: (string) (len=34) "SendAppUserToAppUserPaymentRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001a5320)({ + name: (string) (len=20) "from_user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5350)({ + name: (string) (len=18) "to_user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5380)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=24) "SetMockAppBalanceRequest": (*main.Message)(0xc00043ed80)({ + fullName: (string) (len=24) "SetMockAppBalanceRequest", + name: (string) (len=24) "SetMockAppBalanceRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a54d0)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "LiveUserOperation": (*main.Message)(0xc00043f540)({ fullName: (string) (len=17) "LiveUserOperation", name: (string) (len=17) "LiveUserOperation", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0001d4000)({ + (*main.Field)(0xc0003263c0)({ name: (string) (len=9) "operation", kind: (string) (len=13) "UserOperation", isMap: (bool) false, @@ -2613,10 +2070,684 @@ isOptional: (bool) false }) } + }), + (string) (len=16) "ClosureMigration": (*main.Message)(0xc00043f5c0)({ + fullName: (string) (len=16) "ClosureMigration", + name: (string) (len=16) "ClosureMigration", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000326450)({ + name: (string) (len=14) "closes_at_unix", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=5) "Empty": (*main.Message)(0xc00043e800)({ + fullName: (string) (len=5) "Empty", + name: (string) (len=5) "Empty", + fields: ([]*main.Field) + }), + (string) (len=25) "EncryptionExchangeRequest": (*main.Message)(0xc00043e840)({ + fullName: (string) (len=25) "EncryptionExchangeRequest", + name: (string) (len=25) "EncryptionExchangeRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a4b10)({ + name: (string) (len=9) "publicKey", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4b40)({ + name: (string) (len=8) "deviceId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc00043e940)({ + fullName: (string) (len=17) "LndGetInfoRequest", + name: (string) (len=17) "LndGetInfoRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a4d50)({ + name: (string) (len=6) "nodeId", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=24) "GetUserOperationsRequest": (*main.Message)(0xc00043f300)({ + fullName: (string) (len=24) "GetUserOperationsRequest", + name: (string) (len=24) "GetUserOperationsRequest", + fields: ([]*main.Field) (len=6 cap=8) { + (*main.Field)(0xc0001a5e00)({ + name: (string) (len=21) "latestIncomingInvoice", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5e30)({ + name: (string) (len=21) "latestOutgoingInvoice", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5e60)({ + name: (string) (len=16) "latestIncomingTx", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5e90)({ + name: (string) (len=16) "latestOutgoingTx", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5ec0)({ + name: (string) (len=31) "latestIncomingUserToUserPayment", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5ef0)({ + name: (string) (len=31) "latestOutgoingUserToUserPayment", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=25) "GetUserOperationsResponse": (*main.Message)(0xc00043f440)({ + fullName: (string) (len=25) "GetUserOperationsResponse", + name: (string) (len=25) "GetUserOperationsResponse", + fields: ([]*main.Field) (len=6 cap=8) { + (*main.Field)(0xc000326180)({ + name: (string) (len=31) "latestOutgoingInvoiceOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0003261b0)({ + name: (string) (len=31) "latestIncomingInvoiceOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0003261e0)({ + name: (string) (len=26) "latestOutgoingTxOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc000326210)({ + name: (string) (len=26) "latestIncomingTxOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc000326240)({ + name: (string) (len=32) "latestOutgoingUserToUserPayemnts", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc000326270)({ + name: (string) (len=32) "latestIncomingUserToUserPayemnts", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=25) "GetProductBuyLinkResponse": (*main.Message)(0xc00043f500)({ + fullName: (string) (len=25) "GetProductBuyLinkResponse", + name: (string) (len=25) "GetProductBuyLinkResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000326390)({ + name: (string) (len=4) "link", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=15) "MigrationUpdate": (*main.Message)(0xc00043f580)({ + fullName: (string) (len=15) "MigrationUpdate", + name: (string) (len=15) "MigrationUpdate", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0003263f0)({ + name: (string) (len=7) "closure", + kind: (string) (len=16) "ClosureMigration", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) true + }), + (*main.Field)(0xc000326420)({ + name: (string) (len=6) "relays", + kind: (string) (len=15) "RelaysMigration", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) true + }) + } + }), + (string) (len=24) "PayAppUserInvoiceRequest": (*main.Message)(0xc00043ec40)({ + fullName: (string) (len=24) "PayAppUserInvoiceRequest", + name: (string) (len=24) "PayAppUserInvoiceRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001a5290)({ + name: (string) (len=15) "user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a52c0)({ + name: (string) (len=7) "invoice", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a52f0)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "NewAddressResponse": (*main.Message)(0xc00043ee00)({ + fullName: (string) (len=18) "NewAddressResponse", + name: (string) (len=18) "NewAddressResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a5530)({ + name: (string) (len=7) "address", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=21) "DecodeInvoiceResponse": (*main.Message)(0xc00043ef80)({ + fullName: (string) (len=21) "DecodeInvoiceResponse", + name: (string) (len=21) "DecodeInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a5770)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=14) "AuthAppRequest": (*main.Message)(0xc00043ea40)({ + fullName: (string) (len=14) "AuthAppRequest", + name: (string) (len=14) "AuthAppRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a4e70)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a4ea0)({ + name: (string) (len=19) "allow_user_creation", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) true + }) + } + }), + (string) (len=17) "PayAddressRequest": (*main.Message)(0xc00043ee40)({ + fullName: (string) (len=17) "PayAddressRequest", + name: (string) (len=17) "PayAddressRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001a5560)({ + name: (string) (len=7) "address", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5590)({ + name: (string) (len=9) "amoutSats", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a55c0)({ + name: (string) (len=12) "satsPerVByte", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "OpenChannelRequest": (*main.Message)(0xc00043f080)({ + fullName: (string) (len=18) "OpenChannelRequest", + name: (string) (len=18) "OpenChannelRequest", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc0001a58f0)({ + name: (string) (len=11) "destination", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5920)({ + name: (string) (len=13) "fundingAmount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5950)({ + name: (string) (len=10) "pushAmount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5980)({ + name: (string) (len=12) "closeAddress", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "PayAddressResponse": (*main.Message)(0xc00043ee80)({ + fullName: (string) (len=18) "PayAddressResponse", + name: (string) (len=18) "PayAddressResponse", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc0001a55f0)({ + name: (string) (len=4) "txId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5620)({ + name: (string) (len=12) "operation_id", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5650)({ + name: (string) (len=11) "service_fee", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5680)({ + name: (string) (len=11) "network_fee", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "LnurlLinkResponse": (*main.Message)(0xc00043f100)({ + fullName: (string) (len=17) "LnurlLinkResponse", + name: (string) (len=17) "LnurlLinkResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a59e0)({ + name: (string) (len=5) "lnurl", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5a10)({ + name: (string) (len=2) "k1", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=15) "RelaysMigration": (*main.Message)(0xc00043f600)({ + fullName: (string) (len=15) "RelaysMigration", + name: (string) (len=15) "RelaysMigration", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000326480)({ + name: (string) (len=6) "relays", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) true, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc00043e9c0)({ + fullName: (string) (len=18) "LndGetInfoResponse", + name: (string) (len=18) "LndGetInfoResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a4de0)({ + name: (string) (len=5) "alias", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=30) "SendAppUserToAppPaymentRequest": (*main.Message)(0xc00043ecc0)({ + fullName: (string) (len=30) "SendAppUserToAppPaymentRequest", + name: (string) (len=30) "SendAppUserToAppPaymentRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001a53b0)({ + name: (string) (len=20) "from_user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a53e0)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "NewAddressRequest": (*main.Message)(0xc00043edc0)({ + fullName: (string) (len=17) "NewAddressRequest", + name: (string) (len=17) "NewAddressRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a5500)({ + name: (string) (len=11) "addressType", + kind: (string) (len=11) "AddressType", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) true, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=20) "LnurlPayInfoResponse": (*main.Message)(0xc00043f200)({ + fullName: (string) (len=20) "LnurlPayInfoResponse", + name: (string) (len=20) "LnurlPayInfoResponse", + fields: ([]*main.Field) (len=7 cap=8) { + (*main.Field)(0xc0001a5bc0)({ + name: (string) (len=3) "tag", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5bf0)({ + name: (string) (len=8) "callback", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5c20)({ + name: (string) (len=11) "maxSendable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5c50)({ + name: (string) (len=11) "minSendable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5c80)({ + name: (string) (len=8) "metadata", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5cb0)({ + name: (string) (len=11) "allowsNostr", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5ce0)({ + name: (string) (len=11) "nostrPubkey", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=12) "UsageMetrics": (*main.Message)(0xc00043e900)({ + fullName: (string) (len=12) "UsageMetrics", + name: (string) (len=12) "UsageMetrics", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0001a4d20)({ + name: (string) (len=7) "metrics", + kind: (string) (len=11) "UsageMetric", + isMap: (bool) false, + isArray: (bool) true, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "AddAppUserRequest": (*main.Message)(0xc00043eb00)({ + fullName: (string) (len=17) "AddAppUserRequest", + name: (string) (len=17) "AddAppUserRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001a4ff0)({ + name: (string) (len=10) "identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5020)({ + name: (string) (len=14) "fail_if_exists", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5050)({ + name: (string) (len=7) "balance", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=24) "AddAppUserInvoiceRequest": (*main.Message)(0xc00043ebc0)({ + fullName: (string) (len=24) "AddAppUserInvoiceRequest", + name: (string) (len=24) "AddAppUserInvoiceRequest", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc0001a51a0)({ + name: (string) (len=19) "receiver_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a51d0)({ + name: (string) (len=16) "payer_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5200)({ + name: (string) (len=17) "http_callback_url", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001a5230)({ + name: (string) (len=11) "invoice_req", + kind: (string) (len=17) "NewInvoiceRequest", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } }) } -parsing file: structs 48 +parsing file: structs 50 parsing file: methods 2 -> [{guest Guest map[]} {user User map[app_id:string app_user_id:string user_id:string]} {admin Admin map[admin_id:string]} {app App map[app_id:string]}] diff --git a/proto/autogenerated/ts/express_server.ts b/proto/autogenerated/ts/express_server.ts index 0772f337..bb890c29 100644 --- a/proto/autogenerated/ts/express_server.ts +++ b/proto/autogenerated/ts/express_server.ts @@ -12,584 +12,954 @@ export type ServerOptions = { throwErrors?: true logMethod?: true logBody?: true + metricsCallback: (metrics: Types.RequestMetric[]) => void GuestAuthGuard: (authorizationHeader?: string) => Promise UserAuthGuard: (authorizationHeader?: string) => Promise AdminAuthGuard: (authorizationHeader?: string) => Promise AppAuthGuard: (authorizationHeader?: string) => Promise } -const logErrorAndReturnResponse = (error: Error, response: string, res: Response, logger: Logger) => { logger.error(error.message || error); res.json({ status: 'ERROR', reason: response }) } +declare module 'express-serve-static-core' { interface Request { startTime?: bigint, bodySize?: number } } +const logErrorAndReturnResponse = (error: Error, response: string, res: Response, logger: Logger, metric: Types.RequestMetric, metricsCallback: (metrics: Types.RequestMetric[]) => void) => { + logger.error(error.message || error); metricsCallback([{ ...metric, error: response }]); res.json({ status: 'ERROR', reason: response }) +} export default (methods: Types.ServerMethods, opts: ServerOptions) => { const logger = opts.logger || { log: console.log, error: console.error } const app = express() if (opts.allowCors) { app.use(cors()) } + app.use((req, _, next) => { req.startTime = process.hrtime.bigint(); next() }) app.use(json()) app.use(urlencoded({ extended: true })) if (opts.logMethod) app.use((req, _, next) => { console.log(req.method, req.path); if (opts.logBody) console.log(req.body); next() }) if (!opts.allowNotImplementedMethods && !methods.LndGetInfo) throw new Error('method: LndGetInfo is not implemented') app.post('/api/admin/lnd/getinfo', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'LndGetInfo', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.LndGetInfo) throw new Error('method: LndGetInfo 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.LndGetInfoRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.LndGetInfo({rpcName:'LndGetInfo', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AddApp) throw new Error('method: AddApp is not implemented') app.post('/api/admin/app/add', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'AddApp', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.AddApp) throw new Error('method: AddApp 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.AddAppRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.AddApp({rpcName:'AddApp', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AuthApp) throw new Error('method: AuthApp is not implemented') app.post('/api/admin/app/auth', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'AuthApp', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.AuthApp) throw new Error('method: AuthApp 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.AuthAppRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.AuthApp({rpcName:'AuthApp', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetMetrics) throw new Error('method: GetMetrics is not implemented') + app.post('/api/admin/metrics', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetMetrics', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} + try { + if (!methods.GetMetrics) throw new Error('method: GetMetrics is not implemented') + const authContext = await opts.AdminAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard + const query = req.query + const params = req.params + const response = await methods.GetMetrics({rpcName:'GetMetrics', ctx:authContext }) + 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.Health) throw new Error('method: Health is not implemented') app.get('/api/health', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'Health', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.Health) throw new Error('method: Health is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params await methods.Health({rpcName:'Health', ctx:authContext }) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.EncryptionExchange) throw new Error('method: EncryptionExchange is not implemented') app.post('/api/encryption/exchange', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'EncryptionExchange', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.EncryptionExchange) throw new Error('method: EncryptionExchange is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.EncryptionExchangeRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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 await methods.EncryptionExchange({rpcName:'EncryptionExchange', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.SetMockInvoiceAsPaid) throw new Error('method: SetMockInvoiceAsPaid is not implemented') app.post('/api/lnd/mock/invoice/paid', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'SetMockInvoiceAsPaid', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.SetMockInvoiceAsPaid) throw new Error('method: SetMockInvoiceAsPaid is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.SetMockInvoiceAsPaidRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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 await methods.SetMockInvoiceAsPaid({rpcName:'SetMockInvoiceAsPaid', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetLnurlWithdrawInfo) throw new Error('method: GetLnurlWithdrawInfo is not implemented') app.get('/api/guest/lnurl_withdraw/info', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetLnurlWithdrawInfo', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetLnurlWithdrawInfo) throw new Error('method: GetLnurlWithdrawInfo is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetLnurlWithdrawInfo({rpcName:'GetLnurlWithdrawInfo', ctx:authContext ,query: req.query}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.HandleLnurlWithdraw) throw new Error('method: HandleLnurlWithdraw is not implemented') app.get('/api/guest/lnurl_withdraw/handle', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'HandleLnurlWithdraw', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.HandleLnurlWithdraw) throw new Error('method: HandleLnurlWithdraw is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params await methods.HandleLnurlWithdraw({rpcName:'HandleLnurlWithdraw', ctx:authContext ,query: req.query}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetLnurlPayInfo) throw new Error('method: GetLnurlPayInfo is not implemented') app.get('/api/guest/lnurl_pay/info', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetLnurlPayInfo', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetLnurlPayInfo) throw new Error('method: GetLnurlPayInfo is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetLnurlPayInfo({rpcName:'GetLnurlPayInfo', ctx:authContext ,query: req.query}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.HandleLnurlPay) throw new Error('method: HandleLnurlPay is not implemented') app.get('/api/guest/lnurl_pay/handle', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'HandleLnurlPay', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.HandleLnurlPay) throw new Error('method: HandleLnurlPay is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.HandleLnurlPay({rpcName:'HandleLnurlPay', ctx:authContext ,query: req.query}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.HandleLnurlAddress) throw new Error('method: HandleLnurlAddress is not implemented') app.get('/.well-known/lnurlp/:address_name', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'HandleLnurlAddress', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.HandleLnurlAddress) throw new Error('method: HandleLnurlAddress is not implemented') const authContext = await opts.GuestAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.HandleLnurlAddress({rpcName:'HandleLnurlAddress', ctx:authContext ,params: req.params}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetApp) throw new Error('method: GetApp is not implemented') app.post('/api/app/get', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetApp', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetApp) throw new Error('method: GetApp is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetApp({rpcName:'GetApp', ctx:authContext }) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AddAppUser) throw new Error('method: AddAppUser is not implemented') app.post('/api/app/user/add', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'AddAppUser', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.AddAppUser) throw new Error('method: AddAppUser is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.AddAppUserRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.AddAppUser({rpcName:'AddAppUser', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AddAppInvoice) throw new Error('method: AddAppInvoice is not implemented') app.post('/api/app/add/invoice', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'AddAppInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.AddAppInvoice) throw new Error('method: AddAppInvoice is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.AddAppInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.AddAppInvoice({rpcName:'AddAppInvoice', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AddAppUserInvoice) throw new Error('method: AddAppUserInvoice is not implemented') app.post('/api/app/user/add/invoice', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'AddAppUserInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.AddAppUserInvoice) throw new Error('method: AddAppUserInvoice is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.AddAppUserInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.AddAppUserInvoice({rpcName:'AddAppUserInvoice', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetAppUser) throw new Error('method: GetAppUser is not implemented') app.post('/api/app/user/get', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetAppUser', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetAppUser) throw new Error('method: GetAppUser is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.GetAppUserRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.GetAppUser({rpcName:'GetAppUser', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.PayAppUserInvoice) throw new Error('method: PayAppUserInvoice is not implemented') app.post('/api/app/invoice/pay', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'PayAppUserInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.PayAppUserInvoice) throw new Error('method: PayAppUserInvoice is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.PayAppUserInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.PayAppUserInvoice({rpcName:'PayAppUserInvoice', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.SendAppUserToAppUserPayment) throw new Error('method: SendAppUserToAppUserPayment is not implemented') app.post('/api/app/user/internal/pay', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'SendAppUserToAppUserPayment', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.SendAppUserToAppUserPayment) throw new Error('method: SendAppUserToAppUserPayment is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.SendAppUserToAppUserPaymentRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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 await methods.SendAppUserToAppUserPayment({rpcName:'SendAppUserToAppUserPayment', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.SendAppUserToAppPayment) throw new Error('method: SendAppUserToAppPayment is not implemented') app.post('/api/app/internal/pay', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'SendAppUserToAppPayment', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.SendAppUserToAppPayment) throw new Error('method: SendAppUserToAppPayment is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.SendAppUserToAppPaymentRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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 await methods.SendAppUserToAppPayment({rpcName:'SendAppUserToAppPayment', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetAppUserLNURLInfo) throw new Error('method: GetAppUserLNURLInfo is not implemented') app.post('/api/app/user/lnurl/pay/info', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetAppUserLNURLInfo', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetAppUserLNURLInfo) throw new Error('method: GetAppUserLNURLInfo is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.GetAppUserLNURLInfoRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.GetAppUserLNURLInfo({rpcName:'GetAppUserLNURLInfo', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.SetMockAppUserBalance) throw new Error('method: SetMockAppUserBalance is not implemented') app.post('/api/app/mock/user/blance/set', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'SetMockAppUserBalance', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.SetMockAppUserBalance) throw new Error('method: SetMockAppUserBalance is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.SetMockAppUserBalanceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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 await methods.SetMockAppUserBalance({rpcName:'SetMockAppUserBalance', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.SetMockAppBalance) throw new Error('method: SetMockAppBalance is not implemented') app.post('/api/app/mock/blance/set', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'SetMockAppBalance', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.SetMockAppBalance) throw new Error('method: SetMockAppBalance is not implemented') const authContext = await opts.AppAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.SetMockAppBalanceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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 await methods.SetMockAppBalance({rpcName:'SetMockAppBalance', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK'}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetUserInfo) throw new Error('method: GetUserInfo is not implemented') app.post('/api/user/info', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetUserInfo', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetUserInfo) throw new Error('method: GetUserInfo is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetUserInfo({rpcName:'GetUserInfo', ctx:authContext }) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AddProduct) throw new Error('method: AddProduct is not implemented') app.post('/api/user/product/add', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'AddProduct', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.AddProduct) throw new Error('method: AddProduct is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.AddProductRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.AddProduct({rpcName:'AddProduct', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.NewProductInvoice) throw new Error('method: NewProductInvoice is not implemented') app.get('/api/user/product/get/invoice', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'NewProductInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.NewProductInvoice) throw new Error('method: NewProductInvoice is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.NewProductInvoice({rpcName:'NewProductInvoice', ctx:authContext ,query: req.query}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetUserOperations) throw new Error('method: GetUserOperations is not implemented') app.post('/api/user/operations', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetUserOperations', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetUserOperations) throw new Error('method: GetUserOperations is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.GetUserOperationsRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.GetUserOperations({rpcName:'GetUserOperations', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.NewAddress) throw new Error('method: NewAddress is not implemented') app.post('/api/user/chain/new', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'NewAddress', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.NewAddress) throw new Error('method: NewAddress is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.NewAddressRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.NewAddress({rpcName:'NewAddress', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.PayAddress) throw new Error('method: PayAddress is not implemented') app.post('/api/user/chain/pay', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'PayAddress', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.PayAddress) throw new Error('method: PayAddress is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.PayAddressRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.PayAddress({rpcName:'PayAddress', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.NewInvoice) throw new Error('method: NewInvoice is not implemented') app.post('/api/user/invoice/new', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'NewInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.NewInvoice) throw new Error('method: NewInvoice is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.NewInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.NewInvoice({rpcName:'NewInvoice', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.DecodeInvoice) throw new Error('method: DecodeInvoice is not implemented') app.post('/api/user/invoice/decode', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'DecodeInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.DecodeInvoice) throw new Error('method: DecodeInvoice is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.DecodeInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.DecodeInvoice({rpcName:'DecodeInvoice', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.PayInvoice) throw new Error('method: PayInvoice is not implemented') app.post('/api/user/invoice/pay', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'PayInvoice', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.PayInvoice) throw new Error('method: PayInvoice is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.PayInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.PayInvoice({rpcName:'PayInvoice', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.OpenChannel) throw new Error('method: OpenChannel is not implemented') app.post('/api/user/open/channel', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'OpenChannel', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.OpenChannel) throw new Error('method: OpenChannel is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() const request = req.body const error = Types.OpenChannelRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + 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.OpenChannel({rpcName:'OpenChannel', ctx:authContext , req: request}) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetLnurlWithdrawLink) throw new Error('method: GetLnurlWithdrawLink is not implemented') app.get('/api/user/lnurl_withdraw/link', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetLnurlWithdrawLink', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetLnurlWithdrawLink) throw new Error('method: GetLnurlWithdrawLink is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetLnurlWithdrawLink({rpcName:'GetLnurlWithdrawLink', ctx:authContext }) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetLnurlPayLink) throw new Error('method: GetLnurlPayLink is not implemented') app.get('/api/user/lnurl_pay/link', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetLnurlPayLink', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetLnurlPayLink) throw new Error('method: GetLnurlPayLink is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetLnurlPayLink({rpcName:'GetLnurlPayLink', ctx:authContext }) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetLNURLChannelLink) throw new Error('method: GetLNURLChannelLink is not implemented') app.post('/api/user/lnurl_channel/url', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'GetLNURLChannelLink', batch: false, nostr: false, batchSize: 0} + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { if (!methods.GetLNURLChannelLink) throw new Error('method: GetLNURLChannelLink is not implemented') const authContext = await opts.UserAuthGuard(req.headers['authorization']) + authCtx = authContext + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard const query = req.query const params = req.params const response = await methods.GetLNURLChannelLink({rpcName:'GetLNURLChannelLink', ctx:authContext }) + stats.handle = process.hrtime.bigint() res.json({status: 'OK', ...response}) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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 } }) app.post('/api/user/batch', async (req, res) => { + const info: Types.RequestInfo = { rpcName: 'BatchUser', batch: true, nostr: false, batchSize: 1 } + const stats: Types.RequestStats = { start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} try { const requests = req.body.requests as Types.UserMethodInputs[] if (!Array.isArray(requests))throw new Error('invalid body, is not an array') + info.batchSize = requests.length if (requests.length > 10) throw new Error('too many requests in the batch') const ctx = await opts.UserAuthGuard(req.headers['authorization']) + stats.guard = process.hrtime.bigint() + stats.validate = stats.guard + authCtx = ctx const responses = [] + const callsMetrics: Types.RequestMetric[] = [] for (let i = 0; i < requests.length; i++) { const operation = requests[i] + const opInfo: Types.RequestInfo = { rpcName: operation.rpcName, batch: true, nostr: false, batchSize: 0 } + const opStats: Types.RequestStats = { start:req.startTime || 0n, parse: stats.parse, guard: stats.guard, validate: 0n, handle: 0n } try { switch(operation.rpcName) { case 'GetUserInfo': if (!methods.GetUserInfo) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetUserInfo' }) + throw new Error('method GetUserInfo not found' ) } else { + opStats.validate = opStats.guard const res = await methods.GetUserInfo({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'AddProduct': if (!methods.AddProduct) { - responses.push({ status: 'ERROR', reason: 'method not defined: AddProduct' }) + throw new Error('method AddProduct not found' ) } else { + const error = Types.AddProductRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.AddProduct({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'NewProductInvoice': if (!methods.NewProductInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: NewProductInvoice' }) + throw new Error('method NewProductInvoice not found' ) } else { + opStats.validate = opStats.guard const res = await methods.NewProductInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetUserOperations': if (!methods.GetUserOperations) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetUserOperations' }) + throw new Error('method GetUserOperations not found' ) } else { + const error = Types.GetUserOperationsRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.GetUserOperations({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'NewAddress': if (!methods.NewAddress) { - responses.push({ status: 'ERROR', reason: 'method not defined: NewAddress' }) + throw new Error('method NewAddress not found' ) } else { + const error = Types.NewAddressRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.NewAddress({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'PayAddress': if (!methods.PayAddress) { - responses.push({ status: 'ERROR', reason: 'method not defined: PayAddress' }) + throw new Error('method PayAddress not found' ) } else { + const error = Types.PayAddressRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.PayAddress({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'NewInvoice': if (!methods.NewInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: NewInvoice' }) + throw new Error('method NewInvoice not found' ) } else { + const error = Types.NewInvoiceRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.NewInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'DecodeInvoice': if (!methods.DecodeInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: DecodeInvoice' }) + throw new Error('method DecodeInvoice not found' ) } else { + const error = Types.DecodeInvoiceRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.DecodeInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'PayInvoice': if (!methods.PayInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: PayInvoice' }) + throw new Error('method PayInvoice not found' ) } else { + const error = Types.PayInvoiceRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.PayInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'OpenChannel': if (!methods.OpenChannel) { - responses.push({ status: 'ERROR', reason: 'method not defined: OpenChannel' }) + throw new Error('method OpenChannel not found' ) } else { + const error = Types.OpenChannelRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error const res = await methods.OpenChannel({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetLnurlWithdrawLink': if (!methods.GetLnurlWithdrawLink) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetLnurlWithdrawLink' }) + throw new Error('method GetLnurlWithdrawLink not found' ) } else { + opStats.validate = opStats.guard const res = await methods.GetLnurlWithdrawLink({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetLnurlPayLink': if (!methods.GetLnurlPayLink) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetLnurlPayLink' }) + throw new Error('method GetLnurlPayLink not found' ) } else { + opStats.validate = opStats.guard const res = await methods.GetLnurlPayLink({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetLNURLChannelLink': if (!methods.GetLNURLChannelLink) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetLNURLChannelLink' }) + throw new Error('method GetLNURLChannelLink not found' ) } else { + opStats.validate = opStats.guard const res = await methods.GetLNURLChannelLink({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break default: throw new Error('unkown rpcName') } - } catch(ex) {const e = ex as any; logger.error(e.message || e); responses.push({ status: 'ERROR', reason: e.message || e })} + } catch(ex) {const e = ex as any; logger.error(e.message || e); callsMetrics.push({ ...opInfo, ...opStats, ...ctx, error: e.message }); responses.push({ status: 'ERROR', reason: e.message || e })} } res.json({ status: 'OK', responses }) - } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + opts.metricsCallback([{ ...info, ...stats, ...ctx }, ...callsMetrics]) + } 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.staticFiles) { app.use(express.static(opts.staticFiles)) diff --git a/proto/autogenerated/ts/http_client.ts b/proto/autogenerated/ts/http_client.ts index 8e8ac966..688bd022 100644 --- a/proto/autogenerated/ts/http_client.ts +++ b/proto/autogenerated/ts/http_client.ts @@ -57,6 +57,20 @@ export default (params: ClientParams) => ({ } return { status: 'ERROR', reason: 'invalid response' } }, + GetMetrics: async (): Promise => { + const auth = await params.retrieveAdminAuth() + if (auth === null) throw new Error('retrieveAdminAuth() returned null') + let finalRoute = '/api/admin/metrics' + const { data } = await axios.post(params.baseUrl + finalRoute, {}, { 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.UsageMetricsValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, Health: async (): Promise => { const auth = await params.retrieveGuestAuth() if (auth === null) throw new Error('retrieveGuestAuth() returned null') diff --git a/proto/autogenerated/ts/nostr_transport.ts b/proto/autogenerated/ts/nostr_transport.ts index 2c3d4e9b..f0e256c0 100644 --- a/proto/autogenerated/ts/nostr_transport.ts +++ b/proto/autogenerated/ts/nostr_transport.ts @@ -15,270 +15,417 @@ export type NostrRequest = { export type NostrOptions = { logger?: Logger throwErrors?: true - NostrUserAuthGuard: (appId?:string, identifier?: string) => Promise + metricsCallback: (metrics: Types.RequestMetric[]) => void + NostrUserAuthGuard: (appId?: string, identifier?: string) => Promise +} +const logErrorAndReturnResponse = (error: Error, response: string, res: NostrResponse, logger: Logger, metric: Types.RequestMetric, metricsCallback: (metrics: Types.RequestMetric[]) => void) => { + logger.error(error.message || error); metricsCallback([{ ...metric, error: response }]); res({ status: 'ERROR', reason: response }) } -const logErrorAndReturnResponse = (error: Error, response: string, res: NostrResponse, logger: Logger) => { logger.error(error.message || error); res({ status: 'ERROR', reason: response }) } export default (methods: Types.ServerMethods, opts: NostrOptions) => { const logger = opts.logger || { log: console.log, error: console.error } - return async (req: NostrRequest, res: NostrResponse) => { + return async (req: NostrRequest, res: NostrResponse, startTime: bigint) => { + const info: Types.RequestInfo = { rpcName: req.rpcName || 'unkown', batch: false, nostr: true, batchSize: 0 } + const stats: Types.RequestStats = { start: startTime, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n } + let authCtx: Types.AuthContext = {} switch (req.rpcName) { case 'GetUserInfo': try { if (!methods.GetUserInfo) throw new Error('method: GetUserInfo is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - const response = await methods.GetUserInfo({rpcName:'GetUserInfo', ctx:authContext }) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + const response = await methods.GetUserInfo({ rpcName: 'GetUserInfo', ctx: authContext }) + 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 'AddProduct': try { if (!methods.AddProduct) throw new Error('method: AddProduct is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.AddProductRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.AddProduct({rpcName:'AddProduct', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.AddProduct({ rpcName: 'AddProduct', 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 'NewProductInvoice': try { if (!methods.NewProductInvoice) throw new Error('method: NewProductInvoice is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - const response = await methods.NewProductInvoice({rpcName:'NewProductInvoice', ctx:authContext ,query: req.query||{}}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + const response = await methods.NewProductInvoice({ rpcName: 'NewProductInvoice', ctx: authContext, query: req.query || {} }) + 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 'GetUserOperations': try { if (!methods.GetUserOperations) throw new Error('method: GetUserOperations is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.GetUserOperationsRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.GetUserOperations({rpcName:'GetUserOperations', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.GetUserOperations({ rpcName: 'GetUserOperations', 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 'NewAddress': try { if (!methods.NewAddress) throw new Error('method: NewAddress is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.NewAddressRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.NewAddress({rpcName:'NewAddress', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.NewAddress({ rpcName: 'NewAddress', 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 'PayAddress': try { if (!methods.PayAddress) throw new Error('method: PayAddress is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.PayAddressRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.PayAddress({rpcName:'PayAddress', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.PayAddress({ rpcName: 'PayAddress', 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 'NewInvoice': try { if (!methods.NewInvoice) throw new Error('method: NewInvoice is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.NewInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.NewInvoice({rpcName:'NewInvoice', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.NewInvoice({ rpcName: 'NewInvoice', 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 'DecodeInvoice': try { if (!methods.DecodeInvoice) throw new Error('method: DecodeInvoice is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.DecodeInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.DecodeInvoice({rpcName:'DecodeInvoice', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.DecodeInvoice({ rpcName: 'DecodeInvoice', 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 'PayInvoice': try { if (!methods.PayInvoice) throw new Error('method: PayInvoice is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.PayInvoiceRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.PayInvoice({rpcName:'PayInvoice', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.PayInvoice({ rpcName: 'PayInvoice', 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 'OpenChannel': try { if (!methods.OpenChannel) throw new Error('method: OpenChannel is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = authContext const request = req.body const error = Types.OpenChannelRequestValidate(request) - if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) - const response = await methods.OpenChannel({rpcName:'OpenChannel', ctx:authContext , req: request}) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + 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.OpenChannel({ rpcName: 'OpenChannel', 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 'GetLnurlWithdrawLink': try { if (!methods.GetLnurlWithdrawLink) throw new Error('method: GetLnurlWithdrawLink is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - const response = await methods.GetLnurlWithdrawLink({rpcName:'GetLnurlWithdrawLink', ctx:authContext }) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + const response = await methods.GetLnurlWithdrawLink({ rpcName: 'GetLnurlWithdrawLink', ctx: authContext }) + 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 'GetLnurlPayLink': try { if (!methods.GetLnurlPayLink) throw new Error('method: GetLnurlPayLink is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - const response = await methods.GetLnurlPayLink({rpcName:'GetLnurlPayLink', ctx:authContext }) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + const response = await methods.GetLnurlPayLink({ rpcName: 'GetLnurlPayLink', ctx: authContext }) + 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 'GetLNURLChannelLink': try { if (!methods.GetLNURLChannelLink) throw new Error('method: GetLNURLChannelLink is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - const response = await methods.GetLNURLChannelLink({rpcName:'GetLNURLChannelLink', ctx:authContext }) - res({status: 'OK', ...response}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + const response = await methods.GetLNURLChannelLink({ rpcName: 'GetLNURLChannelLink', ctx: authContext }) + 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 'GetLiveUserOperations': try { if (!methods.GetLiveUserOperations) throw new Error('method: GetLiveUserOperations is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - methods.GetLiveUserOperations({rpcName:'GetLiveUserOperations', ctx:authContext ,cb: (response, err) => { - if (err) { logErrorAndReturnResponse(err, err.message, res, logger)} else { res({status: 'OK', ...response})} - }}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + methods.GetLiveUserOperations({ + rpcName: 'GetLiveUserOperations', ctx: authContext, cb: (response, err) => { + stats.handle = process.hrtime.bigint() + if (err) { logErrorAndReturnResponse(err, err.message, res, logger, { ...info, ...stats, ...authContext }, opts.metricsCallback) } else { 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 'GetMigrationUpdate': try { if (!methods.GetMigrationUpdate) throw new Error('method: GetMigrationUpdate is not implemented') const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) - methods.GetMigrationUpdate({rpcName:'GetMigrationUpdate', ctx:authContext ,cb: (response, err) => { - if (err) { logErrorAndReturnResponse(err, err.message, res, logger)} else { res({status: 'OK', ...response})} - }}) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + stats.guard = process.hrtime.bigint() + authCtx = authContext + stats.validate = stats.guard + methods.GetMigrationUpdate({ + rpcName: 'GetMigrationUpdate', ctx: authContext, cb: (response, err) => { + stats.handle = process.hrtime.bigint() + if (err) { logErrorAndReturnResponse(err, err.message, res, logger, { ...info, ...stats, ...authContext }, opts.metricsCallback) } else { 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 'BatchUser': try { + info.batch = true const requests = req.body.requests as Types.UserMethodInputs[] - if (!Array.isArray(requests))throw new Error('invalid body, is not an array') + if (!Array.isArray(requests)) throw new Error('invalid body, is not an array') + info.batchSize = requests.length if (requests.length > 10) throw new Error('too many requests in the batch') const ctx = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier) + stats.guard = process.hrtime.bigint() + authCtx = ctx + stats.validate = stats.guard const responses = [] + const callsMetrics: Types.RequestMetric[] = [] for (let i = 0; i < requests.length; i++) { const operation = requests[i] + const opInfo: Types.RequestInfo = { rpcName: operation.rpcName, batch: true, nostr: true, batchSize: 0 } + const opStats: Types.RequestStats = { start: startTime, parse: stats.parse, guard: stats.guard, validate: 0n, handle: 0n } try { - switch(operation.rpcName) { + switch (operation.rpcName) { case 'GetUserInfo': if (!methods.GetUserInfo) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetUserInfo' }) + throw new Error('method not defined: GetUserInfo') } else { - const res = await methods.GetUserInfo({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.validate = opStats.guard + const res = await methods.GetUserInfo({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'AddProduct': if (!methods.AddProduct) { - responses.push({ status: 'ERROR', reason: 'method not defined: AddProduct' }) + throw new Error('method not defined: AddProduct') } else { - const res = await methods.AddProduct({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.AddProductRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.AddProduct({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'NewProductInvoice': if (!methods.NewProductInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: NewProductInvoice' }) + throw new Error('method not defined: NewProductInvoice') } else { - const res = await methods.NewProductInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.validate = opStats.guard + const res = await methods.NewProductInvoice({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetUserOperations': if (!methods.GetUserOperations) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetUserOperations' }) + throw new Error('method not defined: GetUserOperations') } else { - const res = await methods.GetUserOperations({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.GetUserOperationsRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.GetUserOperations({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'NewAddress': if (!methods.NewAddress) { - responses.push({ status: 'ERROR', reason: 'method not defined: NewAddress' }) + throw new Error('method not defined: NewAddress') } else { - const res = await methods.NewAddress({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.NewAddressRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.NewAddress({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'PayAddress': if (!methods.PayAddress) { - responses.push({ status: 'ERROR', reason: 'method not defined: PayAddress' }) + throw new Error('method not defined: PayAddress') } else { - const res = await methods.PayAddress({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.PayAddressRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.PayAddress({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'NewInvoice': if (!methods.NewInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: NewInvoice' }) + throw new Error('method not defined: NewInvoice') } else { - const res = await methods.NewInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.NewInvoiceRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.NewInvoice({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'DecodeInvoice': if (!methods.DecodeInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: DecodeInvoice' }) + throw new Error('method not defined: DecodeInvoice') } else { - const res = await methods.DecodeInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.DecodeInvoiceRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.DecodeInvoice({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'PayInvoice': if (!methods.PayInvoice) { - responses.push({ status: 'ERROR', reason: 'method not defined: PayInvoice' }) + throw new Error('method not defined: PayInvoice') } else { - const res = await methods.PayInvoice({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.PayInvoiceRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.PayInvoice({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'OpenChannel': if (!methods.OpenChannel) { - responses.push({ status: 'ERROR', reason: 'method not defined: OpenChannel' }) + throw new Error('method not defined: OpenChannel') } else { - const res = await methods.OpenChannel({...operation, ctx}); responses.push({ status: 'OK', ...res }) + const error = Types.OpenChannelRequestValidate(operation.req) + opStats.validate = process.hrtime.bigint() + if (error !== null) throw error + const res = await methods.OpenChannel({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetLnurlWithdrawLink': if (!methods.GetLnurlWithdrawLink) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetLnurlWithdrawLink' }) + throw new Error('method not defined: GetLnurlWithdrawLink') } else { - const res = await methods.GetLnurlWithdrawLink({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.validate = opStats.guard + const res = await methods.GetLnurlWithdrawLink({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetLnurlPayLink': if (!methods.GetLnurlPayLink) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetLnurlPayLink' }) + throw new Error('method not defined: GetLnurlPayLink') } else { - const res = await methods.GetLnurlPayLink({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.validate = opStats.guard + const res = await methods.GetLnurlPayLink({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break case 'GetLNURLChannelLink': if (!methods.GetLNURLChannelLink) { - responses.push({ status: 'ERROR', reason: 'method not defined: GetLNURLChannelLink' }) + throw new Error('method not defined: GetLNURLChannelLink') } else { - const res = await methods.GetLNURLChannelLink({...operation, ctx}); responses.push({ status: 'OK', ...res }) + opStats.validate = opStats.guard + const res = await methods.GetLNURLChannelLink({ ...operation, ctx }); responses.push({ status: 'OK', ...res }) + opStats.handle = process.hrtime.bigint() + callsMetrics.push({ ...opInfo, ...opStats, ...ctx }) } break default: - throw new Error('unkown rpcName') + throw new Error('unkown rpcName') } - } catch(ex) {const e = ex as any; logger.error(e.message || e); responses.push({ status: 'ERROR', reason: e.message || e })} + } catch (ex) { const e = ex as any; logger.error(e.message || e); callsMetrics.push({ ...opInfo, ...opStats, ...ctx, error: e.message }); responses.push({ status: 'ERROR', reason: e.message || e }) } } res({ status: 'OK', responses }) - }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + opts.metricsCallback([{ ...info, ...stats, ...ctx }, ...callsMetrics]) + } 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 - default: logger.error('unknown rpc call name from nostr event:'+req.rpcName) + default: logger.error('unknown rpc call name from nostr event:' + req.rpcName) } } } diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index 252917b2..a03094b5 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -1,22 +1,25 @@ // This file was autogenerated from a .proto file, DO NOT EDIT! export type ResultError = { status: 'ERROR', reason: string } +export type RequestInfo = { rpcName: string, batch: boolean, nostr: boolean, batchSize: number } +export type RequestStats = { start:bigint, parse: bigint, guard: bigint, validate: bigint, handle: bigint } +export type RequestMetric = AuthContext & RequestInfo & RequestStats & { error?: string } export type GuestContext = { } export type GuestMethodInputs = Health_Input | EncryptionExchange_Input | SetMockInvoiceAsPaid_Input | GetLnurlWithdrawInfo_Input | HandleLnurlWithdraw_Input | GetLnurlPayInfo_Input | HandleLnurlPay_Input | HandleLnurlAddress_Input export type GuestMethodOutputs = Health_Output | EncryptionExchange_Output | SetMockInvoiceAsPaid_Output | GetLnurlWithdrawInfo_Output | HandleLnurlWithdraw_Output | GetLnurlPayInfo_Output | HandleLnurlPay_Output | HandleLnurlAddress_Output export type UserContext = { - app_user_id: string user_id: string app_id: string + app_user_id: string } export type UserMethodInputs = GetUserInfo_Input | AddProduct_Input | NewProductInvoice_Input | GetUserOperations_Input | NewAddress_Input | PayAddress_Input | NewInvoice_Input | DecodeInvoice_Input | PayInvoice_Input | OpenChannel_Input | GetLnurlWithdrawLink_Input | GetLnurlPayLink_Input | GetLNURLChannelLink_Input export type UserMethodOutputs = GetUserInfo_Output | AddProduct_Output | NewProductInvoice_Output | GetUserOperations_Output | NewAddress_Output | PayAddress_Output | NewInvoice_Output | DecodeInvoice_Output | PayInvoice_Output | OpenChannel_Output | GetLnurlWithdrawLink_Output | GetLnurlPayLink_Output | GetLNURLChannelLink_Output export type AdminContext = { admin_id: string } -export type AdminMethodInputs = LndGetInfo_Input | AddApp_Input | AuthApp_Input -export type AdminMethodOutputs = LndGetInfo_Output | AddApp_Output | AuthApp_Output +export type AdminMethodInputs = LndGetInfo_Input | AddApp_Input | AuthApp_Input | GetMetrics_Input +export type AdminMethodOutputs = LndGetInfo_Output | AddApp_Output | AuthApp_Output | GetMetrics_Output export type AppContext = { app_id: string } @@ -33,6 +36,9 @@ export type AddApp_Output = ResultError | ({ status: 'OK' } & AuthApp) export type AuthApp_Input = {rpcName:'AuthApp', req: AuthAppRequest} export type AuthApp_Output = ResultError | ({ status: 'OK' } & AuthApp) +export type GetMetrics_Input = {rpcName:'GetMetrics'} +export type GetMetrics_Output = ResultError | ({ status: 'OK' } & UsageMetrics) + export type Health_Input = {rpcName:'Health'} export type Health_Output = ResultError | { status: 'OK' } @@ -164,6 +170,7 @@ export type ServerMethods = { LndGetInfo?: (req: LndGetInfo_Input & {ctx: AdminContext }) => Promise AddApp?: (req: AddApp_Input & {ctx: AdminContext }) => Promise AuthApp?: (req: AuthApp_Input & {ctx: AdminContext }) => Promise + GetMetrics?: (req: GetMetrics_Input & {ctx: AdminContext }) => Promise Health?: (req: Health_Input & {ctx: GuestContext }) => Promise EncryptionExchange?: (req: EncryptionExchange_Input & {ctx: GuestContext }) => Promise SetMockInvoiceAsPaid?: (req: SetMockInvoiceAsPaid_Input & {ctx: GuestContext }) => Promise @@ -226,92 +233,22 @@ export type OptionsBaseMessage = { allOptionalsAreSet?: true } -export type SetMockInvoiceAsPaidRequest = { - invoice: string - amount: number -} -export const SetMockInvoiceAsPaidRequestOptionalFields: [] = [] -export type SetMockInvoiceAsPaidRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const SetMockInvoiceAsPaidRequestValidate = (o?: SetMockInvoiceAsPaidRequest, opts: SetMockInvoiceAsPaidRequestOptions = {}, path: string = 'SetMockInvoiceAsPaidRequest::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 !== '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`) - - return null -} - -export type LndGetInfoResponse = { - alias: string -} -export const LndGetInfoResponseOptionalFields: [] = [] -export type LndGetInfoResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - alias_CustomCheck?: (v: string) => boolean -} -export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetInfoResponseOptions = {}, path: string = 'LndGetInfoResponse::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.alias !== 'string') return new Error(`${path}.alias: is not a string`) - if (opts.alias_CustomCheck && !opts.alias_CustomCheck(o.alias)) return new Error(`${path}.alias: custom check failed`) - - return null -} - -export type AuthAppRequest = { - name: string - allow_user_creation?: boolean -} -export type AuthAppRequestOptionalField = 'allow_user_creation' -export const AuthAppRequestOptionalFields: AuthAppRequestOptionalField[] = ['allow_user_creation'] -export type AuthAppRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: AuthAppRequestOptionalField[] - name_CustomCheck?: (v: string) => boolean - allow_user_creation_CustomCheck?: (v?: boolean) => boolean -} -export const AuthAppRequestValidate = (o?: AuthAppRequest, opts: AuthAppRequestOptions = {}, path: string = 'AuthAppRequest::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.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.allow_user_creation || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('allow_user_creation')) && typeof o.allow_user_creation !== 'boolean') return new Error(`${path}.allow_user_creation: is not a boolean`) - if (opts.allow_user_creation_CustomCheck && !opts.allow_user_creation_CustomCheck(o.allow_user_creation)) return new Error(`${path}.allow_user_creation: custom check failed`) - - return null -} - -export type AddAppUserInvoiceRequest = { - receiver_identifier: string +export type AddAppInvoiceRequest = { payer_identifier: string http_callback_url: string invoice_req: NewInvoiceRequest } -export const AddAppUserInvoiceRequestOptionalFields: [] = [] -export type AddAppUserInvoiceRequestOptions = OptionsBaseMessage & { +export const AddAppInvoiceRequestOptionalFields: [] = [] +export type AddAppInvoiceRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - receiver_identifier_CustomCheck?: (v: string) => boolean payer_identifier_CustomCheck?: (v: string) => boolean http_callback_url_CustomCheck?: (v: string) => boolean invoice_req_Options?: NewInvoiceRequestOptions } -export const AddAppUserInvoiceRequestValidate = (o?: AddAppUserInvoiceRequest, opts: AddAppUserInvoiceRequestOptions = {}, path: string = 'AddAppUserInvoiceRequest::root.'): Error | null => { +export const AddAppInvoiceRequestValidate = (o?: AddAppInvoiceRequest, opts: AddAppInvoiceRequestOptions = {}, path: string = 'AddAppInvoiceRequest::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.receiver_identifier !== 'string') return new Error(`${path}.receiver_identifier: is not a string`) - if (opts.receiver_identifier_CustomCheck && !opts.receiver_identifier_CustomCheck(o.receiver_identifier)) return new Error(`${path}.receiver_identifier: custom check failed`) - if (typeof o.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) @@ -325,24 +262,6 @@ export const AddAppUserInvoiceRequestValidate = (o?: AddAppUserInvoiceRequest, o return null } -export type NewAddressResponse = { - address: string -} -export const NewAddressResponseOptionalFields: [] = [] -export type NewAddressResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - address_CustomCheck?: (v: string) => boolean -} -export const NewAddressResponseValidate = (o?: NewAddressResponse, opts: NewAddressResponseOptions = {}, path: string = 'NewAddressResponse::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.address !== 'string') return new Error(`${path}.address: is not a string`) - if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) - - return null -} - export type NewInvoiceRequest = { amountSats: number memo: string @@ -366,6 +285,130 @@ export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoic return null } +export type LnurlWithdrawInfoResponse = { + tag: string + callback: string + k1: string + defaultDescription: string + minWithdrawable: number + maxWithdrawable: number + balanceCheck: string + payLink: string +} +export const LnurlWithdrawInfoResponseOptionalFields: [] = [] +export type LnurlWithdrawInfoResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + tag_CustomCheck?: (v: string) => boolean + callback_CustomCheck?: (v: string) => boolean + k1_CustomCheck?: (v: string) => boolean + defaultDescription_CustomCheck?: (v: string) => boolean + minWithdrawable_CustomCheck?: (v: number) => boolean + maxWithdrawable_CustomCheck?: (v: number) => boolean + balanceCheck_CustomCheck?: (v: string) => boolean + payLink_CustomCheck?: (v: string) => boolean +} +export const LnurlWithdrawInfoResponseValidate = (o?: LnurlWithdrawInfoResponse, opts: LnurlWithdrawInfoResponseOptions = {}, path: string = 'LnurlWithdrawInfoResponse::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.tag !== 'string') return new Error(`${path}.tag: is not a string`) + if (opts.tag_CustomCheck && !opts.tag_CustomCheck(o.tag)) return new Error(`${path}.tag: custom check failed`) + + if (typeof o.callback !== 'string') return new Error(`${path}.callback: is not a string`) + if (opts.callback_CustomCheck && !opts.callback_CustomCheck(o.callback)) return new Error(`${path}.callback: custom check failed`) + + if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) + if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) + + if (typeof o.defaultDescription !== 'string') return new Error(`${path}.defaultDescription: is not a string`) + if (opts.defaultDescription_CustomCheck && !opts.defaultDescription_CustomCheck(o.defaultDescription)) return new Error(`${path}.defaultDescription: custom check failed`) + + if (typeof o.minWithdrawable !== 'number') return new Error(`${path}.minWithdrawable: is not a number`) + if (opts.minWithdrawable_CustomCheck && !opts.minWithdrawable_CustomCheck(o.minWithdrawable)) return new Error(`${path}.minWithdrawable: custom check failed`) + + if (typeof o.maxWithdrawable !== 'number') return new Error(`${path}.maxWithdrawable: is not a number`) + if (opts.maxWithdrawable_CustomCheck && !opts.maxWithdrawable_CustomCheck(o.maxWithdrawable)) return new Error(`${path}.maxWithdrawable: custom check failed`) + + if (typeof o.balanceCheck !== 'string') return new Error(`${path}.balanceCheck: is not a string`) + if (opts.balanceCheck_CustomCheck && !opts.balanceCheck_CustomCheck(o.balanceCheck)) return new Error(`${path}.balanceCheck: custom check failed`) + + if (typeof o.payLink !== 'string') return new Error(`${path}.payLink: is not a string`) + if (opts.payLink_CustomCheck && !opts.payLink_CustomCheck(o.payLink)) return new Error(`${path}.payLink: custom check failed`) + + return null +} + +export type UserOperation = { + paidAtUnix: number + type: UserOperationType + inbound: boolean + amount: number + identifier: string + operationId: string + service_fee: number + network_fee: number + confirmed: boolean +} +export const UserOperationOptionalFields: [] = [] +export type UserOperationOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + paidAtUnix_CustomCheck?: (v: number) => boolean + type_CustomCheck?: (v: UserOperationType) => boolean + inbound_CustomCheck?: (v: boolean) => boolean + amount_CustomCheck?: (v: number) => boolean + identifier_CustomCheck?: (v: string) => boolean + operationId_CustomCheck?: (v: string) => boolean + service_fee_CustomCheck?: (v: number) => boolean + network_fee_CustomCheck?: (v: number) => boolean + confirmed_CustomCheck?: (v: boolean) => boolean +} +export const UserOperationValidate = (o?: UserOperation, opts: UserOperationOptions = {}, path: string = 'UserOperation::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.paidAtUnix !== 'number') return new Error(`${path}.paidAtUnix: is not a number`) + if (opts.paidAtUnix_CustomCheck && !opts.paidAtUnix_CustomCheck(o.paidAtUnix)) return new Error(`${path}.paidAtUnix: custom check failed`) + + if (!enumCheckUserOperationType(o.type)) return new Error(`${path}.type: is not a valid UserOperationType`) + if (opts.type_CustomCheck && !opts.type_CustomCheck(o.type)) return new Error(`${path}.type: custom check failed`) + + if (typeof o.inbound !== 'boolean') return new Error(`${path}.inbound: is not a boolean`) + if (opts.inbound_CustomCheck && !opts.inbound_CustomCheck(o.inbound)) return new Error(`${path}.inbound: custom check failed`) + + 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.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) + if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) + + if (typeof o.operationId !== 'string') return new Error(`${path}.operationId: is not a string`) + if (opts.operationId_CustomCheck && !opts.operationId_CustomCheck(o.operationId)) return new Error(`${path}.operationId: custom check failed`) + + if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`) + if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: 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`) + + if (typeof o.confirmed !== 'boolean') return new Error(`${path}.confirmed: is not a boolean`) + if (opts.confirmed_CustomCheck && !opts.confirmed_CustomCheck(o.confirmed)) return new Error(`${path}.confirmed: custom check failed`) + + return null +} + +export type Empty = { +} +export const EmptyOptionalFields: [] = [] +export type EmptyOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] +} +export const EmptyValidate = (o?: Empty, opts: EmptyOptions = {}, path: string = 'Empty::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') + + return null +} + export type EncryptionExchangeRequest = { publicKey: string deviceId: string @@ -407,61 +450,628 @@ export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInf return null } -export type AddProductRequest = { +export type Application = { name: string - price_sats: number + id: string + balance: number + npub: string } -export const AddProductRequestOptionalFields: [] = [] -export type AddProductRequestOptions = OptionsBaseMessage & { +export const ApplicationOptionalFields: [] = [] +export type ApplicationOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] name_CustomCheck?: (v: string) => boolean - price_sats_CustomCheck?: (v: number) => boolean + id_CustomCheck?: (v: string) => boolean + balance_CustomCheck?: (v: number) => boolean + npub_CustomCheck?: (v: string) => boolean } -export const AddProductRequestValidate = (o?: AddProductRequest, opts: AddProductRequestOptions = {}, path: string = 'AddProductRequest::root.'): Error | null => { +export const ApplicationValidate = (o?: Application, opts: ApplicationOptions = {}, path: string = 'Application::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.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 (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`) - if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`) + if (typeof o.id !== 'string') return new Error(`${path}.id: is not a string`) + if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) + + 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 (typeof o.npub !== 'string') return new Error(`${path}.npub: is not a string`) + if (opts.npub_CustomCheck && !opts.npub_CustomCheck(o.npub)) return new Error(`${path}.npub: custom check failed`) return null } -export type NewInvoiceResponse = { - invoice: string +export type SendAppUserToAppUserPaymentRequest = { + from_user_identifier: string + to_user_identifier: string + amount: number } -export const NewInvoiceResponseOptionalFields: [] = [] -export type NewInvoiceResponseOptions = OptionsBaseMessage & { +export const SendAppUserToAppUserPaymentRequestOptionalFields: [] = [] +export type SendAppUserToAppUserPaymentRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean + from_user_identifier_CustomCheck?: (v: string) => boolean + to_user_identifier_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean } -export const NewInvoiceResponseValidate = (o?: NewInvoiceResponse, opts: NewInvoiceResponseOptions = {}, path: string = 'NewInvoiceResponse::root.'): Error | null => { +export const SendAppUserToAppUserPaymentRequestValidate = (o?: SendAppUserToAppUserPaymentRequest, opts: SendAppUserToAppUserPaymentRequestOptions = {}, path: string = 'SendAppUserToAppUserPaymentRequest::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.from_user_identifier !== 'string') return new Error(`${path}.from_user_identifier: is not a string`) + if (opts.from_user_identifier_CustomCheck && !opts.from_user_identifier_CustomCheck(o.from_user_identifier)) return new Error(`${path}.from_user_identifier: custom check failed`) + + if (typeof o.to_user_identifier !== 'string') return new Error(`${path}.to_user_identifier: is not a string`) + if (opts.to_user_identifier_CustomCheck && !opts.to_user_identifier_CustomCheck(o.to_user_identifier)) return new Error(`${path}.to_user_identifier: custom check failed`) + + 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`) + + return null +} + +export type SetMockAppBalanceRequest = { + amount: number +} +export const SetMockAppBalanceRequestOptionalFields: [] = [] +export type SetMockAppBalanceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + amount_CustomCheck?: (v: number) => boolean +} +export const SetMockAppBalanceRequestValidate = (o?: SetMockAppBalanceRequest, opts: SetMockAppBalanceRequestOptions = {}, path: string = 'SetMockAppBalanceRequest::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`) + + return null +} + +export type LiveUserOperation = { + operation: UserOperation +} +export const LiveUserOperationOptionalFields: [] = [] +export type LiveUserOperationOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + 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') + + const operationErr = UserOperationValidate(o.operation, opts.operation_Options, `${path}.operation`) + if (operationErr !== null) return operationErr + + + return null +} + +export type ClosureMigration = { + closes_at_unix: number +} +export const ClosureMigrationOptionalFields: [] = [] +export type ClosureMigrationOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + closes_at_unix_CustomCheck?: (v: number) => boolean +} +export const ClosureMigrationValidate = (o?: ClosureMigration, opts: ClosureMigrationOptions = {}, path: string = 'ClosureMigration::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.closes_at_unix !== 'number') return new Error(`${path}.closes_at_unix: is not a number`) + if (opts.closes_at_unix_CustomCheck && !opts.closes_at_unix_CustomCheck(o.closes_at_unix)) return new Error(`${path}.closes_at_unix: custom check failed`) + + return null +} + +export type PayAppUserInvoiceRequest = { + user_identifier: string + invoice: string + amount: number +} +export const PayAppUserInvoiceRequestOptionalFields: [] = [] +export type PayAppUserInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const PayAppUserInvoiceRequestValidate = (o?: PayAppUserInvoiceRequest, opts: PayAppUserInvoiceRequestOptions = {}, path: string = 'PayAppUserInvoiceRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + 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 !== '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`) + return null } -export type OpenChannelResponse = { - channelId: string +export type NewAddressResponse = { + address: string } -export const OpenChannelResponseOptionalFields: [] = [] -export type OpenChannelResponseOptions = OptionsBaseMessage & { +export const NewAddressResponseOptionalFields: [] = [] +export type NewAddressResponseOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - channelId_CustomCheck?: (v: string) => boolean + address_CustomCheck?: (v: string) => boolean } -export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenChannelResponseOptions = {}, path: string = 'OpenChannelResponse::root.'): Error | null => { +export const NewAddressResponseValidate = (o?: NewAddressResponse, opts: NewAddressResponseOptions = {}, path: string = 'NewAddressResponse::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.channelId !== 'string') return new Error(`${path}.channelId: is not a string`) - if (opts.channelId_CustomCheck && !opts.channelId_CustomCheck(o.channelId)) return new Error(`${path}.channelId: custom check failed`) + if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`) + if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) + + return null +} + +export type DecodeInvoiceResponse = { + amount: number +} +export const DecodeInvoiceResponseOptionalFields: [] = [] +export type DecodeInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + amount_CustomCheck?: (v: number) => boolean +} +export const DecodeInvoiceResponseValidate = (o?: DecodeInvoiceResponse, opts: DecodeInvoiceResponseOptions = {}, path: string = 'DecodeInvoiceResponse::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`) + + return null +} + +export type GetUserOperationsRequest = { + latestIncomingInvoice: number + latestOutgoingInvoice: number + latestIncomingTx: number + latestOutgoingTx: number + latestIncomingUserToUserPayment: number + latestOutgoingUserToUserPayment: number +} +export const GetUserOperationsRequestOptionalFields: [] = [] +export type GetUserOperationsRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + latestIncomingInvoice_CustomCheck?: (v: number) => boolean + latestOutgoingInvoice_CustomCheck?: (v: number) => boolean + latestIncomingTx_CustomCheck?: (v: number) => boolean + latestOutgoingTx_CustomCheck?: (v: number) => boolean + latestIncomingUserToUserPayment_CustomCheck?: (v: number) => boolean + latestOutgoingUserToUserPayment_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`) + + 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`) + + 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`) + + 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`) + + 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`) + + 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`) + + return null +} + +export type GetUserOperationsResponse = { + latestOutgoingInvoiceOperations: UserOperations + latestIncomingInvoiceOperations: UserOperations + latestOutgoingTxOperations: UserOperations + latestIncomingTxOperations: UserOperations + latestOutgoingUserToUserPayemnts: UserOperations + latestIncomingUserToUserPayemnts: UserOperations +} +export const GetUserOperationsResponseOptionalFields: [] = [] +export type GetUserOperationsResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + latestOutgoingInvoiceOperations_Options?: UserOperationsOptions + latestIncomingInvoiceOperations_Options?: UserOperationsOptions + latestOutgoingTxOperations_Options?: UserOperationsOptions + latestIncomingTxOperations_Options?: UserOperationsOptions + latestOutgoingUserToUserPayemnts_Options?: UserOperationsOptions + latestIncomingUserToUserPayemnts_Options?: UserOperationsOptions +} +export const GetUserOperationsResponseValidate = (o?: GetUserOperationsResponse, opts: GetUserOperationsResponseOptions = {}, path: string = 'GetUserOperationsResponse::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') + + const latestOutgoingInvoiceOperationsErr = UserOperationsValidate(o.latestOutgoingInvoiceOperations, opts.latestOutgoingInvoiceOperations_Options, `${path}.latestOutgoingInvoiceOperations`) + if (latestOutgoingInvoiceOperationsErr !== null) return latestOutgoingInvoiceOperationsErr + + + const latestIncomingInvoiceOperationsErr = UserOperationsValidate(o.latestIncomingInvoiceOperations, opts.latestIncomingInvoiceOperations_Options, `${path}.latestIncomingInvoiceOperations`) + if (latestIncomingInvoiceOperationsErr !== null) return latestIncomingInvoiceOperationsErr + + + const latestOutgoingTxOperationsErr = UserOperationsValidate(o.latestOutgoingTxOperations, opts.latestOutgoingTxOperations_Options, `${path}.latestOutgoingTxOperations`) + if (latestOutgoingTxOperationsErr !== null) return latestOutgoingTxOperationsErr + + + const latestIncomingTxOperationsErr = UserOperationsValidate(o.latestIncomingTxOperations, opts.latestIncomingTxOperations_Options, `${path}.latestIncomingTxOperations`) + if (latestIncomingTxOperationsErr !== null) return latestIncomingTxOperationsErr + + + const latestOutgoingUserToUserPayemntsErr = UserOperationsValidate(o.latestOutgoingUserToUserPayemnts, opts.latestOutgoingUserToUserPayemnts_Options, `${path}.latestOutgoingUserToUserPayemnts`) + if (latestOutgoingUserToUserPayemntsErr !== null) return latestOutgoingUserToUserPayemntsErr + + + const latestIncomingUserToUserPayemntsErr = UserOperationsValidate(o.latestIncomingUserToUserPayemnts, opts.latestIncomingUserToUserPayemnts_Options, `${path}.latestIncomingUserToUserPayemnts`) + if (latestIncomingUserToUserPayemntsErr !== null) return latestIncomingUserToUserPayemntsErr + + + return null +} + +export type GetProductBuyLinkResponse = { + link: string +} +export const GetProductBuyLinkResponseOptionalFields: [] = [] +export type GetProductBuyLinkResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + link_CustomCheck?: (v: string) => boolean +} +export const GetProductBuyLinkResponseValidate = (o?: GetProductBuyLinkResponse, opts: GetProductBuyLinkResponseOptions = {}, path: string = 'GetProductBuyLinkResponse::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.link !== 'string') return new Error(`${path}.link: is not a string`) + if (opts.link_CustomCheck && !opts.link_CustomCheck(o.link)) return new Error(`${path}.link: custom check failed`) + + return null +} + +export type MigrationUpdate = { + closure?: ClosureMigration + relays?: RelaysMigration +} +export type MigrationUpdateOptionalField = 'closure' | 'relays' +export const MigrationUpdateOptionalFields: MigrationUpdateOptionalField[] = ['closure', 'relays'] +export type MigrationUpdateOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: MigrationUpdateOptionalField[] + closure_Options?: ClosureMigrationOptions + relays_Options?: RelaysMigrationOptions +} +export const MigrationUpdateValidate = (o?: MigrationUpdate, opts: MigrationUpdateOptions = {}, path: string = 'MigrationUpdate::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.closure === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('closure')) { + const closureErr = ClosureMigrationValidate(o.closure, opts.closure_Options, `${path}.closure`) + if (closureErr !== null) return closureErr + } + + + if (typeof o.relays === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('relays')) { + const relaysErr = RelaysMigrationValidate(o.relays, opts.relays_Options, `${path}.relays`) + if (relaysErr !== null) return relaysErr + } + + + return null +} + +export type AuthAppRequest = { + name: string + allow_user_creation?: boolean +} +export type AuthAppRequestOptionalField = 'allow_user_creation' +export const AuthAppRequestOptionalFields: AuthAppRequestOptionalField[] = ['allow_user_creation'] +export type AuthAppRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: AuthAppRequestOptionalField[] + name_CustomCheck?: (v: string) => boolean + allow_user_creation_CustomCheck?: (v?: boolean) => boolean +} +export const AuthAppRequestValidate = (o?: AuthAppRequest, opts: AuthAppRequestOptions = {}, path: string = 'AuthAppRequest::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.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.allow_user_creation || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('allow_user_creation')) && typeof o.allow_user_creation !== 'boolean') return new Error(`${path}.allow_user_creation: is not a boolean`) + if (opts.allow_user_creation_CustomCheck && !opts.allow_user_creation_CustomCheck(o.allow_user_creation)) return new Error(`${path}.allow_user_creation: custom check failed`) + + return null +} + +export type PayAddressRequest = { + address: string + amoutSats: number + satsPerVByte: number +} +export const PayAddressRequestOptionalFields: [] = [] +export type PayAddressRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + address_CustomCheck?: (v: string) => boolean + amoutSats_CustomCheck?: (v: number) => boolean + satsPerVByte_CustomCheck?: (v: number) => boolean +} +export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddressRequestOptions = {}, path: string = 'PayAddressRequest::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.address !== 'string') return new Error(`${path}.address: is not a string`) + if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) + + if (typeof o.amoutSats !== 'number') return new Error(`${path}.amoutSats: is not a number`) + if (opts.amoutSats_CustomCheck && !opts.amoutSats_CustomCheck(o.amoutSats)) return new Error(`${path}.amoutSats: custom check failed`) + + if (typeof o.satsPerVByte !== 'number') return new Error(`${path}.satsPerVByte: is not a number`) + if (opts.satsPerVByte_CustomCheck && !opts.satsPerVByte_CustomCheck(o.satsPerVByte)) return new Error(`${path}.satsPerVByte: custom check failed`) + + return null +} + +export type OpenChannelRequest = { + destination: string + fundingAmount: number + pushAmount: number + closeAddress: string +} +export const OpenChannelRequestOptionalFields: [] = [] +export type OpenChannelRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + destination_CustomCheck?: (v: string) => boolean + fundingAmount_CustomCheck?: (v: number) => boolean + pushAmount_CustomCheck?: (v: number) => boolean + closeAddress_CustomCheck?: (v: string) => boolean +} +export const OpenChannelRequestValidate = (o?: OpenChannelRequest, opts: OpenChannelRequestOptions = {}, path: string = 'OpenChannelRequest::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.destination !== 'string') return new Error(`${path}.destination: is not a string`) + if (opts.destination_CustomCheck && !opts.destination_CustomCheck(o.destination)) return new Error(`${path}.destination: custom check failed`) + + if (typeof o.fundingAmount !== 'number') return new Error(`${path}.fundingAmount: is not a number`) + if (opts.fundingAmount_CustomCheck && !opts.fundingAmount_CustomCheck(o.fundingAmount)) return new Error(`${path}.fundingAmount: custom check failed`) + + if (typeof o.pushAmount !== 'number') return new Error(`${path}.pushAmount: is not a number`) + if (opts.pushAmount_CustomCheck && !opts.pushAmount_CustomCheck(o.pushAmount)) return new Error(`${path}.pushAmount: custom check failed`) + + if (typeof o.closeAddress !== 'string') return new Error(`${path}.closeAddress: is not a string`) + if (opts.closeAddress_CustomCheck && !opts.closeAddress_CustomCheck(o.closeAddress)) return new Error(`${path}.closeAddress: custom check failed`) + + return null +} + +export type LndGetInfoResponse = { + alias: string +} +export const LndGetInfoResponseOptionalFields: [] = [] +export type LndGetInfoResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + alias_CustomCheck?: (v: string) => boolean +} +export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetInfoResponseOptions = {}, path: string = 'LndGetInfoResponse::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.alias !== 'string') return new Error(`${path}.alias: is not a string`) + if (opts.alias_CustomCheck && !opts.alias_CustomCheck(o.alias)) return new Error(`${path}.alias: custom check failed`) + + return null +} + +export type SendAppUserToAppPaymentRequest = { + from_user_identifier: string + amount: number +} +export const SendAppUserToAppPaymentRequestOptionalFields: [] = [] +export type SendAppUserToAppPaymentRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + from_user_identifier_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const SendAppUserToAppPaymentRequestValidate = (o?: SendAppUserToAppPaymentRequest, opts: SendAppUserToAppPaymentRequestOptions = {}, path: string = 'SendAppUserToAppPaymentRequest::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.from_user_identifier !== 'string') return new Error(`${path}.from_user_identifier: is not a string`) + if (opts.from_user_identifier_CustomCheck && !opts.from_user_identifier_CustomCheck(o.from_user_identifier)) return new Error(`${path}.from_user_identifier: custom check failed`) + + 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`) + + return null +} + +export type NewAddressRequest = { + addressType: AddressType +} +export const NewAddressRequestOptionalFields: [] = [] +export type NewAddressRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + addressType_CustomCheck?: (v: AddressType) => boolean +} +export const NewAddressRequestValidate = (o?: NewAddressRequest, opts: NewAddressRequestOptions = {}, path: string = 'NewAddressRequest::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 (!enumCheckAddressType(o.addressType)) return new Error(`${path}.addressType: is not a valid AddressType`) + if (opts.addressType_CustomCheck && !opts.addressType_CustomCheck(o.addressType)) return new Error(`${path}.addressType: custom check failed`) + + return null +} + +export type PayAddressResponse = { + txId: string + operation_id: string + service_fee: number + network_fee: number +} +export const PayAddressResponseOptionalFields: [] = [] +export type PayAddressResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + txId_CustomCheck?: (v: string) => boolean + operation_id_CustomCheck?: (v: string) => boolean + service_fee_CustomCheck?: (v: number) => boolean + network_fee_CustomCheck?: (v: number) => boolean +} +export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddressResponseOptions = {}, path: string = 'PayAddressResponse::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.txId !== 'string') return new Error(`${path}.txId: is not a string`) + if (opts.txId_CustomCheck && !opts.txId_CustomCheck(o.txId)) return new Error(`${path}.txId: custom check failed`) + + if (typeof o.operation_id !== 'string') return new Error(`${path}.operation_id: is not a string`) + if (opts.operation_id_CustomCheck && !opts.operation_id_CustomCheck(o.operation_id)) return new Error(`${path}.operation_id: custom check failed`) + + if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`) + if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: 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`) + + return null +} + +export type LnurlLinkResponse = { + lnurl: string + k1: string +} +export const LnurlLinkResponseOptionalFields: [] = [] +export type LnurlLinkResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + lnurl_CustomCheck?: (v: string) => boolean + k1_CustomCheck?: (v: string) => boolean +} +export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLinkResponseOptions = {}, path: string = 'LnurlLinkResponse::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.lnurl !== 'string') return new Error(`${path}.lnurl: is not a string`) + if (opts.lnurl_CustomCheck && !opts.lnurl_CustomCheck(o.lnurl)) return new Error(`${path}.lnurl: custom check failed`) + + if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) + if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) + + return null +} + +export type RelaysMigration = { + relays: string[] +} +export const RelaysMigrationOptionalFields: [] = [] +export type RelaysMigrationOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + relays_CustomCheck?: (v: string[]) => boolean +} +export const RelaysMigrationValidate = (o?: RelaysMigration, opts: RelaysMigrationOptions = {}, path: string = 'RelaysMigration::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.relays)) return new Error(`${path}.relays: is not an array`) + for (let index = 0; index < o.relays.length; index++) { + if (typeof o.relays[index] !== 'string') return new Error(`${path}.relays[${index}]: is not a string`) + } + if (opts.relays_CustomCheck && !opts.relays_CustomCheck(o.relays)) return new Error(`${path}.relays: custom check failed`) + + return null +} + +export type UsageMetrics = { + metrics: UsageMetric[] +} +export const UsageMetricsOptionalFields: [] = [] +export type UsageMetricsOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + metrics_ItemOptions?: UsageMetricOptions + metrics_CustomCheck?: (v: UsageMetric[]) => boolean +} +export const UsageMetricsValidate = (o?: UsageMetrics, opts: UsageMetricsOptions = {}, path: string = 'UsageMetrics::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.metrics)) return new Error(`${path}.metrics: is not an array`) + for (let index = 0; index < o.metrics.length; index++) { + const metricsErr = UsageMetricValidate(o.metrics[index], opts.metrics_ItemOptions, `${path}.metrics[${index}]`) + if (metricsErr !== null) return metricsErr + } + if (opts.metrics_CustomCheck && !opts.metrics_CustomCheck(o.metrics)) return new Error(`${path}.metrics: custom check failed`) + + return null +} + +export type AddAppUserRequest = { + identifier: string + fail_if_exists: boolean + balance: number +} +export const AddAppUserRequestOptionalFields: [] = [] +export type AddAppUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + identifier_CustomCheck?: (v: string) => boolean + fail_if_exists_CustomCheck?: (v: boolean) => boolean + balance_CustomCheck?: (v: number) => boolean +} +export const AddAppUserRequestValidate = (o?: AddAppUserRequest, opts: AddAppUserRequestOptions = {}, path: string = 'AddAppUserRequest::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.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) + if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) + + if (typeof o.fail_if_exists !== 'boolean') return new Error(`${path}.fail_if_exists: is not a boolean`) + if (opts.fail_if_exists_CustomCheck && !opts.fail_if_exists_CustomCheck(o.fail_if_exists)) return new Error(`${path}.fail_if_exists: custom check failed`) + + 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`) + + return null +} + +export type AddAppUserInvoiceRequest = { + receiver_identifier: string + payer_identifier: string + http_callback_url: string + invoice_req: NewInvoiceRequest +} +export const AddAppUserInvoiceRequestOptionalFields: [] = [] +export type AddAppUserInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + receiver_identifier_CustomCheck?: (v: string) => boolean + payer_identifier_CustomCheck?: (v: string) => boolean + http_callback_url_CustomCheck?: (v: string) => boolean + invoice_req_Options?: NewInvoiceRequestOptions +} +export const AddAppUserInvoiceRequestValidate = (o?: AddAppUserInvoiceRequest, opts: AddAppUserInvoiceRequestOptions = {}, path: string = 'AddAppUserInvoiceRequest::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.receiver_identifier !== 'string') return new Error(`${path}.receiver_identifier: is not a string`) + if (opts.receiver_identifier_CustomCheck && !opts.receiver_identifier_CustomCheck(o.receiver_identifier)) return new Error(`${path}.receiver_identifier: custom check failed`) + + if (typeof o.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) + if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) + + if (typeof o.http_callback_url !== 'string') return new Error(`${path}.http_callback_url: is not a string`) + if (opts.http_callback_url_CustomCheck && !opts.http_callback_url_CustomCheck(o.http_callback_url)) return new Error(`${path}.http_callback_url: custom check failed`) + + const invoice_reqErr = NewInvoiceRequestValidate(o.invoice_req, opts.invoice_req_Options, `${path}.invoice_req`) + if (invoice_reqErr !== null) return invoice_reqErr + return null } @@ -514,6 +1124,201 @@ export const LnurlPayInfoResponseValidate = (o?: LnurlPayInfoResponse, opts: Lnu return null } +export type SetMockInvoiceAsPaidRequest = { + invoice: string + amount: number +} +export const SetMockInvoiceAsPaidRequestOptionalFields: [] = [] +export type SetMockInvoiceAsPaidRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const SetMockInvoiceAsPaidRequestValidate = (o?: SetMockInvoiceAsPaidRequest, opts: SetMockInvoiceAsPaidRequestOptions = {}, path: string = 'SetMockInvoiceAsPaidRequest::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 !== '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`) + + return null +} + +export type AppUser = { + identifier: string + info: UserInfo + max_withdrawable: number +} +export const AppUserOptionalFields: [] = [] +export type AppUserOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + identifier_CustomCheck?: (v: string) => boolean + info_Options?: UserInfoOptions + max_withdrawable_CustomCheck?: (v: number) => boolean +} +export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: string = 'AppUser::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.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) + if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) + + const infoErr = UserInfoValidate(o.info, opts.info_Options, `${path}.info`) + if (infoErr !== null) return infoErr + + + if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`) + if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`) + + return null +} + +export type GetAppUserRequest = { + user_identifier: string +} +export const GetAppUserRequestOptionalFields: [] = [] +export type GetAppUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean +} +export const GetAppUserRequestValidate = (o?: GetAppUserRequest, opts: GetAppUserRequestOptions = {}, path: string = 'GetAppUserRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + return null +} + +export type GetAppUserLNURLInfoRequest = { + user_identifier: string + base_url_override: string +} +export const GetAppUserLNURLInfoRequestOptionalFields: [] = [] +export type GetAppUserLNURLInfoRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean + base_url_override_CustomCheck?: (v: string) => boolean +} +export const GetAppUserLNURLInfoRequestValidate = (o?: GetAppUserLNURLInfoRequest, opts: GetAppUserLNURLInfoRequestOptions = {}, path: string = 'GetAppUserLNURLInfoRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + if (typeof o.base_url_override !== 'string') return new Error(`${path}.base_url_override: is not a string`) + if (opts.base_url_override_CustomCheck && !opts.base_url_override_CustomCheck(o.base_url_override)) return new Error(`${path}.base_url_override: custom check failed`) + + return null +} + +export type SetMockAppUserBalanceRequest = { + user_identifier: string + amount: number +} +export const SetMockAppUserBalanceRequestOptionalFields: [] = [] +export type SetMockAppUserBalanceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const SetMockAppUserBalanceRequestValidate = (o?: SetMockAppUserBalanceRequest, opts: SetMockAppUserBalanceRequestOptions = {}, path: string = 'SetMockAppUserBalanceRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + 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`) + + return null +} + +export type DecodeInvoiceRequest = { + invoice: string +} +export const DecodeInvoiceRequestOptionalFields: [] = [] +export type DecodeInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean +} +export const DecodeInvoiceRequestValidate = (o?: DecodeInvoiceRequest, opts: DecodeInvoiceRequestOptions = {}, path: string = 'DecodeInvoiceRequest::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`) + + return null +} + +export type PayInvoiceRequest = { + invoice: string + amount: number +} +export const PayInvoiceRequestOptionalFields: [] = [] +export type PayInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::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 !== '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`) + + return null +} + +export type PayInvoiceResponse = { + preimage: string + amount_paid: number + operation_id: string + service_fee: number + network_fee: number +} +export const PayInvoiceResponseOptionalFields: [] = [] +export type PayInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + preimage_CustomCheck?: (v: string) => boolean + amount_paid_CustomCheck?: (v: number) => boolean + operation_id_CustomCheck?: (v: string) => boolean + service_fee_CustomCheck?: (v: number) => boolean + network_fee_CustomCheck?: (v: number) => boolean +} +export const PayInvoiceResponseValidate = (o?: PayInvoiceResponse, opts: PayInvoiceResponseOptions = {}, path: string = 'PayInvoiceResponse::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.preimage !== 'string') return new Error(`${path}.preimage: is not a string`) + if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`) + + 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.operation_id !== 'string') return new Error(`${path}.operation_id: is not a string`) + if (opts.operation_id_CustomCheck && !opts.operation_id_CustomCheck(o.operation_id)) return new Error(`${path}.operation_id: custom check failed`) + + if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`) + if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: 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`) + + return null +} + export type HandleLnurlPayResponse = { pr: string routes: Empty[] @@ -542,122 +1347,6 @@ export const HandleLnurlPayResponseValidate = (o?: HandleLnurlPayResponse, opts: return null } -export type Product = { - id: string - name: string - price_sats: number -} -export const ProductOptionalFields: [] = [] -export type ProductOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - id_CustomCheck?: (v: string) => boolean - name_CustomCheck?: (v: string) => boolean - price_sats_CustomCheck?: (v: number) => boolean -} -export const ProductValidate = (o?: Product, opts: ProductOptions = {}, path: string = 'Product::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 !== 'string') return new Error(`${path}.id: is not a string`) - if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) - - 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 (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`) - if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`) - - return null -} - -export type ClosureMigration = { - closes_at_unix: number -} -export const ClosureMigrationOptionalFields: [] = [] -export type ClosureMigrationOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - closes_at_unix_CustomCheck?: (v: number) => boolean -} -export const ClosureMigrationValidate = (o?: ClosureMigration, opts: ClosureMigrationOptions = {}, path: string = 'ClosureMigration::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.closes_at_unix !== 'number') return new Error(`${path}.closes_at_unix: is not a number`) - if (opts.closes_at_unix_CustomCheck && !opts.closes_at_unix_CustomCheck(o.closes_at_unix)) return new Error(`${path}.closes_at_unix: custom check failed`) - - return null -} - -export type AuthApp = { - app: Application - auth_token: string -} -export const AuthAppOptionalFields: [] = [] -export type AuthAppOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - app_Options?: ApplicationOptions - auth_token_CustomCheck?: (v: string) => boolean -} -export const AuthAppValidate = (o?: AuthApp, opts: AuthAppOptions = {}, path: string = 'AuthApp::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') - - const appErr = ApplicationValidate(o.app, opts.app_Options, `${path}.app`) - if (appErr !== null) return appErr - - - if (typeof o.auth_token !== 'string') return new Error(`${path}.auth_token: is not a string`) - if (opts.auth_token_CustomCheck && !opts.auth_token_CustomCheck(o.auth_token)) return new Error(`${path}.auth_token: custom check failed`) - - return null -} - -export type AddAppUserRequest = { - identifier: string - fail_if_exists: boolean - balance: number -} -export const AddAppUserRequestOptionalFields: [] = [] -export type AddAppUserRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - identifier_CustomCheck?: (v: string) => boolean - fail_if_exists_CustomCheck?: (v: boolean) => boolean - balance_CustomCheck?: (v: number) => boolean -} -export const AddAppUserRequestValidate = (o?: AddAppUserRequest, opts: AddAppUserRequestOptions = {}, path: string = 'AddAppUserRequest::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.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) - if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) - - if (typeof o.fail_if_exists !== 'boolean') return new Error(`${path}.fail_if_exists: is not a boolean`) - if (opts.fail_if_exists_CustomCheck && !opts.fail_if_exists_CustomCheck(o.fail_if_exists)) return new Error(`${path}.fail_if_exists: custom check failed`) - - 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`) - - return null -} - -export type DecodeInvoiceRequest = { - invoice: string -} -export const DecodeInvoiceRequestOptionalFields: [] = [] -export type DecodeInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean -} -export const DecodeInvoiceRequestValidate = (o?: DecodeInvoiceRequest, opts: DecodeInvoiceRequestOptions = {}, path: string = 'DecodeInvoiceRequest::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`) - - return null -} - export type UserInfo = { userId: string balance: number @@ -719,491 +1408,88 @@ export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsO return null } -export type GetProductBuyLinkResponse = { - link: string -} -export const GetProductBuyLinkResponseOptionalFields: [] = [] -export type GetProductBuyLinkResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - link_CustomCheck?: (v: string) => boolean -} -export const GetProductBuyLinkResponseValidate = (o?: GetProductBuyLinkResponse, opts: GetProductBuyLinkResponseOptions = {}, path: string = 'GetProductBuyLinkResponse::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.link !== 'string') return new Error(`${path}.link: is not a string`) - if (opts.link_CustomCheck && !opts.link_CustomCheck(o.link)) return new Error(`${path}.link: custom check failed`) - - return null -} - -export type AppUser = { - identifier: string - info: UserInfo - max_withdrawable: number -} -export const AppUserOptionalFields: [] = [] -export type AppUserOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - identifier_CustomCheck?: (v: string) => boolean - info_Options?: UserInfoOptions - max_withdrawable_CustomCheck?: (v: number) => boolean -} -export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: string = 'AppUser::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.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) - if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) - - const infoErr = UserInfoValidate(o.info, opts.info_Options, `${path}.info`) - if (infoErr !== null) return infoErr - - - if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`) - if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`) - - return null -} - -export type NewAddressRequest = { - addressType: AddressType -} -export const NewAddressRequestOptionalFields: [] = [] -export type NewAddressRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - addressType_CustomCheck?: (v: AddressType) => boolean -} -export const NewAddressRequestValidate = (o?: NewAddressRequest, opts: NewAddressRequestOptions = {}, path: string = 'NewAddressRequest::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 (!enumCheckAddressType(o.addressType)) return new Error(`${path}.addressType: is not a valid AddressType`) - if (opts.addressType_CustomCheck && !opts.addressType_CustomCheck(o.addressType)) return new Error(`${path}.addressType: custom check failed`) - - return null -} - -export type LnurlWithdrawInfoResponse = { - tag: string - callback: string - k1: string - defaultDescription: string - minWithdrawable: number - maxWithdrawable: number - balanceCheck: string - payLink: string -} -export const LnurlWithdrawInfoResponseOptionalFields: [] = [] -export type LnurlWithdrawInfoResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - tag_CustomCheck?: (v: string) => boolean - callback_CustomCheck?: (v: string) => boolean - k1_CustomCheck?: (v: string) => boolean - defaultDescription_CustomCheck?: (v: string) => boolean - minWithdrawable_CustomCheck?: (v: number) => boolean - maxWithdrawable_CustomCheck?: (v: number) => boolean - balanceCheck_CustomCheck?: (v: string) => boolean - payLink_CustomCheck?: (v: string) => boolean -} -export const LnurlWithdrawInfoResponseValidate = (o?: LnurlWithdrawInfoResponse, opts: LnurlWithdrawInfoResponseOptions = {}, path: string = 'LnurlWithdrawInfoResponse::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.tag !== 'string') return new Error(`${path}.tag: is not a string`) - if (opts.tag_CustomCheck && !opts.tag_CustomCheck(o.tag)) return new Error(`${path}.tag: custom check failed`) - - if (typeof o.callback !== 'string') return new Error(`${path}.callback: is not a string`) - if (opts.callback_CustomCheck && !opts.callback_CustomCheck(o.callback)) return new Error(`${path}.callback: custom check failed`) - - if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) - if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) - - if (typeof o.defaultDescription !== 'string') return new Error(`${path}.defaultDescription: is not a string`) - if (opts.defaultDescription_CustomCheck && !opts.defaultDescription_CustomCheck(o.defaultDescription)) return new Error(`${path}.defaultDescription: custom check failed`) - - if (typeof o.minWithdrawable !== 'number') return new Error(`${path}.minWithdrawable: is not a number`) - if (opts.minWithdrawable_CustomCheck && !opts.minWithdrawable_CustomCheck(o.minWithdrawable)) return new Error(`${path}.minWithdrawable: custom check failed`) - - if (typeof o.maxWithdrawable !== 'number') return new Error(`${path}.maxWithdrawable: is not a number`) - if (opts.maxWithdrawable_CustomCheck && !opts.maxWithdrawable_CustomCheck(o.maxWithdrawable)) return new Error(`${path}.maxWithdrawable: custom check failed`) - - if (typeof o.balanceCheck !== 'string') return new Error(`${path}.balanceCheck: is not a string`) - if (opts.balanceCheck_CustomCheck && !opts.balanceCheck_CustomCheck(o.balanceCheck)) return new Error(`${path}.balanceCheck: custom check failed`) - - if (typeof o.payLink !== 'string') return new Error(`${path}.payLink: is not a string`) - if (opts.payLink_CustomCheck && !opts.payLink_CustomCheck(o.payLink)) return new Error(`${path}.payLink: custom check failed`) - - return null -} - -export type GetUserOperationsRequest = { - latestIncomingInvoice: number - latestOutgoingInvoice: number - latestIncomingTx: number - latestOutgoingTx: number - latestIncomingUserToUserPayment: number - latestOutgoingUserToUserPayment: number -} -export const GetUserOperationsRequestOptionalFields: [] = [] -export type GetUserOperationsRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - latestIncomingInvoice_CustomCheck?: (v: number) => boolean - latestOutgoingInvoice_CustomCheck?: (v: number) => boolean - latestIncomingTx_CustomCheck?: (v: number) => boolean - latestOutgoingTx_CustomCheck?: (v: number) => boolean - latestIncomingUserToUserPayment_CustomCheck?: (v: number) => boolean - latestOutgoingUserToUserPayment_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`) - - 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`) - - 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`) - - 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`) - - 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`) - - 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`) - - return null -} - -export type SendAppUserToAppPaymentRequest = { - from_user_identifier: string - amount: number -} -export const SendAppUserToAppPaymentRequestOptionalFields: [] = [] -export type SendAppUserToAppPaymentRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - from_user_identifier_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const SendAppUserToAppPaymentRequestValidate = (o?: SendAppUserToAppPaymentRequest, opts: SendAppUserToAppPaymentRequestOptions = {}, path: string = 'SendAppUserToAppPaymentRequest::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.from_user_identifier !== 'string') return new Error(`${path}.from_user_identifier: is not a string`) - if (opts.from_user_identifier_CustomCheck && !opts.from_user_identifier_CustomCheck(o.from_user_identifier)) return new Error(`${path}.from_user_identifier: custom check failed`) - - 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`) - - return null -} - -export type PayInvoiceResponse = { - preimage: string - amount_paid: number - operation_id: string - service_fee: number - network_fee: number -} -export const PayInvoiceResponseOptionalFields: [] = [] -export type PayInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - preimage_CustomCheck?: (v: string) => boolean - amount_paid_CustomCheck?: (v: number) => boolean - operation_id_CustomCheck?: (v: string) => boolean - service_fee_CustomCheck?: (v: number) => boolean - network_fee_CustomCheck?: (v: number) => boolean -} -export const PayInvoiceResponseValidate = (o?: PayInvoiceResponse, opts: PayInvoiceResponseOptions = {}, path: string = 'PayInvoiceResponse::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.preimage !== 'string') return new Error(`${path}.preimage: is not a string`) - if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`) - - 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.operation_id !== 'string') return new Error(`${path}.operation_id: is not a string`) - if (opts.operation_id_CustomCheck && !opts.operation_id_CustomCheck(o.operation_id)) return new Error(`${path}.operation_id: custom check failed`) - - if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`) - if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: 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`) - - return null -} - -export type PayAddressResponse = { - txId: string - operation_id: string - service_fee: number - network_fee: number -} -export const PayAddressResponseOptionalFields: [] = [] -export type PayAddressResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - txId_CustomCheck?: (v: string) => boolean - operation_id_CustomCheck?: (v: string) => boolean - service_fee_CustomCheck?: (v: number) => boolean - network_fee_CustomCheck?: (v: number) => boolean -} -export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddressResponseOptions = {}, path: string = 'PayAddressResponse::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.txId !== 'string') return new Error(`${path}.txId: is not a string`) - if (opts.txId_CustomCheck && !opts.txId_CustomCheck(o.txId)) return new Error(`${path}.txId: custom check failed`) - - if (typeof o.operation_id !== 'string') return new Error(`${path}.operation_id: is not a string`) - if (opts.operation_id_CustomCheck && !opts.operation_id_CustomCheck(o.operation_id)) return new Error(`${path}.operation_id: custom check failed`) - - if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`) - if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: 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`) - - return null -} - -export type DecodeInvoiceResponse = { - amount: number -} -export const DecodeInvoiceResponseOptionalFields: [] = [] -export type DecodeInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - amount_CustomCheck?: (v: number) => boolean -} -export const DecodeInvoiceResponseValidate = (o?: DecodeInvoiceResponse, opts: DecodeInvoiceResponseOptions = {}, path: string = 'DecodeInvoiceResponse::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`) - - return null -} - -export type LnurlLinkResponse = { - lnurl: string - k1: string -} -export const LnurlLinkResponseOptionalFields: [] = [] -export type LnurlLinkResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - lnurl_CustomCheck?: (v: string) => boolean - k1_CustomCheck?: (v: string) => boolean -} -export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLinkResponseOptions = {}, path: string = 'LnurlLinkResponse::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.lnurl !== 'string') return new Error(`${path}.lnurl: is not a string`) - if (opts.lnurl_CustomCheck && !opts.lnurl_CustomCheck(o.lnurl)) return new Error(`${path}.lnurl: custom check failed`) - - if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) - if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) - - return null -} - -export type Application = { - name: string +export type Product = { id: string - balance: number - npub: string + name: string + price_sats: number } -export const ApplicationOptionalFields: [] = [] -export type ApplicationOptions = OptionsBaseMessage & { +export const ProductOptionalFields: [] = [] +export type ProductOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - name_CustomCheck?: (v: string) => boolean id_CustomCheck?: (v: string) => boolean - balance_CustomCheck?: (v: number) => boolean - npub_CustomCheck?: (v: string) => boolean + name_CustomCheck?: (v: string) => boolean + price_sats_CustomCheck?: (v: number) => boolean } -export const ApplicationValidate = (o?: Application, opts: ApplicationOptions = {}, path: string = 'Application::root.'): Error | null => { +export const ProductValidate = (o?: Product, opts: ProductOptions = {}, path: string = 'Product::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.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 (typeof o.id !== 'string') return new Error(`${path}.id: is not a string`) if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) - 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 (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 (typeof o.npub !== 'string') return new Error(`${path}.npub: is not a string`) - if (opts.npub_CustomCheck && !opts.npub_CustomCheck(o.npub)) return new Error(`${path}.npub: custom check failed`) + if (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`) + if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`) return null } -export type AddAppInvoiceRequest = { - payer_identifier: string - http_callback_url: string - invoice_req: NewInvoiceRequest +export type UsageMetric = { + processed_at_nano: string + parsed_in_nano: number + auth_in_nano: number + validate_in_nano: number + handle_in_nano: number + rpc_name: string + batch: boolean + nostr: boolean + batch_size: number } -export const AddAppInvoiceRequestOptionalFields: [] = [] -export type AddAppInvoiceRequestOptions = OptionsBaseMessage & { +export const UsageMetricOptionalFields: [] = [] +export type UsageMetricOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - payer_identifier_CustomCheck?: (v: string) => boolean - http_callback_url_CustomCheck?: (v: string) => boolean - invoice_req_Options?: NewInvoiceRequestOptions + processed_at_nano_CustomCheck?: (v: string) => boolean + parsed_in_nano_CustomCheck?: (v: number) => boolean + auth_in_nano_CustomCheck?: (v: number) => boolean + validate_in_nano_CustomCheck?: (v: number) => boolean + handle_in_nano_CustomCheck?: (v: number) => boolean + rpc_name_CustomCheck?: (v: string) => boolean + batch_CustomCheck?: (v: boolean) => boolean + nostr_CustomCheck?: (v: boolean) => boolean + batch_size_CustomCheck?: (v: number) => boolean } -export const AddAppInvoiceRequestValidate = (o?: AddAppInvoiceRequest, opts: AddAppInvoiceRequestOptions = {}, path: string = 'AddAppInvoiceRequest::root.'): Error | null => { +export const UsageMetricValidate = (o?: UsageMetric, opts: UsageMetricOptions = {}, path: string = 'UsageMetric::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.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) - if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) + if (typeof o.processed_at_nano !== 'string') return new Error(`${path}.processed_at_nano: is not a string`) + if (opts.processed_at_nano_CustomCheck && !opts.processed_at_nano_CustomCheck(o.processed_at_nano)) return new Error(`${path}.processed_at_nano: custom check failed`) - if (typeof o.http_callback_url !== 'string') return new Error(`${path}.http_callback_url: is not a string`) - if (opts.http_callback_url_CustomCheck && !opts.http_callback_url_CustomCheck(o.http_callback_url)) return new Error(`${path}.http_callback_url: custom check failed`) + if (typeof o.parsed_in_nano !== 'number') return new Error(`${path}.parsed_in_nano: is not a number`) + if (opts.parsed_in_nano_CustomCheck && !opts.parsed_in_nano_CustomCheck(o.parsed_in_nano)) return new Error(`${path}.parsed_in_nano: custom check failed`) - const invoice_reqErr = NewInvoiceRequestValidate(o.invoice_req, opts.invoice_req_Options, `${path}.invoice_req`) - if (invoice_reqErr !== null) return invoice_reqErr - + if (typeof o.auth_in_nano !== 'number') return new Error(`${path}.auth_in_nano: is not a number`) + if (opts.auth_in_nano_CustomCheck && !opts.auth_in_nano_CustomCheck(o.auth_in_nano)) return new Error(`${path}.auth_in_nano: custom check failed`) - return null -} + if (typeof o.validate_in_nano !== 'number') return new Error(`${path}.validate_in_nano: is not a number`) + if (opts.validate_in_nano_CustomCheck && !opts.validate_in_nano_CustomCheck(o.validate_in_nano)) return new Error(`${path}.validate_in_nano: custom check failed`) -export type OpenChannelRequest = { - destination: string - fundingAmount: number - pushAmount: number - closeAddress: string -} -export const OpenChannelRequestOptionalFields: [] = [] -export type OpenChannelRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - destination_CustomCheck?: (v: string) => boolean - fundingAmount_CustomCheck?: (v: number) => boolean - pushAmount_CustomCheck?: (v: number) => boolean - closeAddress_CustomCheck?: (v: string) => boolean -} -export const OpenChannelRequestValidate = (o?: OpenChannelRequest, opts: OpenChannelRequestOptions = {}, path: string = 'OpenChannelRequest::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.handle_in_nano !== 'number') return new Error(`${path}.handle_in_nano: is not a number`) + if (opts.handle_in_nano_CustomCheck && !opts.handle_in_nano_CustomCheck(o.handle_in_nano)) return new Error(`${path}.handle_in_nano: custom check failed`) - if (typeof o.destination !== 'string') return new Error(`${path}.destination: is not a string`) - if (opts.destination_CustomCheck && !opts.destination_CustomCheck(o.destination)) return new Error(`${path}.destination: custom check failed`) + if (typeof o.rpc_name !== 'string') return new Error(`${path}.rpc_name: is not a string`) + if (opts.rpc_name_CustomCheck && !opts.rpc_name_CustomCheck(o.rpc_name)) return new Error(`${path}.rpc_name: custom check failed`) - if (typeof o.fundingAmount !== 'number') return new Error(`${path}.fundingAmount: is not a number`) - if (opts.fundingAmount_CustomCheck && !opts.fundingAmount_CustomCheck(o.fundingAmount)) return new Error(`${path}.fundingAmount: custom check failed`) + if (typeof o.batch !== 'boolean') return new Error(`${path}.batch: is not a boolean`) + if (opts.batch_CustomCheck && !opts.batch_CustomCheck(o.batch)) return new Error(`${path}.batch: custom check failed`) - if (typeof o.pushAmount !== 'number') return new Error(`${path}.pushAmount: is not a number`) - if (opts.pushAmount_CustomCheck && !opts.pushAmount_CustomCheck(o.pushAmount)) return new Error(`${path}.pushAmount: custom check failed`) + if (typeof o.nostr !== 'boolean') return new Error(`${path}.nostr: is not a boolean`) + if (opts.nostr_CustomCheck && !opts.nostr_CustomCheck(o.nostr)) return new Error(`${path}.nostr: custom check failed`) - if (typeof o.closeAddress !== 'string') return new Error(`${path}.closeAddress: is not a string`) - if (opts.closeAddress_CustomCheck && !opts.closeAddress_CustomCheck(o.closeAddress)) return new Error(`${path}.closeAddress: custom check failed`) - - return null -} - -export type UserOperation = { - paidAtUnix: number - type: UserOperationType - inbound: boolean - amount: number - identifier: string - operationId: string - service_fee: number - network_fee: number - confirmed: boolean -} -export const UserOperationOptionalFields: [] = [] -export type UserOperationOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - paidAtUnix_CustomCheck?: (v: number) => boolean - type_CustomCheck?: (v: UserOperationType) => boolean - inbound_CustomCheck?: (v: boolean) => boolean - amount_CustomCheck?: (v: number) => boolean - identifier_CustomCheck?: (v: string) => boolean - operationId_CustomCheck?: (v: string) => boolean - service_fee_CustomCheck?: (v: number) => boolean - network_fee_CustomCheck?: (v: number) => boolean - confirmed_CustomCheck?: (v: boolean) => boolean -} -export const UserOperationValidate = (o?: UserOperation, opts: UserOperationOptions = {}, path: string = 'UserOperation::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.paidAtUnix !== 'number') return new Error(`${path}.paidAtUnix: is not a number`) - if (opts.paidAtUnix_CustomCheck && !opts.paidAtUnix_CustomCheck(o.paidAtUnix)) return new Error(`${path}.paidAtUnix: custom check failed`) - - if (!enumCheckUserOperationType(o.type)) return new Error(`${path}.type: is not a valid UserOperationType`) - if (opts.type_CustomCheck && !opts.type_CustomCheck(o.type)) return new Error(`${path}.type: custom check failed`) - - if (typeof o.inbound !== 'boolean') return new Error(`${path}.inbound: is not a boolean`) - if (opts.inbound_CustomCheck && !opts.inbound_CustomCheck(o.inbound)) return new Error(`${path}.inbound: custom check failed`) - - 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.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) - if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) - - if (typeof o.operationId !== 'string') return new Error(`${path}.operationId: is not a string`) - if (opts.operationId_CustomCheck && !opts.operationId_CustomCheck(o.operationId)) return new Error(`${path}.operationId: custom check failed`) - - if (typeof o.service_fee !== 'number') return new Error(`${path}.service_fee: is not a number`) - if (opts.service_fee_CustomCheck && !opts.service_fee_CustomCheck(o.service_fee)) return new Error(`${path}.service_fee: 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`) - - if (typeof o.confirmed !== 'boolean') return new Error(`${path}.confirmed: is not a boolean`) - if (opts.confirmed_CustomCheck && !opts.confirmed_CustomCheck(o.confirmed)) return new Error(`${path}.confirmed: custom check failed`) - - return null -} - -export type LiveUserOperation = { - operation: UserOperation -} -export const LiveUserOperationOptionalFields: [] = [] -export type LiveUserOperationOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - 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') - - const operationErr = UserOperationValidate(o.operation, opts.operation_Options, `${path}.operation`) - if (operationErr !== null) return operationErr - - - return null -} - -export type RelaysMigration = { - relays: string[] -} -export const RelaysMigrationOptionalFields: [] = [] -export type RelaysMigrationOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - relays_CustomCheck?: (v: string[]) => boolean -} -export const RelaysMigrationValidate = (o?: RelaysMigration, opts: RelaysMigrationOptions = {}, path: string = 'RelaysMigration::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.relays)) return new Error(`${path}.relays: is not an array`) - for (let index = 0; index < o.relays.length; index++) { - if (typeof o.relays[index] !== 'string') return new Error(`${path}.relays[${index}]: is not a string`) - } - if (opts.relays_CustomCheck && !opts.relays_CustomCheck(o.relays)) return new Error(`${path}.relays: custom check failed`) + if (typeof o.batch_size !== 'number') return new Error(`${path}.batch_size: is not a number`) + if (opts.batch_size_CustomCheck && !opts.batch_size_CustomCheck(o.batch_size)) return new Error(`${path}.batch_size: custom check failed`) return null } @@ -1231,283 +1517,85 @@ export const AddAppRequestValidate = (o?: AddAppRequest, opts: AddAppRequestOpti return null } -export type SendAppUserToAppUserPaymentRequest = { - from_user_identifier: string - to_user_identifier: string - amount: number +export type AuthApp = { + app: Application + auth_token: string } -export const SendAppUserToAppUserPaymentRequestOptionalFields: [] = [] -export type SendAppUserToAppUserPaymentRequestOptions = OptionsBaseMessage & { +export const AuthAppOptionalFields: [] = [] +export type AuthAppOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - from_user_identifier_CustomCheck?: (v: string) => boolean - to_user_identifier_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean + app_Options?: ApplicationOptions + auth_token_CustomCheck?: (v: string) => boolean } -export const SendAppUserToAppUserPaymentRequestValidate = (o?: SendAppUserToAppUserPaymentRequest, opts: SendAppUserToAppUserPaymentRequestOptions = {}, path: string = 'SendAppUserToAppUserPaymentRequest::root.'): Error | null => { +export const AuthAppValidate = (o?: AuthApp, opts: AuthAppOptions = {}, path: string = 'AuthApp::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.from_user_identifier !== 'string') return new Error(`${path}.from_user_identifier: is not a string`) - if (opts.from_user_identifier_CustomCheck && !opts.from_user_identifier_CustomCheck(o.from_user_identifier)) return new Error(`${path}.from_user_identifier: custom check failed`) + const appErr = ApplicationValidate(o.app, opts.app_Options, `${path}.app`) + if (appErr !== null) return appErr + - if (typeof o.to_user_identifier !== 'string') return new Error(`${path}.to_user_identifier: is not a string`) - if (opts.to_user_identifier_CustomCheck && !opts.to_user_identifier_CustomCheck(o.to_user_identifier)) return new Error(`${path}.to_user_identifier: custom check failed`) - - 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.auth_token !== 'string') return new Error(`${path}.auth_token: is not a string`) + if (opts.auth_token_CustomCheck && !opts.auth_token_CustomCheck(o.auth_token)) return new Error(`${path}.auth_token: custom check failed`) return null } -export type SetMockAppBalanceRequest = { - amount: number -} -export const SetMockAppBalanceRequestOptionalFields: [] = [] -export type SetMockAppBalanceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - amount_CustomCheck?: (v: number) => boolean -} -export const SetMockAppBalanceRequestValidate = (o?: SetMockAppBalanceRequest, opts: SetMockAppBalanceRequestOptions = {}, path: string = 'SetMockAppBalanceRequest::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`) - - return null -} - -export type GetAppUserLNURLInfoRequest = { - user_identifier: string - base_url_override: string -} -export const GetAppUserLNURLInfoRequestOptionalFields: [] = [] -export type GetAppUserLNURLInfoRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean - base_url_override_CustomCheck?: (v: string) => boolean -} -export const GetAppUserLNURLInfoRequestValidate = (o?: GetAppUserLNURLInfoRequest, opts: GetAppUserLNURLInfoRequestOptions = {}, path: string = 'GetAppUserLNURLInfoRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) - - if (typeof o.base_url_override !== 'string') return new Error(`${path}.base_url_override: is not a string`) - if (opts.base_url_override_CustomCheck && !opts.base_url_override_CustomCheck(o.base_url_override)) return new Error(`${path}.base_url_override: custom check failed`) - - return null -} - -export type SetMockAppUserBalanceRequest = { - user_identifier: string - amount: number -} -export const SetMockAppUserBalanceRequestOptionalFields: [] = [] -export type SetMockAppUserBalanceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const SetMockAppUserBalanceRequestValidate = (o?: SetMockAppUserBalanceRequest, opts: SetMockAppUserBalanceRequestOptions = {}, path: string = 'SetMockAppUserBalanceRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) - - 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`) - - return null -} - -export type PayAppUserInvoiceRequest = { - user_identifier: string +export type NewInvoiceResponse = { invoice: string - amount: number } -export const PayAppUserInvoiceRequestOptionalFields: [] = [] -export type PayAppUserInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean - invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const PayAppUserInvoiceRequestValidate = (o?: PayAppUserInvoiceRequest, opts: PayAppUserInvoiceRequestOptions = {}, path: string = 'PayAppUserInvoiceRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) - - 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 !== '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`) - - return null -} - -export type PayAddressRequest = { - address: string - amoutSats: number - satsPerVByte: number -} -export const PayAddressRequestOptionalFields: [] = [] -export type PayAddressRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - address_CustomCheck?: (v: string) => boolean - amoutSats_CustomCheck?: (v: number) => boolean - satsPerVByte_CustomCheck?: (v: number) => boolean -} -export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddressRequestOptions = {}, path: string = 'PayAddressRequest::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.address !== 'string') return new Error(`${path}.address: is not a string`) - if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) - - if (typeof o.amoutSats !== 'number') return new Error(`${path}.amoutSats: is not a number`) - if (opts.amoutSats_CustomCheck && !opts.amoutSats_CustomCheck(o.amoutSats)) return new Error(`${path}.amoutSats: custom check failed`) - - if (typeof o.satsPerVByte !== 'number') return new Error(`${path}.satsPerVByte: is not a number`) - if (opts.satsPerVByte_CustomCheck && !opts.satsPerVByte_CustomCheck(o.satsPerVByte)) return new Error(`${path}.satsPerVByte: custom check failed`) - - return null -} - -export type PayInvoiceRequest = { - invoice: string - amount: number -} -export const PayInvoiceRequestOptionalFields: [] = [] -export type PayInvoiceRequestOptions = OptionsBaseMessage & { +export const NewInvoiceResponseOptionalFields: [] = [] +export type NewInvoiceResponseOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean } -export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::root.'): Error | null => { +export const NewInvoiceResponseValidate = (o?: NewInvoiceResponse, opts: NewInvoiceResponseOptions = {}, path: string = 'NewInvoiceResponse::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 !== '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`) - return null } -export type GetUserOperationsResponse = { - latestOutgoingInvoiceOperations: UserOperations - latestIncomingInvoiceOperations: UserOperations - latestOutgoingTxOperations: UserOperations - latestIncomingTxOperations: UserOperations - latestOutgoingUserToUserPayemnts: UserOperations - latestIncomingUserToUserPayemnts: UserOperations +export type OpenChannelResponse = { + channelId: string } -export const GetUserOperationsResponseOptionalFields: [] = [] -export type GetUserOperationsResponseOptions = OptionsBaseMessage & { +export const OpenChannelResponseOptionalFields: [] = [] +export type OpenChannelResponseOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - latestOutgoingInvoiceOperations_Options?: UserOperationsOptions - latestIncomingInvoiceOperations_Options?: UserOperationsOptions - latestOutgoingTxOperations_Options?: UserOperationsOptions - latestIncomingTxOperations_Options?: UserOperationsOptions - latestOutgoingUserToUserPayemnts_Options?: UserOperationsOptions - latestIncomingUserToUserPayemnts_Options?: UserOperationsOptions + channelId_CustomCheck?: (v: string) => boolean } -export const GetUserOperationsResponseValidate = (o?: GetUserOperationsResponse, opts: GetUserOperationsResponseOptions = {}, path: string = 'GetUserOperationsResponse::root.'): Error | null => { +export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenChannelResponseOptions = {}, path: string = 'OpenChannelResponse::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') - const latestOutgoingInvoiceOperationsErr = UserOperationsValidate(o.latestOutgoingInvoiceOperations, opts.latestOutgoingInvoiceOperations_Options, `${path}.latestOutgoingInvoiceOperations`) - if (latestOutgoingInvoiceOperationsErr !== null) return latestOutgoingInvoiceOperationsErr - - - const latestIncomingInvoiceOperationsErr = UserOperationsValidate(o.latestIncomingInvoiceOperations, opts.latestIncomingInvoiceOperations_Options, `${path}.latestIncomingInvoiceOperations`) - if (latestIncomingInvoiceOperationsErr !== null) return latestIncomingInvoiceOperationsErr - - - const latestOutgoingTxOperationsErr = UserOperationsValidate(o.latestOutgoingTxOperations, opts.latestOutgoingTxOperations_Options, `${path}.latestOutgoingTxOperations`) - if (latestOutgoingTxOperationsErr !== null) return latestOutgoingTxOperationsErr - - - const latestIncomingTxOperationsErr = UserOperationsValidate(o.latestIncomingTxOperations, opts.latestIncomingTxOperations_Options, `${path}.latestIncomingTxOperations`) - if (latestIncomingTxOperationsErr !== null) return latestIncomingTxOperationsErr - - - const latestOutgoingUserToUserPayemntsErr = UserOperationsValidate(o.latestOutgoingUserToUserPayemnts, opts.latestOutgoingUserToUserPayemnts_Options, `${path}.latestOutgoingUserToUserPayemnts`) - if (latestOutgoingUserToUserPayemntsErr !== null) return latestOutgoingUserToUserPayemntsErr - - - const latestIncomingUserToUserPayemntsErr = UserOperationsValidate(o.latestIncomingUserToUserPayemnts, opts.latestIncomingUserToUserPayemnts_Options, `${path}.latestIncomingUserToUserPayemnts`) - if (latestIncomingUserToUserPayemntsErr !== null) return latestIncomingUserToUserPayemntsErr - + if (typeof o.channelId !== 'string') return new Error(`${path}.channelId: is not a string`) + if (opts.channelId_CustomCheck && !opts.channelId_CustomCheck(o.channelId)) return new Error(`${path}.channelId: custom check failed`) return null } -export type MigrationUpdate = { - closure?: ClosureMigration - relays?: RelaysMigration +export type AddProductRequest = { + name: string + price_sats: number } -export type MigrationUpdateOptionalField = 'closure' | 'relays' -export const MigrationUpdateOptionalFields: MigrationUpdateOptionalField[] = ['closure', 'relays'] -export type MigrationUpdateOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: MigrationUpdateOptionalField[] - closure_Options?: ClosureMigrationOptions - relays_Options?: RelaysMigrationOptions -} -export const MigrationUpdateValidate = (o?: MigrationUpdate, opts: MigrationUpdateOptions = {}, path: string = 'MigrationUpdate::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.closure === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('closure')) { - const closureErr = ClosureMigrationValidate(o.closure, opts.closure_Options, `${path}.closure`) - if (closureErr !== null) return closureErr - } - - - if (typeof o.relays === 'object' || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('relays')) { - const relaysErr = RelaysMigrationValidate(o.relays, opts.relays_Options, `${path}.relays`) - if (relaysErr !== null) return relaysErr - } - - - return null -} - -export type Empty = { -} -export const EmptyOptionalFields: [] = [] -export type EmptyOptions = OptionsBaseMessage & { +export const AddProductRequestOptionalFields: [] = [] +export type AddProductRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] + name_CustomCheck?: (v: string) => boolean + price_sats_CustomCheck?: (v: number) => boolean } -export const EmptyValidate = (o?: Empty, opts: EmptyOptions = {}, path: string = 'Empty::root.'): Error | null => { +export const AddProductRequestValidate = (o?: AddProductRequest, opts: AddProductRequestOptions = {}, path: string = 'AddProductRequest::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') - - return null -} - -export type GetAppUserRequest = { - user_identifier: string -} -export const GetAppUserRequestOptionalFields: [] = [] -export type GetAppUserRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean -} -export const GetAppUserRequestValidate = (o?: GetAppUserRequest, opts: GetAppUserRequestOptions = {}, path: string = 'GetAppUserRequest::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.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + 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 (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`) + if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`) return null } diff --git a/proto/protoc-gen-pub b/proto/protoc-gen-pub index 58d0b5c4..ffeb545c 100755 Binary files a/proto/protoc-gen-pub and b/proto/protoc-gen-pub differ diff --git a/proto/service/methods.proto b/proto/service/methods.proto index cce0f31b..c9d6fcf6 100644 --- a/proto/service/methods.proto +++ b/proto/service/methods.proto @@ -96,6 +96,12 @@ service LightningPub { option (http_method) = "post"; option (http_route) = "/api/admin/app/auth"; } + + rpc GetMetrics(structs.Empty) returns (structs.UsageMetrics) { + option (auth_type) = "Admin"; + option (http_method) = "post"; + option (http_route) = "/api/admin/metrics"; + } // // diff --git a/proto/service/structs.proto b/proto/service/structs.proto index edbe86f1..9487942c 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -12,6 +12,22 @@ message EncryptionExchangeRequest { string deviceId = 2; } +message UsageMetric { + string processed_at_nano = 1; + int64 parsed_in_nano = 2; + int64 auth_in_nano = 3; + int64 validate_in_nano = 4; + int64 handle_in_nano = 5; + string rpc_name = 6; + bool batch = 7; + bool nostr = 8; + int64 batch_size = 9; +} + +message UsageMetrics { + repeated UsageMetric metrics = 1; +} + message LndGetInfoRequest { int64 nodeId = 1; } diff --git a/src/auth.ts b/src/auth.ts index fdc65285..188ce3b6 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -10,6 +10,7 @@ const serverOptions = (mainHandler: Main): ServerOptions => { AppAuthGuard: async (authHeader) => { return { app_id: mainHandler.applicationManager.DecodeAppToken(stripBearer(authHeader)) } }, UserAuthGuard: async (authHeader) => { return mainHandler.appUserManager.DecodeUserToken(stripBearer(authHeader)) }, GuestAuthGuard: async (_) => ({}), + metricsCallback: metrics => mainHandler.metricsManager.AddMetrics(metrics) //throwErrors: true } } diff --git a/src/services/main/index.ts b/src/services/main/index.ts index 1f7e9334..7bc71da9 100644 --- a/src/services/main/index.ts +++ b/src/services/main/index.ts @@ -15,6 +15,7 @@ import { Application } from '../storage/entity/Application.js' import { UserReceivingInvoice, ZapInfo } from '../storage/entity/UserReceivingInvoice.js' import { UnsignedEvent } from '../nostr/tools/event.js' import { NostrSend } from '../nostr/handler.js' +import MetricsManager from '../metrics/index.js' export const LoadMainSettingsFromEnv = (test = false): MainSettings => { return { lndSettings: LoadLndSettingsFromEnv(test), @@ -51,11 +52,13 @@ export default class { appUserManager: AppUserManager paymentManager: PaymentManager paymentSubs: Record void) | null> = {} + metricsManager: MetricsManager nostrSend: NostrSend = () => { getLogger({})("nostr send not initialized yet") } constructor(settings: MainSettings) { this.settings = settings this.storage = new Storage(settings.storageSettings) + this.metricsManager = new MetricsManager() this.lnd = NewLightningHandler(settings.lndSettings, this.addressPaidCb, this.invoicePaidCb, this.newBlockCb) this.paymentManager = new PaymentManager(this.storage, this.lnd, this.settings, this.addressPaidCb, this.invoicePaidCb) diff --git a/src/services/metrics/index.ts b/src/services/metrics/index.ts new file mode 100644 index 00000000..2b71b545 --- /dev/null +++ b/src/services/metrics/index.ts @@ -0,0 +1,27 @@ +import * as Types from '../../../proto/autogenerated/ts/types' +const maxEvents = 100_000 +export default class Handler { + metrics: Types.UsageMetric[] = [] + AddMetrics(newMetrics: Types.RequestMetric[]) { + const parsed: Types.UsageMetric[] = newMetrics.map(m => ({ + rpc_name: m.rpcName, + processed_at_nano: m.start.toString(), + batch: m.batch, + nostr: m.nostr, + batch_size: m.batchSize, + parsed_in_nano: Number(m.parse - m.start), + auth_in_nano: Number(m.guard - m.parse), + validate_in_nano: Number(m.validate - m.guard), + handle_in_nano: Number(m.handle - m.validate) + })) + const len = this.metrics.push(...parsed) + if (len > maxEvents) { + this.metrics.splice(0, len - maxEvents) + } + } + async GetMetrics(): Promise { + return { + metrics: this.metrics + } + } +} \ No newline at end of file diff --git a/src/services/serverMethods/index.ts b/src/services/serverMethods/index.ts index a93142a4..412273fc 100644 --- a/src/services/serverMethods/index.ts +++ b/src/services/serverMethods/index.ts @@ -1,8 +1,12 @@ import * as Types from '../../../proto/autogenerated/ts/types.js' import { getLogger } from '../helpers/logger.js' +import main from '../main/index.js' import Main from '../main/index.js' export default (mainHandler: Main): Types.ServerMethods => { return { + GetMetrics: async ({ ctx }) => { + return mainHandler.metricsManager.GetMetrics() + }, EncryptionExchange: async () => { }, Health: async () => { await mainHandler.lnd.Health() }, LndGetInfo: async ({ ctx }) => {