diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md new file mode 100644 index 00000000..f518c73e --- /dev/null +++ b/proto/autogenerated/client.md @@ -0,0 +1,370 @@ +# NOSTR API DEFINITION + + +A nostr request will take the same parameter and give the same response as an http request, but it will use nostr as transport, to do that it will send encrypted events to the server public key, in the event 6 thing are required: +- __rpcName__: string containing the name of the method +- __params__: a map with the all the url params for the method +- __query__: a map with the the url query for the method +- __body__: the body of the method request +- __requestId__: id of the request to be able to get a response + +The nostr server will send back a message response, and inside the body there will also be a __requestId__ to identify the request this response is answering + +## NOSTR Methods +### These are the nostr methods the client implements to communicate with the API via nostr + +- GetUserInfo + - auth type: __User__ + - This methods has an __empty__ __request__ body + - output: [UserInfo](#UserInfo) + +- GetUserOperations + - auth type: __User__ + - input: [GetUserOperationsRequest](#GetUserOperationsRequest) + - output: [GetUserOperationsResponse](#GetUserOperationsResponse) + +- NewAddress + - auth type: __User__ + - input: [NewAddressRequest](#NewAddressRequest) + - output: [NewAddressResponse](#NewAddressResponse) + +- PayAddress + - auth type: __User__ + - input: [PayAddressRequest](#PayAddressRequest) + - output: [PayAddressResponse](#PayAddressResponse) + +- NewInvoice + - auth type: __User__ + - input: [NewInvoiceRequest](#NewInvoiceRequest) + - output: [NewInvoiceResponse](#NewInvoiceResponse) + +- DecodeInvoice + - auth type: __User__ + - input: [DecodeInvoiceRequest](#DecodeInvoiceRequest) + - output: [DecodeInvoiceResponse](#DecodeInvoiceResponse) + +- PayInvoice + - auth type: __User__ + - input: [PayInvoiceRequest](#PayInvoiceRequest) + - output: [PayInvoiceResponse](#PayInvoiceResponse) + +- OpenChannel + - auth type: __User__ + - input: [OpenChannelRequest](#OpenChannelRequest) + - output: [OpenChannelResponse](#OpenChannelResponse) + +- GetLnurlWithdrawLink + - auth type: __User__ + - This methods has an __empty__ __request__ body + - output: [LnurlLinkResponse](#LnurlLinkResponse) + +- GetLNURLChannelLink + - auth type: __User__ + - This methods has an __empty__ __request__ body + - output: [LnurlLinkResponse](#LnurlLinkResponse) + +# HTTP API DEFINITION + +## Supported HTTP Auths +### These are the supported http auth types, to give different type of access to the API users + +- __Guest__: + - expected context content + +- __User__: + - expected context content + - __user_id__: _string_ + +- __Admin__: + - this auth type is __encrypted__ + - expected context content + - __admin_id__: _string_ + +## HTTP Methods +### These are the http methods the client implements to communicate with the API + +- Health + - auth type: __Guest__ + - http method: __get__ + - http route: __/api/health__ + - This methods has an __empty__ __request__ body + - This methods has an __empty__ __response__ body + +- EncryptionExchange + - auth type: __Guest__ + - http method: __post__ + - http route: __/api/encryption/exchange__ + - input: [EncryptionExchangeRequest](#EncryptionExchangeRequest) + - This methods has an __empty__ __response__ body + +- LndGetInfo + - auth type: __Admin__ + - this method is encrypted + - http method: __post__ + - http route: __/api/lnd/getinfo__ + - input: [LndGetInfoRequest](#LndGetInfoRequest) + - output: [LndGetInfoResponse](#LndGetInfoResponse) + +- AddUser + - auth type: __Guest__ + - http method: __post__ + - http route: __/api/user/add__ + - input: [AddUserRequest](#AddUserRequest) + - output: [AddUserResponse](#AddUserResponse) + +- AuthUser + - auth type: __Guest__ + - http method: __post__ + - http route: __/api/user/auth__ + - input: [AuthUserRequest](#AuthUserRequest) + - output: [AuthUserResponse](#AuthUserResponse) + +- GetUserInfo + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/info__ + - This methods has an __empty__ __request__ body + - output: [UserInfo](#UserInfo) + +- GetUserOperations + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/operations__ + - input: [GetUserOperationsRequest](#GetUserOperationsRequest) + - output: [GetUserOperationsResponse](#GetUserOperationsResponse) + +- NewAddress + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/chain/new__ + - input: [NewAddressRequest](#NewAddressRequest) + - output: [NewAddressResponse](#NewAddressResponse) + +- PayAddress + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/chain/pay__ + - input: [PayAddressRequest](#PayAddressRequest) + - output: [PayAddressResponse](#PayAddressResponse) + +- NewInvoice + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/invoice/new__ + - input: [NewInvoiceRequest](#NewInvoiceRequest) + - output: [NewInvoiceResponse](#NewInvoiceResponse) + +- DecodeInvoice + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/invoice/decode__ + - input: [DecodeInvoiceRequest](#DecodeInvoiceRequest) + - output: [DecodeInvoiceResponse](#DecodeInvoiceResponse) + +- PayInvoice + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/invoice/pay__ + - input: [PayInvoiceRequest](#PayInvoiceRequest) + - output: [PayInvoiceResponse](#PayInvoiceResponse) + +- OpenChannel + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/open/channel__ + - input: [OpenChannelRequest](#OpenChannelRequest) + - output: [OpenChannelResponse](#OpenChannelResponse) + +- GetLnurlWithdrawLink + - auth type: __User__ + - http method: __get__ + - http route: __/api/user/lnurl_withdraw/link__ + - This methods has an __empty__ __request__ body + - output: [LnurlLinkResponse](#LnurlLinkResponse) + +- GetLnurlWithdrawInfo + - auth type: __Guest__ + - http method: __get__ + - http route: __/api/guest/lnurl_withdraw/info__ + - the request url __query__ can take the following string items: + - k1 + - This methods has an __empty__ __request__ body + - output: [LnurlWithdrawInfoResponse](#LnurlWithdrawInfoResponse) + +- HandleLnurlWithdraw + - auth type: __Guest__ + - http method: __get__ + - http route: __/api/guest/lnurl_withdraw/handle__ + - the request url __query__ can take the following string items: + - k1 + - pr + - This methods has an __empty__ __request__ body + - This methods has an __empty__ __response__ body + +- GetLnurlPayInfo + - auth type: __Guest__ + - http method: __get__ + - http route: __/api/guest/lnurl_pay/info__ + - the request url __query__ can take the following string items: + - k1 + - This methods has an __empty__ __request__ body + - output: [LnurlPayInfoResponse](#LnurlPayInfoResponse) + +- HandleLnurlPay + - auth type: __Guest__ + - http method: __get__ + - http route: __/api/guest/lnurl_pay/handle__ + - the request url __query__ can take the following string items: + - k1 + - amount + - This methods has an __empty__ __request__ body + - output: [HandleLnurlPayResponse](#HandleLnurlPayResponse) + +- GetLNURLChannelLink + - auth type: __User__ + - http method: __post__ + - http route: __/api/user/lnurl_channel/url__ + - This methods has an __empty__ __request__ body + - output: [LnurlLinkResponse](#LnurlLinkResponse) + +# INPUTS AND OUTPUTS + +## Messages +### The content of requests and response from the methods + +### Empty + +### DecodeInvoiceRequest + - __invoice__: _string_ + +### AddUserRequest + - __callbackUrl__: _string_ + - __name__: _string_ + - __secret__: _string_ + +### GetUserOperationsResponse + - __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_ + - __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_ + - __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_ + - __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_ + +### PayAddressResponse + - __txId__: _string_ + +### LnurlWithdrawInfoResponse + - __tag__: _string_ + - __callback__: _string_ + - __k1__: _string_ + - __defaultDescription__: _string_ + - __minWithdrawable__: _number_ + - __maxWithdrawable__: _number_ + - __balanceCheck__: _string_ + - __payLink__: _string_ + +### UserInfo + - __userId__: _string_ + - __balance__: _number_ + +### NewAddressResponse + - __address__: _string_ + +### PayAddressRequest + - __address__: _string_ + - __amoutSats__: _number_ + - __targetConf__: _number_ + +### HandleLnurlPayResponse + - __pr__: _string_ + - __routes__: ARRAY of: _[Empty](#Empty)_ + +### UserOperation + - __paidAtUnix__: _number_ + - __type__: _[UserOperationType](#UserOperationType)_ + - __inbound__: _boolean_ + - __amount__: _number_ + +### DecodeInvoiceResponse + - __amount__: _number_ + +### AddUserResponse + - __userId__: _string_ + - __authToken__: _string_ + +### NewInvoiceResponse + - __invoice__: _string_ + +### PayInvoiceResponse + - __preimage__: _string_ + +### NewAddressRequest + - __addressType__: _[AddressType](#AddressType)_ + +### LnurlLinkResponse + - __lnurl__: _string_ + - __k1__: _string_ + +### LnurlPayInfoResponse + - __tag__: _string_ + - __callback__: _string_ + - __maxSendable__: _number_ + - __minSendable__: _number_ + - __metadata__: _string_ + +### GetUserOperationsRequest + - __latestIncomingInvoice__: _number_ + - __latestOutgoingInvoice__: _number_ + - __latestIncomingTx__: _number_ + - __latestOutgoingTx__: _number_ + +### AuthUserResponse + - __userId__: _string_ + - __authToken__: _string_ + +### EncryptionExchangeRequest + - __publicKey__: _string_ + - __deviceId__: _string_ + +### LndGetInfoRequest + - __nodeId__: _number_ + +### LndGetInfoResponse + - __alias__: _string_ + +### PayInvoiceRequest + - __invoice__: _string_ + - __amount__: _number_ + +### OpenChannelRequest + - __destination__: _string_ + - __fundingAmount__: _number_ + - __pushAmount__: _number_ + - __closeAddress__: _string_ + +### OpenChannelResponse + - __channelId__: _string_ + +### AuthUserRequest + - __name__: _string_ + - __secret__: _string_ + +### UserOperations + - __fromIndex__: _number_ + - __toIndex__: _number_ + - __operations__: ARRAY of: _[UserOperation](#UserOperation)_ + +### NewInvoiceRequest + - __amountSats__: _number_ + - __memo__: _string_ +## Enums +### The enumerators used in the messages + +### AddressType + - __WITNESS_PUBKEY_HASH__ + - __NESTED_PUBKEY_HASH__ + - __TAPROOT_PUBKEY__ + +### UserOperationType + - __INCOMING_TX__ + - __OUTGOING_TX__ + - __INCOMING_INVOICE__ + - __OUTGOING_INVOICE__ diff --git a/proto/autogenerated/debug.txt b/proto/autogenerated/debug.txt index a3789813..562b71fe 100644 --- a/proto/autogenerated/debug.txt +++ b/proto/autogenerated/debug.txt @@ -1,5 +1,5 @@ -([]*main.Method) (len=18 cap=32) { - (*main.Method)(0xc0002c2730)({ +([]*main.Method) (len=19 cap=32) { + (*main.Method)(0xc0002922d0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -9,8 +9,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc0002ced20)({ - authType: (*main.supportedAuth)(0xc00045efc0)({ + opts: (*main.methodOptions)(0xc000036300)({ + authType: (*main.supportedAuth)(0xc000030270)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -26,7 +26,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2780)({ + (*main.Method)(0xc000292500)({ in: (main.MethodMessage) { name: (string) (len=25) "EncryptionExchangeRequest", hasZeroFields: (bool) false @@ -36,8 +36,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc0002ceea0)({ - authType: (*main.supportedAuth)(0xc00045f080)({ + opts: (*main.methodOptions)(0xc000036480)({ + authType: (*main.supportedAuth)(0xc000030330)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -53,7 +53,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c27d0)({ + (*main.Method)(0xc000292550)({ in: (main.MethodMessage) { name: (string) (len=17) "LndGetInfoRequest", hasZeroFields: (bool) false @@ -63,8 +63,8 @@ name: (string) (len=18) "LndGetInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cf020)({ - authType: (*main.supportedAuth)(0xc00045f110)({ + opts: (*main.methodOptions)(0xc000036600)({ + authType: (*main.supportedAuth)(0xc0000303c0)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", encrypted: (bool) true, @@ -81,7 +81,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2820)({ + (*main.Method)(0xc000292690)({ in: (main.MethodMessage) { name: (string) (len=14) "AddUserRequest", hasZeroFields: (bool) false @@ -91,8 +91,8 @@ name: (string) (len=15) "AddUserResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cf1a0)({ - authType: (*main.supportedAuth)(0xc00045f1a0)({ + opts: (*main.methodOptions)(0xc000036780)({ + authType: (*main.supportedAuth)(0xc000030450)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -108,7 +108,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2870)({ + (*main.Method)(0xc0002926e0)({ in: (main.MethodMessage) { name: (string) (len=15) "AuthUserRequest", hasZeroFields: (bool) false @@ -118,8 +118,8 @@ name: (string) (len=16) "AuthUserResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cf320)({ - authType: (*main.supportedAuth)(0xc00045f230)({ + opts: (*main.methodOptions)(0xc000036900)({ + authType: (*main.supportedAuth)(0xc0000304e0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -135,7 +135,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c28c0)({ + (*main.Method)(0xc000292730)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -145,8 +145,8 @@ name: (string) (len=8) "UserInfo", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cf500)({ - authType: (*main.supportedAuth)(0xc00045f2f0)({ + opts: (*main.methodOptions)(0xc000036ae0)({ + authType: (*main.supportedAuth)(0xc0000305a0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -163,7 +163,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2910)({ + (*main.Method)(0xc000292780)({ in: (main.MethodMessage) { name: (string) (len=24) "GetUserOperationsRequest", hasZeroFields: (bool) false @@ -173,8 +173,8 @@ name: (string) (len=25) "GetUserOperationsResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cf6e0)({ - authType: (*main.supportedAuth)(0xc00045f380)({ + opts: (*main.methodOptions)(0xc000036cc0)({ + authType: (*main.supportedAuth)(0xc000030630)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -191,7 +191,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c29b0)({ + (*main.Method)(0xc000292820)({ in: (main.MethodMessage) { name: (string) (len=17) "NewAddressRequest", hasZeroFields: (bool) false @@ -201,8 +201,8 @@ name: (string) (len=18) "NewAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cf8c0)({ - authType: (*main.supportedAuth)(0xc00045f410)({ + opts: (*main.methodOptions)(0xc000036ea0)({ + authType: (*main.supportedAuth)(0xc0000306c0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -219,7 +219,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2a50)({ + (*main.Method)(0xc0002928c0)({ in: (main.MethodMessage) { name: (string) (len=17) "PayAddressRequest", hasZeroFields: (bool) false @@ -229,8 +229,8 @@ name: (string) (len=18) "PayAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cfaa0)({ - authType: (*main.supportedAuth)(0xc00045f4a0)({ + opts: (*main.methodOptions)(0xc000037080)({ + authType: (*main.supportedAuth)(0xc000030750)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -247,7 +247,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2af0)({ + (*main.Method)(0xc000292960)({ in: (main.MethodMessage) { name: (string) (len=17) "NewInvoiceRequest", hasZeroFields: (bool) false @@ -257,8 +257,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cfc80)({ - authType: (*main.supportedAuth)(0xc00045f530)({ + opts: (*main.methodOptions)(0xc000037260)({ + authType: (*main.supportedAuth)(0xc0000307e0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -275,7 +275,35 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2b90)({ + (*main.Method)(0xc000292a00)({ + in: (main.MethodMessage) { + name: (string) (len=20) "DecodeInvoiceRequest", + hasZeroFields: (bool) false + }, + name: (string) (len=13) "DecodeInvoice", + out: (main.MethodMessage) { + name: (string) (len=21) "DecodeInvoiceResponse", + hasZeroFields: (bool) false + }, + opts: (*main.methodOptions)(0xc000037440)({ + authType: (*main.supportedAuth)(0xc000030870)({ + id: (string) (len=4) "user", + name: (string) (len=4) "User", + encrypted: (bool) false, + context: (map[string]string) (len=1) { + (string) (len=7) "user_id": (string) (len=6) "string" + } + }), + method: (string) (len=4) "post", + route: (main.decodedRoute) { + route: (string) (len=24) "/api/user/invoice/decode", + params: ([]string) + }, + query: ([]string) , + nostr: (bool) true + }) + }), + (*main.Method)(0xc000292aa0)({ in: (main.MethodMessage) { name: (string) (len=17) "PayInvoiceRequest", hasZeroFields: (bool) false @@ -285,8 +313,8 @@ name: (string) (len=18) "PayInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cfe60)({ - authType: (*main.supportedAuth)(0xc00045f5c0)({ + opts: (*main.methodOptions)(0xc000037620)({ + authType: (*main.supportedAuth)(0xc000030900)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -303,7 +331,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2c30)({ + (*main.Method)(0xc000292b40)({ in: (main.MethodMessage) { name: (string) (len=18) "OpenChannelRequest", hasZeroFields: (bool) false @@ -313,8 +341,8 @@ name: (string) (len=19) "OpenChannelResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000464060)({ - authType: (*main.supportedAuth)(0xc00045f650)({ + opts: (*main.methodOptions)(0xc000037800)({ + authType: (*main.supportedAuth)(0xc000030990)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -331,7 +359,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2cd0)({ + (*main.Method)(0xc000292be0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -341,8 +369,8 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000464240)({ - authType: (*main.supportedAuth)(0xc00045f6e0)({ + opts: (*main.methodOptions)(0xc0000379e0)({ + authType: (*main.supportedAuth)(0xc000030a20)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -359,7 +387,7 @@ nostr: (bool) true }) }), - (*main.Method)(0xc0002c2d70)({ + (*main.Method)(0xc000292c80)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -369,8 +397,8 @@ name: (string) (len=25) "LnurlWithdrawInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0004645a0)({ - authType: (*main.supportedAuth)(0xc00045f830)({ + opts: (*main.methodOptions)(0xc000037d40)({ + authType: (*main.supportedAuth)(0xc000030b70)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -388,7 +416,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2e10)({ + (*main.Method)(0xc000292d20)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -398,8 +426,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc000464900)({ - authType: (*main.supportedAuth)(0xc00045f980)({ + opts: (*main.methodOptions)(0xc00029eae0)({ + authType: (*main.supportedAuth)(0xc000030cc0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -418,7 +446,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2eb0)({ + (*main.Method)(0xc000292dc0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -428,8 +456,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000464c60)({ - authType: (*main.supportedAuth)(0xc00045faa0)({ + opts: (*main.methodOptions)(0xc00029ee40)({ + authType: (*main.supportedAuth)(0xc000030de0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -447,7 +475,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2f50)({ + (*main.Method)(0xc000292e60)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -457,8 +485,8 @@ name: (string) (len=22) "HandleLnurlPayResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000464fc0)({ - authType: (*main.supportedAuth)(0xc00045fbf0)({ + opts: (*main.methodOptions)(0xc00029f1a0)({ + authType: (*main.supportedAuth)(0xc000030f30)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -477,7 +505,7 @@ nostr: (bool) false }) }), - (*main.Method)(0xc0002c2ff0)({ + (*main.Method)(0xc000292f00)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -487,8 +515,8 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0004651a0)({ - authType: (*main.supportedAuth)(0xc00045fc80)({ + opts: (*main.methodOptions)(0xc00029f380)({ + authType: (*main.supportedAuth)(0xc000030fc0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -508,7 +536,7 @@ } ([]*main.Enum) (len=2 cap=2) { - (*main.Enum)(0xc00045e840)({ + (*main.Enum)(0xc00051cc90)({ name: (string) (len=11) "AddressType", values: ([]main.EnumValue) (len=3 cap=4) { (main.EnumValue) { @@ -525,7 +553,7 @@ } } }), - (*main.Enum)(0xc00045e8a0)({ + (*main.Enum)(0xc00051ccf0)({ name: (string) (len=17) "UserOperationType", values: ([]main.EnumValue) (len=4 cap=4) { (main.EnumValue) { @@ -548,13 +576,18 @@ }) } -(map[string]*main.Message) (len=27) { - (string) (len=18) "NewAddressResponse": (*main.Message)(0xc000247400)({ - fullName: (string) (len=18) "NewAddressResponse", - name: (string) (len=18) "NewAddressResponse", +(map[string]*main.Message) (len=29) { + (string) (len=5) "Empty": (*main.Message)(0xc000518000)({ + fullName: (string) (len=5) "Empty", + name: (string) (len=5) "Empty", + fields: ([]*main.Field) + }), + (string) (len=20) "DecodeInvoiceRequest": (*main.Message)(0xc000518280)({ + fullName: (string) (len=20) "DecodeInvoiceRequest", + name: (string) (len=20) "DecodeInvoiceRequest", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffce0)({ - name: (string) (len=7) "address", + (*main.Field)(0xc00051c270)({ + name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -564,12 +597,12 @@ }) } }), - (string) (len=17) "LnurlLinkResponse": (*main.Message)(0xc000247640)({ - fullName: (string) (len=17) "LnurlLinkResponse", - name: (string) (len=17) "LnurlLinkResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00045e000)({ - name: (string) (len=5) "lnurl", + (string) (len=14) "AddUserRequest": (*main.Message)(0xc000518580)({ + fullName: (string) (len=14) "AddUserRequest", + name: (string) (len=14) "AddUserRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc00051c780)({ + name: (string) (len=11) "callbackUrl", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -577,88 +610,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e030)({ - 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=17) "NewInvoiceRequest": (*main.Message)(0xc0002474c0)({ - fullName: (string) (len=17) "NewInvoiceRequest", - name: (string) (len=17) "NewInvoiceRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003ffdd0)({ - 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)(0xc0003ffe00)({ - 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=24) "GetUserOperationsRequest": (*main.Message)(0xc000247900)({ - fullName: (string) (len=24) "GetUserOperationsRequest", - name: (string) (len=24) "GetUserOperationsRequest", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc00045e540)({ - 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)(0xc00045e570)({ - 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)(0xc00045e5a0)({ - 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)(0xc00045e5d0)({ - 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 - }) - } - }), - (string) (len=15) "AuthUserRequest": (*main.Message)(0xc000247840)({ - fullName: (string) (len=15) "AuthUserRequest", - name: (string) (len=15) "AuthUserRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00045e420)({ + (*main.Field)(0xc00051c7b0)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -667,7 +619,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e450)({ + (*main.Field)(0xc00051c7e0)({ name: (string) (len=6) "secret", kind: (string) (len=6) "string", isMap: (bool) false, @@ -678,110 +630,11 @@ }) } }), - (string) (len=16) "AuthUserResponse": (*main.Message)(0xc000247880)({ - fullName: (string) (len=16) "AuthUserResponse", - name: (string) (len=16) "AuthUserResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00045e480)({ - name: (string) (len=6) "userId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00045e4b0)({ - name: (string) (len=9) "authToken", - 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)(0xc000247740)({ - fullName: (string) (len=20) "LnurlPayInfoResponse", - name: (string) (len=20) "LnurlPayInfoResponse", - fields: ([]*main.Field) (len=5 cap=8) { - (*main.Field)(0xc00045e1e0)({ - 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)(0xc00045e210)({ - 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)(0xc00045e240)({ - 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)(0xc00045e270)({ - 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)(0xc00045e2a0)({ - 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 - }) - } - }), - (string) (len=17) "PayInvoiceRequest": (*main.Message)(0xc000247540)({ - fullName: (string) (len=17) "PayInvoiceRequest", - name: (string) (len=17) "PayInvoiceRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003ffe60)({ - 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)(0xc0003ffe90)({ - 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)(0xc0002479c0)({ + (string) (len=25) "GetUserOperationsResponse": (*main.Message)(0xc000518780)({ fullName: (string) (len=25) "GetUserOperationsResponse", name: (string) (len=25) "GetUserOperationsResponse", fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc00045e750)({ + (*main.Field)(0xc00051cba0)({ name: (string) (len=31) "latestOutgoingInvoiceOperations", kind: (string) (len=14) "UserOperations", isMap: (bool) false, @@ -790,7 +643,7 @@ isMessage: (bool) true, isOptional: (bool) false }), - (*main.Field)(0xc00045e780)({ + (*main.Field)(0xc00051cbd0)({ name: (string) (len=31) "latestIncomingInvoiceOperations", kind: (string) (len=14) "UserOperations", isMap: (bool) false, @@ -799,7 +652,7 @@ isMessage: (bool) true, isOptional: (bool) false }), - (*main.Field)(0xc00045e7b0)({ + (*main.Field)(0xc00051cc00)({ name: (string) (len=26) "latestOutgoingTxOperations", kind: (string) (len=14) "UserOperations", isMap: (bool) false, @@ -808,7 +661,7 @@ isMessage: (bool) true, isOptional: (bool) false }), - (*main.Field)(0xc00045e7e0)({ + (*main.Field)(0xc00051cc30)({ name: (string) (len=26) "latestIncomingTxOperations", kind: (string) (len=14) "UserOperations", isMap: (bool) false, @@ -819,196 +672,11 @@ }) } }), - (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc000247380)({ - fullName: (string) (len=18) "LndGetInfoResponse", - name: (string) (len=18) "LndGetInfoResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffc80)({ - 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=17) "PayAddressRequest": (*main.Message)(0xc000247440)({ - fullName: (string) (len=17) "PayAddressRequest", - name: (string) (len=17) "PayAddressRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0003ffd10)({ - 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)(0xc0003ffd40)({ - 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)(0xc0003ffd70)({ - name: (string) (len=10) "targetConf", - 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)(0xc000247580)({ - fullName: (string) (len=18) "PayInvoiceResponse", - name: (string) (len=18) "PayInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffec0)({ - 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 - }) - } - }), - (string) (len=19) "OpenChannelResponse": (*main.Message)(0xc000247600)({ - fullName: (string) (len=19) "OpenChannelResponse", - name: (string) (len=19) "OpenChannelResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003fffb0)({ - 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=5) "Empty": (*main.Message)(0xc0002472c0)({ - fullName: (string) (len=5) "Empty", - name: (string) (len=5) "Empty", - fields: ([]*main.Field) - }), - (string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc000247500)({ - fullName: (string) (len=18) "NewInvoiceResponse", - name: (string) (len=18) "NewInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffe30)({ - 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=15) "AddUserResponse": (*main.Message)(0xc000247800)({ - fullName: (string) (len=15) "AddUserResponse", - name: (string) (len=15) "AddUserResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00045e3c0)({ - name: (string) (len=6) "userId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00045e3f0)({ - name: (string) (len=9) "authToken", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=22) "HandleLnurlPayResponse": (*main.Message)(0xc000247780)({ - fullName: (string) (len=22) "HandleLnurlPayResponse", - name: (string) (len=22) "HandleLnurlPayResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00045e2d0)({ - name: (string) (len=2) "pr", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00045e300)({ - name: (string) (len=6) "routes", - kind: (string) (len=5) "Empty", - isMap: (bool) false, - isArray: (bool) true, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }) - } - }), - (string) (len=8) "UserInfo": (*main.Message)(0xc0002478c0)({ - fullName: (string) (len=8) "UserInfo", - name: (string) (len=8) "UserInfo", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc00045e4e0)({ - name: (string) (len=6) "userId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00045e510)({ - 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=17) "NewAddressRequest": (*main.Message)(0xc0002473c0)({ - fullName: (string) (len=17) "NewAddressRequest", - name: (string) (len=17) "NewAddressRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffcb0)({ - 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=18) "PayAddressResponse": (*main.Message)(0xc000247480)({ + (string) (len=18) "PayAddressResponse": (*main.Message)(0xc0005181c0)({ fullName: (string) (len=18) "PayAddressResponse", name: (string) (len=18) "PayAddressResponse", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffda0)({ + (*main.Field)(0xc00051c1b0)({ name: (string) (len=4) "txId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1019,12 +687,12 @@ }) } }), - (string) (len=18) "OpenChannelRequest": (*main.Message)(0xc0002475c0)({ - fullName: (string) (len=18) "OpenChannelRequest", - name: (string) (len=18) "OpenChannelRequest", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc0003ffef0)({ - name: (string) (len=11) "destination", + (string) (len=25) "LnurlWithdrawInfoResponse": (*main.Message)(0xc000518480)({ + fullName: (string) (len=25) "LnurlWithdrawInfoResponse", + name: (string) (len=25) "LnurlWithdrawInfoResponse", + fields: ([]*main.Field) (len=8 cap=8) { + (*main.Field)(0xc00051c4b0)({ + name: (string) (len=3) "tag", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1032,8 +700,35 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003fff20)({ - name: (string) (len=13) "fundingAmount", + (*main.Field)(0xc00051c4e0)({ + 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)(0xc00051c510)({ + 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)(0xc00051c540)({ + 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)(0xc00051c570)({ + name: (string) (len=15) "minWithdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -1041,8 +736,8 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003fff50)({ - name: (string) (len=10) "pushAmount", + (*main.Field)(0xc00051c5a0)({ + name: (string) (len=15) "maxWithdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -1050,8 +745,17 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003fff80)({ - name: (string) (len=12) "closeAddress", + (*main.Field)(0xc00051c5d0)({ + 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)(0xc00051c600)({ + name: (string) (len=7) "payLink", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1061,12 +765,60 @@ }) } }), - (string) (len=14) "UserOperations": (*main.Message)(0xc000247980)({ - fullName: (string) (len=14) "UserOperations", - name: (string) (len=14) "UserOperations", + (string) (len=8) "UserInfo": (*main.Message)(0xc000518680)({ + fullName: (string) (len=8) "UserInfo", + name: (string) (len=8) "UserInfo", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c930)({ + name: (string) (len=6) "userId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00051c960)({ + 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) "NewAddressResponse": (*main.Message)(0xc000518140)({ + fullName: (string) (len=18) "NewAddressResponse", + name: (string) (len=18) "NewAddressResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c0f0)({ + 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) "PayAddressRequest": (*main.Message)(0xc000518180)({ + fullName: (string) (len=17) "PayAddressRequest", + name: (string) (len=17) "PayAddressRequest", fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00045e6c0)({ - name: (string) (len=9) "fromIndex", + (*main.Field)(0xc00051c120)({ + 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)(0xc00051c150)({ + name: (string) (len=9) "amoutSats", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -1074,18 +826,33 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e6f0)({ - name: (string) (len=7) "toIndex", + (*main.Field)(0xc00051c180)({ + name: (string) (len=10) "targetConf", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, isMessage: (bool) false, isOptional: (bool) false + }) + } + }), + (string) (len=22) "HandleLnurlPayResponse": (*main.Message)(0xc000518540)({ + fullName: (string) (len=22) "HandleLnurlPayResponse", + name: (string) (len=22) "HandleLnurlPayResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c720)({ + name: (string) (len=2) "pr", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false }), - (*main.Field)(0xc00045e720)({ - name: (string) (len=10) "operations", - kind: (string) (len=13) "UserOperation", + (*main.Field)(0xc00051c750)({ + name: (string) (len=6) "routes", + kind: (string) (len=5) "Empty", isMap: (bool) false, isArray: (bool) true, isEnum: (bool) false, @@ -1094,44 +861,11 @@ }) } }), - (string) (len=14) "AddUserRequest": (*main.Message)(0xc0002477c0)({ - fullName: (string) (len=14) "AddUserRequest", - name: (string) (len=14) "AddUserRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc00045e330)({ - name: (string) (len=11) "callbackUrl", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc00045e360)({ - 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)(0xc00045e390)({ - name: (string) (len=6) "secret", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=13) "UserOperation": (*main.Message)(0xc000247940)({ + (string) (len=13) "UserOperation": (*main.Message)(0xc000518700)({ fullName: (string) (len=13) "UserOperation", name: (string) (len=13) "UserOperation", fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc00045e600)({ + (*main.Field)(0xc00051ca50)({ name: (string) (len=10) "paidAtUnix", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1140,7 +874,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e630)({ + (*main.Field)(0xc00051ca80)({ name: (string) (len=4) "type", kind: (string) (len=17) "UserOperationType", isMap: (bool) false, @@ -1149,7 +883,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e660)({ + (*main.Field)(0xc00051cab0)({ name: (string) (len=7) "inbound", kind: (string) (len=4) "bool", isMap: (bool) false, @@ -1158,7 +892,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e690)({ + (*main.Field)(0xc00051cae0)({ name: (string) (len=6) "amount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1169,11 +903,260 @@ }) } }), - (string) (len=25) "EncryptionExchangeRequest": (*main.Message)(0xc000247300)({ + (string) (len=21) "DecodeInvoiceResponse": (*main.Message)(0xc0005182c0)({ + fullName: (string) (len=21) "DecodeInvoiceResponse", + name: (string) (len=21) "DecodeInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c2a0)({ + 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=15) "AddUserResponse": (*main.Message)(0xc0005185c0)({ + fullName: (string) (len=15) "AddUserResponse", + name: (string) (len=15) "AddUserResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c810)({ + name: (string) (len=6) "userId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00051c840)({ + name: (string) (len=9) "authToken", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc000518240)({ + fullName: (string) (len=18) "NewInvoiceResponse", + name: (string) (len=18) "NewInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c240)({ + 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=18) "PayInvoiceResponse": (*main.Message)(0xc000518340)({ + fullName: (string) (len=18) "PayInvoiceResponse", + name: (string) (len=18) "PayInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c330)({ + 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 + }) + } + }), + (string) (len=17) "NewAddressRequest": (*main.Message)(0xc000518100)({ + fullName: (string) (len=17) "NewAddressRequest", + name: (string) (len=17) "NewAddressRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c0c0)({ + 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=17) "LnurlLinkResponse": (*main.Message)(0xc000518400)({ + fullName: (string) (len=17) "LnurlLinkResponse", + name: (string) (len=17) "LnurlLinkResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c450)({ + 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)(0xc00051c480)({ + 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=20) "LnurlPayInfoResponse": (*main.Message)(0xc000518500)({ + fullName: (string) (len=20) "LnurlPayInfoResponse", + name: (string) (len=20) "LnurlPayInfoResponse", + fields: ([]*main.Field) (len=5 cap=8) { + (*main.Field)(0xc00051c630)({ + 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)(0xc00051c660)({ + 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)(0xc00051c690)({ + 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)(0xc00051c6c0)({ + 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)(0xc00051c6f0)({ + 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 + }) + } + }), + (string) (len=24) "GetUserOperationsRequest": (*main.Message)(0xc0005186c0)({ + fullName: (string) (len=24) "GetUserOperationsRequest", + name: (string) (len=24) "GetUserOperationsRequest", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc00051c990)({ + 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)(0xc00051c9c0)({ + 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)(0xc00051c9f0)({ + 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)(0xc00051ca20)({ + 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 + }) + } + }), + (string) (len=15) "AuthUserRequest": (*main.Message)(0xc000518600)({ + fullName: (string) (len=15) "AuthUserRequest", + name: (string) (len=15) "AuthUserRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c870)({ + 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)(0xc00051c8a0)({ + name: (string) (len=6) "secret", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=16) "AuthUserResponse": (*main.Message)(0xc000518640)({ + fullName: (string) (len=16) "AuthUserResponse", + name: (string) (len=16) "AuthUserResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c8d0)({ + name: (string) (len=6) "userId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00051c900)({ + name: (string) (len=9) "authToken", + 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)(0xc000518040)({ fullName: (string) (len=25) "EncryptionExchangeRequest", name: (string) (len=25) "EncryptionExchangeRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003ffbf0)({ + (*main.Field)(0xc00051c000)({ name: (string) (len=9) "publicKey", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1182,7 +1165,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003ffc20)({ + (*main.Field)(0xc00051c030)({ name: (string) (len=8) "deviceId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1193,11 +1176,11 @@ }) } }), - (string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc000247340)({ + (string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc000518080)({ fullName: (string) (len=17) "LndGetInfoRequest", name: (string) (len=17) "LndGetInfoRequest", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003ffc50)({ + (*main.Field)(0xc00051c060)({ name: (string) (len=6) "nodeId", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1208,12 +1191,27 @@ }) } }), - (string) (len=25) "LnurlWithdrawInfoResponse": (*main.Message)(0xc0002476c0)({ - fullName: (string) (len=25) "LnurlWithdrawInfoResponse", - name: (string) (len=25) "LnurlWithdrawInfoResponse", - fields: ([]*main.Field) (len=8 cap=8) { - (*main.Field)(0xc00045e060)({ - name: (string) (len=3) "tag", + (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc0005180c0)({ + fullName: (string) (len=18) "LndGetInfoResponse", + name: (string) (len=18) "LndGetInfoResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c090)({ + 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=17) "PayInvoiceRequest": (*main.Message)(0xc000518300)({ + fullName: (string) (len=17) "PayInvoiceRequest", + name: (string) (len=17) "PayInvoiceRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c2d0)({ + name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1221,8 +1219,23 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e090)({ - name: (string) (len=8) "callback", + (*main.Field)(0xc00051c300)({ + 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)(0xc000518380)({ + fullName: (string) (len=18) "OpenChannelRequest", + name: (string) (len=18) "OpenChannelRequest", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc00051c360)({ + name: (string) (len=11) "destination", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1230,26 +1243,8 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e0c0)({ - 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)(0xc00045e0f0)({ - 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)(0xc00045e120)({ - name: (string) (len=15) "minWithdrawable", + (*main.Field)(0xc00051c390)({ + name: (string) (len=13) "fundingAmount", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -1257,8 +1252,8 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e150)({ - name: (string) (len=15) "maxWithdrawable", + (*main.Field)(0xc00051c3c0)({ + name: (string) (len=10) "pushAmount", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, @@ -1266,17 +1261,80 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc00045e180)({ - name: (string) (len=12) "balanceCheck", + (*main.Field)(0xc00051c3f0)({ + 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=19) "OpenChannelResponse": (*main.Message)(0xc0005183c0)({ + fullName: (string) (len=19) "OpenChannelResponse", + name: (string) (len=19) "OpenChannelResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00051c420)({ + 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=14) "UserOperations": (*main.Message)(0xc000518740)({ + fullName: (string) (len=14) "UserOperations", + name: (string) (len=14) "UserOperations", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc00051cb10)({ + name: (string) (len=9) "fromIndex", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false }), - (*main.Field)(0xc00045e1b0)({ - name: (string) (len=7) "payLink", + (*main.Field)(0xc00051cb40)({ + name: (string) (len=7) "toIndex", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00051cb70)({ + name: (string) (len=10) "operations", + kind: (string) (len=13) "UserOperation", + isMap: (bool) false, + isArray: (bool) true, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "NewInvoiceRequest": (*main.Message)(0xc000518200)({ + fullName: (string) (len=17) "NewInvoiceRequest", + name: (string) (len=17) "NewInvoiceRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00051c1e0)({ + 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)(0xc00051c210)({ + name: (string) (len=4) "memo", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1288,7 +1346,7 @@ }) } -parsing file: structs 27 +parsing file: structs 29 parsing file: methods 2 -> [{guest Guest false map[]} {user User false map[user_id:string]} {admin Admin true map[admin_id:string]}] diff --git a/proto/autogenerated/ts/express_server.ts b/proto/autogenerated/ts/express_server.ts index 75208c4a..50348f29 100644 --- a/proto/autogenerated/ts/express_server.ts +++ b/proto/autogenerated/ts/express_server.ts @@ -161,6 +161,20 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); 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) => { + try { + if (!methods.DecodeInvoice) throw new Error('method: DecodeInvoice is not implemented') + const authContext = await opts.UserAuthGuard(req.headers['authorization']) + const request = req.body + const error = Types.DecodeInvoiceRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.DecodeInvoice({ ...authContext, ...query, ...params }, request) + res.json({status: 'OK', ...response}) + } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); 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) => { try { diff --git a/proto/autogenerated/ts/http_client.ts b/proto/autogenerated/ts/http_client.ts index 384735e9..b170d7f5 100644 --- a/proto/autogenerated/ts/http_client.ts +++ b/proto/autogenerated/ts/http_client.ts @@ -148,6 +148,20 @@ export default (params: ClientParams) => ({ } return { status: 'ERROR', reason: 'invalid response' } }, + DecodeInvoice: async (request: Types.DecodeInvoiceRequest): Promise => { + const auth = await params.retrieveUserAuth() + if (auth === null) throw new Error('retrieveUserAuth() returned null') + let finalRoute = '/api/user/invoice/decode' + const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } }) + if (data.status === 'ERROR' && typeof data.reason === 'string') return data + if (data.status === 'OK') { + const result = data + if(!params.checkResult) return { status: 'OK', ...result } + const error = Types.DecodeInvoiceResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, PayInvoice: async (request: Types.PayInvoiceRequest): Promise => { const auth = await params.retrieveUserAuth() if (auth === null) throw new Error('retrieveUserAuth() returned null') diff --git a/proto/autogenerated/ts/nostr_client.ts b/proto/autogenerated/ts/nostr_client.ts index da8cb18e..1d31d7d1 100644 --- a/proto/autogenerated/ts/nostr_client.ts +++ b/proto/autogenerated/ts/nostr_client.ts @@ -83,6 +83,21 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ } return { status: 'ERROR', reason: 'invalid response' } }, + DecodeInvoice: async (request: Types.DecodeInvoiceRequest): Promise => { + const auth = await params.retrieveNostrUserAuth() + if (auth === null) throw new Error('retrieveNostrUserAuth() returned null') + const nostrRequest: NostrRequest = {} + nostrRequest.body = request + const data = await send(params.pubDestination, {rpcName:'DecodeInvoice',authIdentifier:auth, ...nostrRequest }) + if (data.status === 'ERROR' && typeof data.reason === 'string') return data + if (data.status === 'OK') { + const result = data + if(!params.checkResult) return { status: 'OK', ...result } + const error = Types.DecodeInvoiceResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, PayInvoice: async (request: Types.PayInvoiceRequest): Promise => { const auth = await params.retrieveNostrUserAuth() if (auth === null) throw new Error('retrieveNostrUserAuth() returned null') diff --git a/proto/autogenerated/ts/nostr_transport.ts b/proto/autogenerated/ts/nostr_transport.ts index cebe3e36..24f74f1c 100644 --- a/proto/autogenerated/ts/nostr_transport.ts +++ b/proto/autogenerated/ts/nostr_transport.ts @@ -83,6 +83,19 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => { res({status: 'OK', ...response}) }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); 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.authIdentifier) + const request = req.body + const error = Types.DecodeInvoiceRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.DecodeInvoice({ ...authContext, ...query, ...params }, request) + res({status: 'OK', ...response}) + }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + break case 'PayInvoice': try { if (!methods.PayInvoice) throw new Error('method: PayInvoice is not implemented') diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index c0ba7742..c86becb2 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -60,6 +60,11 @@ export type NewInvoice_Query = { export type NewInvoice_RouteParams = { } export type NewInvoice_Context = NewInvoice_Query & NewInvoice_RouteParams & UserContext +export type DecodeInvoice_Query = { +} +export type DecodeInvoice_RouteParams = { +} +export type DecodeInvoice_Context = DecodeInvoice_Query & DecodeInvoice_RouteParams & UserContext export type PayInvoice_Query = { } export type PayInvoice_RouteParams = { @@ -117,6 +122,7 @@ export type ServerMethods = { NewAddress?: (ctx: NewAddress_Context, req: NewAddressRequest) => Promise PayAddress?: (ctx: PayAddress_Context, req: PayAddressRequest) => Promise NewInvoice?: (ctx: NewInvoice_Context, req: NewInvoiceRequest) => Promise + DecodeInvoice?: (ctx: DecodeInvoice_Context, req: DecodeInvoiceRequest) => Promise PayInvoice?: (ctx: PayInvoice_Context, req: PayInvoiceRequest) => Promise OpenChannel?: (ctx: OpenChannel_Context, req: OpenChannelRequest) => Promise GetLnurlWithdrawLink?: (ctx: GetLnurlWithdrawLink_Context) => Promise @@ -151,20 +157,20 @@ export type OptionsBaseMessage = { allOptionalsAreSet?: true } -export type NewAddressResponse = { - address: string +export type NewAddressRequest = { + addressType: AddressType } -export const NewAddressResponseOptionalFields: [] = [] -export type NewAddressResponseOptions = OptionsBaseMessage & { +export const NewAddressRequestOptionalFields: [] = [] +export type NewAddressRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - address_CustomCheck?: (v: string) => boolean + addressType_CustomCheck?: (v: AddressType) => boolean } -export const NewAddressResponseValidate = (o?: NewAddressResponse, opts: NewAddressResponseOptions = {}, path: string = 'NewAddressResponse::root.'): Error | null => { +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 (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 (!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 } @@ -192,62 +198,6 @@ export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLink return null } -export type NewInvoiceRequest = { - amountSats: number - memo: string -} -export const NewInvoiceRequestOptionalFields: [] = [] -export type NewInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - amountSats_CustomCheck?: (v: number) => boolean - memo_CustomCheck?: (v: string) => boolean -} -export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoiceRequestOptions = {}, path: string = 'NewInvoiceRequest::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.amountSats !== 'number') return new Error(`${path}.amountSats: is not a number`) - if (opts.amountSats_CustomCheck && !opts.amountSats_CustomCheck(o.amountSats)) return new Error(`${path}.amountSats: custom check failed`) - - if (typeof o.memo !== 'string') return new Error(`${path}.memo: is not a string`) - if (opts.memo_CustomCheck && !opts.memo_CustomCheck(o.memo)) return new Error(`${path}.memo: custom check failed`) - - return null -} - -export type GetUserOperationsRequest = { - latestIncomingInvoice: number - latestOutgoingInvoice: number - latestIncomingTx: number - latestOutgoingTx: 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 -} -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`) - - return null -} - export type LnurlPayInfoResponse = { tag: string callback: string @@ -286,6 +236,39 @@ export const LnurlPayInfoResponseValidate = (o?: LnurlPayInfoResponse, opts: Lnu return null } +export type GetUserOperationsRequest = { + latestIncomingInvoice: number + latestOutgoingInvoice: number + latestIncomingTx: number + latestOutgoingTx: 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 +} +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`) + + return null +} + export type AuthUserRequest = { name: string secret: string @@ -332,6 +315,65 @@ export const AuthUserResponseValidate = (o?: AuthUserResponse, opts: AuthUserRes return null } +export type EncryptionExchangeRequest = { + publicKey: string + deviceId: string +} +export const EncryptionExchangeRequestOptionalFields: [] = [] +export type EncryptionExchangeRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + publicKey_CustomCheck?: (v: string) => boolean + deviceId_CustomCheck?: (v: string) => boolean +} +export const EncryptionExchangeRequestValidate = (o?: EncryptionExchangeRequest, opts: EncryptionExchangeRequestOptions = {}, path: string = 'EncryptionExchangeRequest::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.publicKey !== 'string') return new Error(`${path}.publicKey: is not a string`) + if (opts.publicKey_CustomCheck && !opts.publicKey_CustomCheck(o.publicKey)) return new Error(`${path}.publicKey: custom check failed`) + + if (typeof o.deviceId !== 'string') return new Error(`${path}.deviceId: is not a string`) + if (opts.deviceId_CustomCheck && !opts.deviceId_CustomCheck(o.deviceId)) return new Error(`${path}.deviceId: custom check failed`) + + return null +} + +export type LndGetInfoRequest = { + nodeId: number +} +export const LndGetInfoRequestOptionalFields: [] = [] +export type LndGetInfoRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + nodeId_CustomCheck?: (v: number) => boolean +} +export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInfoRequestOptions = {}, path: string = 'LndGetInfoRequest::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.nodeId !== 'number') return new Error(`${path}.nodeId: is not a number`) + if (opts.nodeId_CustomCheck && !opts.nodeId_CustomCheck(o.nodeId)) return new Error(`${path}.nodeId: 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 PayInvoiceRequest = { invoice: string amount: number @@ -355,66 +397,35 @@ export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoic return null } -export type LndGetInfoResponse = { - alias: string +export type OpenChannelRequest = { + destination: string + fundingAmount: number + pushAmount: number + closeAddress: string } -export const LndGetInfoResponseOptionalFields: [] = [] -export type LndGetInfoResponseOptions = OptionsBaseMessage & { +export const OpenChannelRequestOptionalFields: [] = [] +export type OpenChannelRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - alias_CustomCheck?: (v: string) => boolean + destination_CustomCheck?: (v: string) => boolean + fundingAmount_CustomCheck?: (v: number) => boolean + pushAmount_CustomCheck?: (v: number) => boolean + closeAddress_CustomCheck?: (v: string) => boolean } -export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetInfoResponseOptions = {}, path: string = 'LndGetInfoResponse::root.'): Error | null => { +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.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`) + 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`) - return null -} + 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`) -export type PayAddressRequest = { - address: string - amoutSats: number - targetConf: number -} -export const PayAddressRequestOptionalFields: [] = [] -export type PayAddressRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - address_CustomCheck?: (v: string) => boolean - amoutSats_CustomCheck?: (v: number) => boolean - targetConf_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.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.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.targetConf !== 'number') return new Error(`${path}.targetConf: is not a number`) - if (opts.targetConf_CustomCheck && !opts.targetConf_CustomCheck(o.targetConf)) return new Error(`${path}.targetConf: custom check failed`) - - return null -} - -export type PayInvoiceResponse = { - preimage: string -} -export const PayInvoiceResponseOptionalFields: [] = [] -export type PayInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - preimage_CustomCheck?: (v: string) => 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.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 } @@ -437,6 +448,121 @@ export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenC return null } +export type UserOperations = { + fromIndex: number + toIndex: number + operations: UserOperation[] +} +export const UserOperationsOptionalFields: [] = [] +export type UserOperationsOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + fromIndex_CustomCheck?: (v: number) => boolean + toIndex_CustomCheck?: (v: number) => boolean + operations_ItemOptions?: UserOperationOptions + operations_CustomCheck?: (v: UserOperation[]) => boolean +} +export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsOptions = {}, path: string = 'UserOperations::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.fromIndex !== 'number') return new Error(`${path}.fromIndex: is not a number`) + if (opts.fromIndex_CustomCheck && !opts.fromIndex_CustomCheck(o.fromIndex)) return new Error(`${path}.fromIndex: custom check failed`) + + if (typeof o.toIndex !== 'number') return new Error(`${path}.toIndex: is not a number`) + if (opts.toIndex_CustomCheck && !opts.toIndex_CustomCheck(o.toIndex)) return new Error(`${path}.toIndex: custom check failed`) + + if (!Array.isArray(o.operations)) return new Error(`${path}.operations: is not an array`) + for (let index = 0; index < o.operations.length; index++) { + const operationsErr = UserOperationValidate(o.operations[index], opts.operations_ItemOptions, `${path}.operations[${index}]`) + if (operationsErr !== null) return operationsErr + } + if (opts.operations_CustomCheck && !opts.operations_CustomCheck(o.operations)) return new Error(`${path}.operations: custom check failed`) + + return null +} + +export type NewInvoiceRequest = { + amountSats: number + memo: string +} +export const NewInvoiceRequestOptionalFields: [] = [] +export type NewInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + amountSats_CustomCheck?: (v: number) => boolean + memo_CustomCheck?: (v: string) => boolean +} +export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoiceRequestOptions = {}, path: string = 'NewInvoiceRequest::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.amountSats !== 'number') return new Error(`${path}.amountSats: is not a number`) + if (opts.amountSats_CustomCheck && !opts.amountSats_CustomCheck(o.amountSats)) return new Error(`${path}.amountSats: custom check failed`) + + if (typeof o.memo !== 'string') return new Error(`${path}.memo: is not a string`) + if (opts.memo_CustomCheck && !opts.memo_CustomCheck(o.memo)) return new Error(`${path}.memo: 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 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 AddUserRequest = { + callbackUrl: string + name: string + secret: string +} +export const AddUserRequestOptionalFields: [] = [] +export type AddUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + callbackUrl_CustomCheck?: (v: string) => boolean + name_CustomCheck?: (v: string) => boolean + secret_CustomCheck?: (v: string) => boolean +} +export const AddUserRequestValidate = (o?: AddUserRequest, opts: AddUserRequestOptions = {}, path: string = 'AddUserRequest::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.callbackUrl !== 'string') return new Error(`${path}.callbackUrl: is not a string`) + if (opts.callbackUrl_CustomCheck && !opts.callbackUrl_CustomCheck(o.callbackUrl)) return new Error(`${path}.callbackUrl: 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.secret !== 'string') return new Error(`${path}.secret: is not a string`) + if (opts.secret_CustomCheck && !opts.secret_CustomCheck(o.secret)) return new Error(`${path}.secret: custom check failed`) + + return null +} + export type GetUserOperationsResponse = { latestOutgoingInvoiceOperations: UserOperations latestIncomingInvoiceOperations: UserOperations @@ -474,101 +600,6 @@ export const GetUserOperationsResponseValidate = (o?: GetUserOperationsResponse, 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 NewInvoiceResponse = { - invoice: string -} -export const NewInvoiceResponseOptionalFields: [] = [] -export type NewInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean -} -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`) - - return null -} - -export type AddUserResponse = { - userId: string - authToken: string -} -export const AddUserResponseOptionalFields: [] = [] -export type AddUserResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - userId_CustomCheck?: (v: string) => boolean - authToken_CustomCheck?: (v: string) => boolean -} -export const AddUserResponseValidate = (o?: AddUserResponse, opts: AddUserResponseOptions = {}, path: string = 'AddUserResponse::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.userId !== 'string') return new Error(`${path}.userId: is not a string`) - if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) - - if (typeof o.authToken !== 'string') return new Error(`${path}.authToken: is not a string`) - if (opts.authToken_CustomCheck && !opts.authToken_CustomCheck(o.authToken)) return new Error(`${path}.authToken: custom check failed`) - - return null -} - -export type UserInfo = { - userId: string - balance: number -} -export const UserInfoOptionalFields: [] = [] -export type UserInfoOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - userId_CustomCheck?: (v: string) => boolean - balance_CustomCheck?: (v: number) => boolean -} -export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path: string = 'UserInfo::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.userId !== 'string') return new Error(`${path}.userId: is not a string`) - if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: 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 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 } @@ -587,141 +618,6 @@ export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddr 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 HandleLnurlPayResponse = { - pr: string - routes: Empty[] -} -export const HandleLnurlPayResponseOptionalFields: [] = [] -export type HandleLnurlPayResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - pr_CustomCheck?: (v: string) => boolean - routes_ItemOptions?: EmptyOptions - routes_CustomCheck?: (v: Empty[]) => boolean -} -export const HandleLnurlPayResponseValidate = (o?: HandleLnurlPayResponse, opts: HandleLnurlPayResponseOptions = {}, path: string = 'HandleLnurlPayResponse::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.pr !== 'string') return new Error(`${path}.pr: is not a string`) - if (opts.pr_CustomCheck && !opts.pr_CustomCheck(o.pr)) return new Error(`${path}.pr: custom check failed`) - - if (!Array.isArray(o.routes)) return new Error(`${path}.routes: is not an array`) - for (let index = 0; index < o.routes.length; index++) { - const routesErr = EmptyValidate(o.routes[index], opts.routes_ItemOptions, `${path}.routes[${index}]`) - if (routesErr !== null) return routesErr - } - if (opts.routes_CustomCheck && !opts.routes_CustomCheck(o.routes)) return new Error(`${path}.routes: custom check failed`) - - return null -} - -export type UserOperations = { - fromIndex: number - toIndex: number - operations: UserOperation[] -} -export const UserOperationsOptionalFields: [] = [] -export type UserOperationsOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - fromIndex_CustomCheck?: (v: number) => boolean - toIndex_CustomCheck?: (v: number) => boolean - operations_ItemOptions?: UserOperationOptions - operations_CustomCheck?: (v: UserOperation[]) => boolean -} -export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsOptions = {}, path: string = 'UserOperations::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.fromIndex !== 'number') return new Error(`${path}.fromIndex: is not a number`) - if (opts.fromIndex_CustomCheck && !opts.fromIndex_CustomCheck(o.fromIndex)) return new Error(`${path}.fromIndex: custom check failed`) - - if (typeof o.toIndex !== 'number') return new Error(`${path}.toIndex: is not a number`) - if (opts.toIndex_CustomCheck && !opts.toIndex_CustomCheck(o.toIndex)) return new Error(`${path}.toIndex: custom check failed`) - - if (!Array.isArray(o.operations)) return new Error(`${path}.operations: is not an array`) - for (let index = 0; index < o.operations.length; index++) { - const operationsErr = UserOperationValidate(o.operations[index], opts.operations_ItemOptions, `${path}.operations[${index}]`) - if (operationsErr !== null) return operationsErr - } - if (opts.operations_CustomCheck && !opts.operations_CustomCheck(o.operations)) return new Error(`${path}.operations: custom check failed`) - - return null -} - -export type EncryptionExchangeRequest = { - publicKey: string - deviceId: string -} -export const EncryptionExchangeRequestOptionalFields: [] = [] -export type EncryptionExchangeRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - publicKey_CustomCheck?: (v: string) => boolean - deviceId_CustomCheck?: (v: string) => boolean -} -export const EncryptionExchangeRequestValidate = (o?: EncryptionExchangeRequest, opts: EncryptionExchangeRequestOptions = {}, path: string = 'EncryptionExchangeRequest::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.publicKey !== 'string') return new Error(`${path}.publicKey: is not a string`) - if (opts.publicKey_CustomCheck && !opts.publicKey_CustomCheck(o.publicKey)) return new Error(`${path}.publicKey: custom check failed`) - - if (typeof o.deviceId !== 'string') return new Error(`${path}.deviceId: is not a string`) - if (opts.deviceId_CustomCheck && !opts.deviceId_CustomCheck(o.deviceId)) return new Error(`${path}.deviceId: custom check failed`) - - return null -} - -export type LndGetInfoRequest = { - nodeId: number -} -export const LndGetInfoRequestOptionalFields: [] = [] -export type LndGetInfoRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - nodeId_CustomCheck?: (v: number) => boolean -} -export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInfoRequestOptions = {}, path: string = 'LndGetInfoRequest::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.nodeId !== 'number') return new Error(`${path}.nodeId: is not a number`) - if (opts.nodeId_CustomCheck && !opts.nodeId_CustomCheck(o.nodeId)) return new Error(`${path}.nodeId: custom check failed`) - - return null -} - export type LnurlWithdrawInfoResponse = { tag: string callback: string @@ -775,30 +671,99 @@ export const LnurlWithdrawInfoResponseValidate = (o?: LnurlWithdrawInfoResponse, return null } -export type AddUserRequest = { - callbackUrl: string - name: string - secret: string +export type UserInfo = { + userId: string + balance: number } -export const AddUserRequestOptionalFields: [] = [] -export type AddUserRequestOptions = OptionsBaseMessage & { +export const UserInfoOptionalFields: [] = [] +export type UserInfoOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - callbackUrl_CustomCheck?: (v: string) => boolean - name_CustomCheck?: (v: string) => boolean - secret_CustomCheck?: (v: string) => boolean + userId_CustomCheck?: (v: string) => boolean + balance_CustomCheck?: (v: number) => boolean } -export const AddUserRequestValidate = (o?: AddUserRequest, opts: AddUserRequestOptions = {}, path: string = 'AddUserRequest::root.'): Error | null => { +export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path: string = 'UserInfo::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.callbackUrl !== 'string') return new Error(`${path}.callbackUrl: is not a string`) - if (opts.callbackUrl_CustomCheck && !opts.callbackUrl_CustomCheck(o.callbackUrl)) return new Error(`${path}.callbackUrl: custom check failed`) + if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) + if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: 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.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.secret !== 'string') return new Error(`${path}.secret: is not a string`) - if (opts.secret_CustomCheck && !opts.secret_CustomCheck(o.secret)) return new Error(`${path}.secret: custom check failed`) + 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 PayAddressRequest = { + address: string + amoutSats: number + targetConf: number +} +export const PayAddressRequestOptionalFields: [] = [] +export type PayAddressRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + address_CustomCheck?: (v: string) => boolean + amoutSats_CustomCheck?: (v: number) => boolean + targetConf_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.targetConf !== 'number') return new Error(`${path}.targetConf: is not a number`) + if (opts.targetConf_CustomCheck && !opts.targetConf_CustomCheck(o.targetConf)) return new Error(`${path}.targetConf: custom check failed`) + + return null +} + +export type HandleLnurlPayResponse = { + pr: string + routes: Empty[] +} +export const HandleLnurlPayResponseOptionalFields: [] = [] +export type HandleLnurlPayResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + pr_CustomCheck?: (v: string) => boolean + routes_ItemOptions?: EmptyOptions + routes_CustomCheck?: (v: Empty[]) => boolean +} +export const HandleLnurlPayResponseValidate = (o?: HandleLnurlPayResponse, opts: HandleLnurlPayResponseOptions = {}, path: string = 'HandleLnurlPayResponse::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.pr !== 'string') return new Error(`${path}.pr: is not a string`) + if (opts.pr_CustomCheck && !opts.pr_CustomCheck(o.pr)) return new Error(`${path}.pr: custom check failed`) + + if (!Array.isArray(o.routes)) return new Error(`${path}.routes: is not an array`) + for (let index = 0; index < o.routes.length; index++) { + const routesErr = EmptyValidate(o.routes[index], opts.routes_ItemOptions, `${path}.routes[${index}]`) + if (routesErr !== null) return routesErr + } + if (opts.routes_CustomCheck && !opts.routes_CustomCheck(o.routes)) return new Error(`${path}.routes: custom check failed`) return null } @@ -836,3 +801,80 @@ export const UserOperationValidate = (o?: UserOperation, opts: UserOperationOpti 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 AddUserResponse = { + userId: string + authToken: string +} +export const AddUserResponseOptionalFields: [] = [] +export type AddUserResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + userId_CustomCheck?: (v: string) => boolean + authToken_CustomCheck?: (v: string) => boolean +} +export const AddUserResponseValidate = (o?: AddUserResponse, opts: AddUserResponseOptions = {}, path: string = 'AddUserResponse::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.userId !== 'string') return new Error(`${path}.userId: is not a string`) + if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) + + if (typeof o.authToken !== 'string') return new Error(`${path}.authToken: is not a string`) + if (opts.authToken_CustomCheck && !opts.authToken_CustomCheck(o.authToken)) return new Error(`${path}.authToken: custom check failed`) + + return null +} + +export type NewInvoiceResponse = { + invoice: string +} +export const NewInvoiceResponseOptionalFields: [] = [] +export type NewInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean +} +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`) + + return null +} + +export type PayInvoiceResponse = { + preimage: string +} +export const PayInvoiceResponseOptionalFields: [] = [] +export type PayInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + preimage_CustomCheck?: (v: string) => 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`) + + return null +} + diff --git a/proto/protoc-gen-pub.exe b/proto/protoc-gen-pub.exe index 6b455447..d2d94ec4 100644 Binary files a/proto/protoc-gen-pub.exe and b/proto/protoc-gen-pub.exe differ diff --git a/proto/service/methods.proto b/proto/service/methods.proto index 542d797c..245a859f 100644 --- a/proto/service/methods.proto +++ b/proto/service/methods.proto @@ -120,6 +120,12 @@ service LightningPub { option (http_route) = "/api/user/invoice/new"; option (nostr) = true; } + rpc DecodeInvoice(structs.DecodeInvoiceRequest) returns (structs.DecodeInvoiceResponse){ + option (auth_type) = "User"; + option (http_method) = "post"; + option (http_route) = "/api/user/invoice/decode"; + option (nostr) = true; + } rpc PayInvoice(structs.PayInvoiceRequest) returns (structs.PayInvoiceResponse){ option (auth_type) = "User"; option (http_method) = "post"; diff --git a/proto/service/structs.proto b/proto/service/structs.proto index 94fa6a8a..f9231990 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -48,7 +48,12 @@ message NewInvoiceRequest{ message NewInvoiceResponse{ string invoice = 1; } - +message DecodeInvoiceRequest{ + string invoice=1; +} +message DecodeInvoiceResponse{ + int64 amount=1; +} message PayInvoiceRequest{ string invoice = 1; int64 amount = 2; diff --git a/src/services/main/index.ts b/src/services/main/index.ts index 7b2f5ee7..29693eb2 100644 --- a/src/services/main/index.ts +++ b/src/services/main/index.ts @@ -141,7 +141,12 @@ export default class { const maxWithinServiceFee = Math.max(0, Math.floor(balance * (1 - this.settings.outgoingInvoiceFee))) return this.lnd.GetMaxWithinLimit(maxWithinServiceFee) } - + async DecodeInvoice(req: Types.DecodeInvoiceRequest): Promise { + const decoded = await this.lnd.DecodeInvoice(req.invoice) + return { + amount: Number(decoded.numSatoshis) + } + } async PayInvoice(userId: string, req: Types.PayInvoiceRequest): Promise { const decoded = await this.lnd.DecodeInvoice(req.invoice) if (decoded.numSatoshis !== 0n && req.amount !== 0) { diff --git a/src/services/serverMethods/index.ts b/src/services/serverMethods/index.ts index d59ec83b..9d7ad69b 100644 --- a/src/services/serverMethods/index.ts +++ b/src/services/serverMethods/index.ts @@ -50,6 +50,9 @@ export default (mainHandler: Main): Types.ServerMethods => { NewInvoice: async (ctx, req) => { return mainHandler.NewInvoice(ctx.user_id, req) }, + DecodeInvoice: async (ctx, req) => { + return mainHandler.DecodeInvoice(req) + }, PayInvoice: async (ctx, req) => { const err = Types.PayInvoiceRequestValidate(req, { invoice_CustomCheck: invoice => invoice !== ''