diff --git a/proto/autogenerated/debug.txt b/proto/autogenerated/debug.txt index 36cc8024..fccff04b 100644 --- a/proto/autogenerated/debug.txt +++ b/proto/autogenerated/debug.txt @@ -10,7 +10,7 @@ hasZeroFields: (bool) true }, opts: (*main.methodOptions)(0xc0002caa80)({ - authType: (*main.supportedAuth)(0xc000424780)({ + authType: (*main.supportedAuth)(0xc000428750)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -22,7 +22,8 @@ route: (string) (len=11) "/api/health", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), (*main.Method)(0xc0002be780)({ @@ -36,7 +37,7 @@ hasZeroFields: (bool) true }, opts: (*main.methodOptions)(0xc0002cac00)({ - authType: (*main.supportedAuth)(0xc000424870)({ + authType: (*main.supportedAuth)(0xc000428810)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -48,7 +49,8 @@ route: (string) (len=24) "/api/encryption/exchange", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), (*main.Method)(0xc0002be7d0)({ @@ -62,7 +64,7 @@ hasZeroFields: (bool) false }, opts: (*main.methodOptions)(0xc0002cad80)({ - authType: (*main.supportedAuth)(0xc000424930)({ + authType: (*main.supportedAuth)(0xc0004288a0)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", encrypted: (bool) true, @@ -75,7 +77,8 @@ route: (string) (len=16) "/api/lnd/getinfo", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), (*main.Method)(0xc0002be820)({ @@ -89,7 +92,7 @@ hasZeroFields: (bool) false }, opts: (*main.methodOptions)(0xc0002caf00)({ - authType: (*main.supportedAuth)(0xc0004249f0)({ + authType: (*main.supportedAuth)(0xc000428930)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -101,7 +104,8 @@ route: (string) (len=13) "/api/user/add", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), (*main.Method)(0xc0002be870)({ @@ -115,7 +119,7 @@ hasZeroFields: (bool) false }, opts: (*main.methodOptions)(0xc0002cb080)({ - authType: (*main.supportedAuth)(0xc000424ab0)({ + authType: (*main.supportedAuth)(0xc0004289c0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -127,7 +131,8 @@ route: (string) (len=14) "/api/user/auth", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), (*main.Method)(0xc0002be910)({ @@ -140,8 +145,8 @@ name: (string) (len=18) "NewAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cb200)({ - authType: (*main.supportedAuth)(0xc000424b70)({ + opts: (*main.methodOptions)(0xc0002cb260)({ + authType: (*main.supportedAuth)(0xc000428a80)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -154,7 +159,8 @@ route: (string) (len=19) "/api/user/chain/new", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), (*main.Method)(0xc0002be9b0)({ @@ -167,8 +173,8 @@ name: (string) (len=18) "PayAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cb380)({ - authType: (*main.supportedAuth)(0xc000424c30)({ + opts: (*main.methodOptions)(0xc0002cb440)({ + authType: (*main.supportedAuth)(0xc000428b10)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -181,7 +187,8 @@ route: (string) (len=19) "/api/user/chain/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), (*main.Method)(0xc0002bea50)({ @@ -194,8 +201,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cb500)({ - authType: (*main.supportedAuth)(0xc000424cf0)({ + opts: (*main.methodOptions)(0xc0002cb620)({ + authType: (*main.supportedAuth)(0xc000428ba0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -208,7 +215,8 @@ route: (string) (len=21) "/api/user/invoice/new", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), (*main.Method)(0xc0002beaf0)({ @@ -221,8 +229,8 @@ name: (string) (len=18) "PayInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cb680)({ - authType: (*main.supportedAuth)(0xc000424db0)({ + opts: (*main.methodOptions)(0xc0002cb800)({ + authType: (*main.supportedAuth)(0xc000428c30)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -235,7 +243,8 @@ route: (string) (len=21) "/api/user/invoice/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), (*main.Method)(0xc0002beb90)({ @@ -248,8 +257,8 @@ name: (string) (len=19) "OpenChannelResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cb800)({ - authType: (*main.supportedAuth)(0xc000424e70)({ + opts: (*main.methodOptions)(0xc0002cb9e0)({ + authType: (*main.supportedAuth)(0xc000428cc0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -262,7 +271,8 @@ route: (string) (len=22) "/api/user/open/channel", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), (*main.Method)(0xc0002bec30)({ @@ -275,8 +285,8 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cb980)({ - authType: (*main.supportedAuth)(0xc000424f30)({ + opts: (*main.methodOptions)(0xc0002cbbc0)({ + authType: (*main.supportedAuth)(0xc000428d50)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -289,7 +299,8 @@ route: (string) (len=29) "/api/user/lnurl_withdraw/link", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), (*main.Method)(0xc0002becd0)({ @@ -302,8 +313,8 @@ name: (string) (len=25) "LnurlWithdrawInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002cbce0)({ - authType: (*main.supportedAuth)(0xc0004250b0)({ + opts: (*main.methodOptions)(0xc0002cbf20)({ + authType: (*main.supportedAuth)(0xc000428ea0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -317,7 +328,8 @@ }, query: ([]string) (len=1 cap=1) { (string) (len=2) "k1" - } + }, + nostr: (bool) false }) }), (*main.Method)(0xc0002bed70)({ @@ -330,8 +342,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00042e060)({ - authType: (*main.supportedAuth)(0xc000425230)({ + opts: (*main.methodOptions)(0xc0004302a0)({ + authType: (*main.supportedAuth)(0xc000428ff0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -346,7 +358,8 @@ query: ([]string) (len=2 cap=2) { (string) (len=2) "k1", (string) (len=2) "pr" - } + }, + nostr: (bool) false }) }), (*main.Method)(0xc0002bee10)({ @@ -359,8 +372,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00042e3c0)({ - authType: (*main.supportedAuth)(0xc000425380)({ + opts: (*main.methodOptions)(0xc000430600)({ + authType: (*main.supportedAuth)(0xc000429110)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -374,7 +387,8 @@ }, query: ([]string) (len=1 cap=1) { (string) (len=2) "k1" - } + }, + nostr: (bool) false }) }), (*main.Method)(0xc0002beeb0)({ @@ -387,8 +401,8 @@ name: (string) (len=22) "HandleLnurlPayResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00042e720)({ - authType: (*main.supportedAuth)(0xc000425500)({ + opts: (*main.methodOptions)(0xc000430960)({ + authType: (*main.supportedAuth)(0xc000429260)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -403,7 +417,8 @@ query: ([]string) (len=2 cap=2) { (string) (len=2) "k1", (string) (len=6) "amount" - } + }, + nostr: (bool) false }) }), (*main.Method)(0xc0002bef50)({ @@ -416,8 +431,8 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00042e8a0)({ - authType: (*main.supportedAuth)(0xc0004255c0)({ + opts: (*main.methodOptions)(0xc000430b40)({ + authType: (*main.supportedAuth)(0xc0004292f0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -430,13 +445,14 @@ route: (string) (len=27) "/api/user/lnurl_channel/url", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }) } ([]*main.Enum) (len=1 cap=1) { - (*main.Enum)(0xc000424030)({ + (*main.Enum)(0xc000428030)({ name: (string) (len=11) "AddressType", values: ([]main.EnumValue) (len=3 cap=4) { (main.EnumValue) { @@ -456,17 +472,12 @@ } (map[string]*main.Message) (len=22) { - (string) (len=5) "Empty": (*main.Message)(0xc000247200)({ - fullName: (string) (len=5) "Empty", - name: (string) (len=5) "Empty", - fields: ([]*main.Field) - }), - (string) (len=18) "NewAddressResponse": (*main.Message)(0xc000247340)({ - fullName: (string) (len=18) "NewAddressResponse", - name: (string) (len=18) "NewAddressResponse", + (string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc0002474c0)({ + fullName: (string) (len=18) "PayInvoiceResponse", + name: (string) (len=18) "PayInvoiceResponse", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df800)({ - name: (string) (len=7) "address", + (*main.Field)(0xc0003dd9e0)({ + name: (string) (len=8) "preimage", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -480,7 +491,7 @@ fullName: (string) (len=18) "OpenChannelRequest", name: (string) (len=18) "OpenChannelRequest", fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc0003dfa10)({ + (*main.Field)(0xc0003dda10)({ name: (string) (len=11) "destination", kind: (string) (len=6) "string", isMap: (bool) false, @@ -489,7 +500,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfa40)({ + (*main.Field)(0xc0003dda40)({ name: (string) (len=13) "fundingAmount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -498,7 +509,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfa70)({ + (*main.Field)(0xc0003dda70)({ name: (string) (len=10) "pushAmount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -507,7 +518,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfaa0)({ + (*main.Field)(0xc0003ddaa0)({ name: (string) (len=12) "closeAddress", kind: (string) (len=6) "string", isMap: (bool) false, @@ -518,134 +529,11 @@ }) } }), - (string) (len=20) "LnurlPayInfoResponse": (*main.Message)(0xc000247680)({ - fullName: (string) (len=20) "LnurlPayInfoResponse", - name: (string) (len=20) "LnurlPayInfoResponse", - fields: ([]*main.Field) (len=5 cap=8) { - (*main.Field)(0xc0003dfce0)({ - 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)(0xc0003dfd10)({ - 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)(0xc0003dfd40)({ - 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)(0xc0003dfd70)({ - 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)(0xc0003dfda0)({ - 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)(0xc000247480)({ - fullName: (string) (len=17) "PayInvoiceRequest", - name: (string) (len=17) "PayInvoiceRequest", + (string) (len=15) "AuthUserRequest": (*main.Message)(0xc000247780)({ + fullName: (string) (len=15) "AuthUserRequest", + name: (string) (len=15) "AuthUserRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003df980)({ - 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)(0xc0003df9b0)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc0002474c0)({ - fullName: (string) (len=18) "PayInvoiceResponse", - name: (string) (len=18) "PayInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df9e0)({ - 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) "LnurlLinkResponse": (*main.Message)(0xc000247580)({ - fullName: (string) (len=17) "LnurlLinkResponse", - name: (string) (len=17) "LnurlLinkResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003dfb00)({ - 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)(0xc0003dfb30)({ - 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=14) "AddUserRequest": (*main.Message)(0xc000247700)({ - fullName: (string) (len=14) "AddUserRequest", - name: (string) (len=14) "AddUserRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0003dfe30)({ - 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)(0xc0003dfe60)({ + (*main.Field)(0xc0003ddf20)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -654,7 +542,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfe90)({ + (*main.Field)(0xc0003ddf50)({ name: (string) (len=6) "secret", kind: (string) (len=6) "string", isMap: (bool) false, @@ -665,35 +553,11 @@ }) } }), - (string) (len=16) "AuthUserResponse": (*main.Message)(0xc0002477c0)({ - fullName: (string) (len=16) "AuthUserResponse", - name: (string) (len=16) "AuthUserResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003dff80)({ - 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)(0xc0003dffb0)({ - 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)(0xc000247240)({ fullName: (string) (len=25) "EncryptionExchangeRequest", name: (string) (len=25) "EncryptionExchangeRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003df710)({ + (*main.Field)(0xc0003dd710)({ name: (string) (len=9) "publicKey", kind: (string) (len=6) "string", isMap: (bool) false, @@ -702,7 +566,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003df740)({ + (*main.Field)(0xc0003dd740)({ name: (string) (len=8) "deviceId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -717,7 +581,7 @@ fullName: (string) (len=17) "LndGetInfoRequest", name: (string) (len=17) "LndGetInfoRequest", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df770)({ + (*main.Field)(0xc0003dd770)({ name: (string) (len=6) "nodeId", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -728,44 +592,11 @@ }) } }), - (string) (len=17) "PayAddressRequest": (*main.Message)(0xc000247380)({ - fullName: (string) (len=17) "PayAddressRequest", - name: (string) (len=17) "PayAddressRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0003df830)({ - 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)(0xc0003df860)({ - 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)(0xc0003df890)({ - 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) "NewInvoiceResponse": (*main.Message)(0xc000247440)({ fullName: (string) (len=18) "NewInvoiceResponse", name: (string) (len=18) "NewInvoiceResponse", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df950)({ + (*main.Field)(0xc0003dd950)({ name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, @@ -780,7 +611,7 @@ fullName: (string) (len=19) "OpenChannelResponse", name: (string) (len=19) "OpenChannelResponse", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003dfad0)({ + (*main.Field)(0xc0003ddad0)({ name: (string) (len=9) "channelId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -791,12 +622,12 @@ }) } }), - (string) (len=15) "AddUserResponse": (*main.Message)(0xc000247740)({ - fullName: (string) (len=15) "AddUserResponse", - name: (string) (len=15) "AddUserResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003dfec0)({ - name: (string) (len=6) "userId", + (string) (len=20) "LnurlPayInfoResponse": (*main.Message)(0xc000247680)({ + fullName: (string) (len=20) "LnurlPayInfoResponse", + name: (string) (len=20) "LnurlPayInfoResponse", + fields: ([]*main.Field) (len=5 cap=8) { + (*main.Field)(0xc0003ddce0)({ + name: (string) (len=3) "tag", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -804,8 +635,35 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfef0)({ - name: (string) (len=9) "authToken", + (*main.Field)(0xc0003ddd10)({ + 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)(0xc0003ddd40)({ + 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)(0xc0003ddd70)({ + 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)(0xc0003ddda0)({ + name: (string) (len=8) "metadata", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -815,11 +673,20 @@ }) } }), - (string) (len=15) "AuthUserRequest": (*main.Message)(0xc000247780)({ - fullName: (string) (len=15) "AuthUserRequest", - name: (string) (len=15) "AuthUserRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003dff20)({ + (string) (len=14) "AddUserRequest": (*main.Message)(0xc000247700)({ + fullName: (string) (len=14) "AddUserRequest", + name: (string) (len=14) "AddUserRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0003dde30)({ + 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)(0xc0003dde60)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -828,7 +695,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dff50)({ + (*main.Field)(0xc0003dde90)({ name: (string) (len=6) "secret", kind: (string) (len=6) "string", isMap: (bool) false, @@ -839,43 +706,31 @@ }) } }), - (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc0002472c0)({ - fullName: (string) (len=18) "LndGetInfoResponse", - name: (string) (len=18) "LndGetInfoResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df7a0)({ - name: (string) (len=5) "alias", + (string) (len=17) "PayAddressRequest": (*main.Message)(0xc000247380)({ + fullName: (string) (len=17) "PayAddressRequest", + name: (string) (len=17) "PayAddressRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0003dd830)({ + 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) "NewAddressRequest": (*main.Message)(0xc000247300)({ - fullName: (string) (len=17) "NewAddressRequest", - name: (string) (len=17) "NewAddressRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df7d0)({ - name: (string) (len=11) "addressType", - kind: (string) (len=11) "AddressType", + }), + (*main.Field)(0xc0003dd860)({ + name: (string) (len=9) "amoutSats", + kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, - isEnum: (bool) true, + isEnum: (bool) false, isMessage: (bool) false, isOptional: (bool) false - }) - } - }), - (string) (len=18) "PayAddressResponse": (*main.Message)(0xc0002473c0)({ - fullName: (string) (len=18) "PayAddressResponse", - name: (string) (len=18) "PayAddressResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0003df8c0)({ - name: (string) (len=4) "txId", - kind: (string) (len=6) "string", + }), + (*main.Field)(0xc0003dd890)({ + name: (string) (len=10) "targetConf", + kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, @@ -888,7 +743,7 @@ fullName: (string) (len=17) "NewInvoiceRequest", name: (string) (len=17) "NewInvoiceRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003df8f0)({ + (*main.Field)(0xc0003dd8f0)({ name: (string) (len=10) "amountSats", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -897,7 +752,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003df920)({ + (*main.Field)(0xc0003dd920)({ name: (string) (len=4) "memo", kind: (string) (len=6) "string", isMap: (bool) false, @@ -908,11 +763,118 @@ }) } }), + (string) (len=18) "NewAddressResponse": (*main.Message)(0xc000247340)({ + fullName: (string) (len=18) "NewAddressResponse", + name: (string) (len=18) "NewAddressResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0003dd800)({ + 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) "LnurlLinkResponse": (*main.Message)(0xc000247580)({ + fullName: (string) (len=17) "LnurlLinkResponse", + name: (string) (len=17) "LnurlLinkResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0003ddb00)({ + 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)(0xc0003ddb30)({ + 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=16) "AuthUserResponse": (*main.Message)(0xc0002477c0)({ + fullName: (string) (len=16) "AuthUserResponse", + name: (string) (len=16) "AuthUserResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0003ddf80)({ + 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)(0xc0003ddfb0)({ + 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=5) "Empty": (*main.Message)(0xc000247200)({ + fullName: (string) (len=5) "Empty", + name: (string) (len=5) "Empty", + fields: ([]*main.Field) + }), + (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc0002472c0)({ + fullName: (string) (len=18) "LndGetInfoResponse", + name: (string) (len=18) "LndGetInfoResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0003dd7a0)({ + 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)(0xc000247480)({ + fullName: (string) (len=17) "PayInvoiceRequest", + name: (string) (len=17) "PayInvoiceRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0003dd980)({ + 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)(0xc0003dd9b0)({ + 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) "LnurlWithdrawInfoResponse": (*main.Message)(0xc000247600)({ fullName: (string) (len=25) "LnurlWithdrawInfoResponse", name: (string) (len=25) "LnurlWithdrawInfoResponse", fields: ([]*main.Field) (len=8 cap=8) { - (*main.Field)(0xc0003dfb60)({ + (*main.Field)(0xc0003ddb60)({ name: (string) (len=3) "tag", kind: (string) (len=6) "string", isMap: (bool) false, @@ -921,7 +883,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfb90)({ + (*main.Field)(0xc0003ddb90)({ name: (string) (len=8) "callback", kind: (string) (len=6) "string", isMap: (bool) false, @@ -930,7 +892,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfbc0)({ + (*main.Field)(0xc0003ddbc0)({ name: (string) (len=2) "k1", kind: (string) (len=6) "string", isMap: (bool) false, @@ -939,7 +901,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfbf0)({ + (*main.Field)(0xc0003ddbf0)({ name: (string) (len=18) "defaultDescription", kind: (string) (len=6) "string", isMap: (bool) false, @@ -948,7 +910,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfc20)({ + (*main.Field)(0xc0003ddc20)({ name: (string) (len=15) "minWithdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -957,7 +919,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfc50)({ + (*main.Field)(0xc0003ddc50)({ name: (string) (len=15) "maxWithdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -966,7 +928,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfc80)({ + (*main.Field)(0xc0003ddc80)({ name: (string) (len=12) "balanceCheck", kind: (string) (len=6) "string", isMap: (bool) false, @@ -975,7 +937,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfcb0)({ + (*main.Field)(0xc0003ddcb0)({ name: (string) (len=7) "payLink", kind: (string) (len=6) "string", isMap: (bool) false, @@ -990,7 +952,7 @@ fullName: (string) (len=22) "HandleLnurlPayResponse", name: (string) (len=22) "HandleLnurlPayResponse", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0003dfdd0)({ + (*main.Field)(0xc0003dddd0)({ name: (string) (len=2) "pr", kind: (string) (len=6) "string", isMap: (bool) false, @@ -999,7 +961,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0003dfe00)({ + (*main.Field)(0xc0003dde00)({ name: (string) (len=6) "routes", kind: (string) (len=5) "Empty", isMap: (bool) false, @@ -1009,6 +971,60 @@ isOptional: (bool) false }) } + }), + (string) (len=15) "AddUserResponse": (*main.Message)(0xc000247740)({ + fullName: (string) (len=15) "AddUserResponse", + name: (string) (len=15) "AddUserResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0003ddec0)({ + 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)(0xc0003ddef0)({ + 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=17) "NewAddressRequest": (*main.Message)(0xc000247300)({ + fullName: (string) (len=17) "NewAddressRequest", + name: (string) (len=17) "NewAddressRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0003dd7d0)({ + 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)(0xc0002473c0)({ + fullName: (string) (len=18) "PayAddressResponse", + name: (string) (len=18) "PayAddressResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0003dd8c0)({ + name: (string) (len=4) "txId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } }) } diff --git a/proto/autogenerated/ts/express_server.ts b/proto/autogenerated/ts/express_server.ts index de16ef2d..22fd378b 100644 --- a/proto/autogenerated/ts/express_server.ts +++ b/proto/autogenerated/ts/express_server.ts @@ -7,7 +7,7 @@ export type Logger = { log: (v: any) => void, error: (v: any) => void } export type ServerOptions = { allowCors?: true staticFiles?: string - allowNotImplementedMethods?: number + allowNotImplementedMethods?: true logger?: Logger throwErrors?: true GuestAuthGuard: (authorizationHeader?: string) => Promise diff --git a/proto/autogenerated/ts/nostr_client.ts b/proto/autogenerated/ts/nostr_client.ts new file mode 100644 index 00000000..fae0082f --- /dev/null +++ b/proto/autogenerated/ts/nostr_client.ts @@ -0,0 +1,115 @@ +// This file was autogenerated from a .proto file, DO NOT EDIT! +import { NostrRequest } from './nostr_transport.js' +import * as Types from './types.js' +export type ResultError = { status: 'ERROR', reason: string } + +export type NostrClientParams = { + pubDestination: string + retrieveNostrUserAuth: () => Promise + checkResult?: true +} +export default (params: NostrClientParams, send: (to:string, message: NostrRequest) => Promise) => ({ + NewAddress: async (request: Types.NewAddressRequest): 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:'NewAddress',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.NewAddressResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, + PayAddress: async (request: Types.PayAddressRequest): 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:'PayAddress',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.PayAddressResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, + NewInvoice: async (request: Types.NewInvoiceRequest): 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:'NewInvoice',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.NewInvoiceResponseValidate(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') + const nostrRequest: NostrRequest = {} + nostrRequest.body = request + const data = await send(params.pubDestination, {rpcName:'PayInvoice',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.PayInvoiceResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, + OpenChannel: async (request: Types.OpenChannelRequest): 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:'OpenChannel',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.OpenChannelResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, + GetLnurlWithdrawLink: async (): Promise => { + const auth = await params.retrieveNostrUserAuth() + if (auth === null) throw new Error('retrieveNostrUserAuth() returned null') + const nostrRequest: NostrRequest = {} + const data = await send(params.pubDestination, {rpcName:'GetLnurlWithdrawLink',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.LnurlLinkResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, + GetLNURLChannelLink: async (): Promise => { + const auth = await params.retrieveNostrUserAuth() + if (auth === null) throw new Error('retrieveNostrUserAuth() returned null') + const nostrRequest: NostrRequest = {} + const data = await send(params.pubDestination, {rpcName:'GetLNURLChannelLink',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.LnurlLinkResponseValidate(result) + if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message } + } + return { status: 'ERROR', reason: 'invalid response' } + }, +}) diff --git a/proto/autogenerated/ts/nostr_transport.ts b/proto/autogenerated/ts/nostr_transport.ts new file mode 100644 index 00000000..589574e1 --- /dev/null +++ b/proto/autogenerated/ts/nostr_transport.ts @@ -0,0 +1,112 @@ +// This file was autogenerated from a .proto file, DO NOT EDIT! + +import * as Types from './types.js' +export type Logger = { log: (v: any) => void, error: (v: any) => void } +type NostrResponse = (message: object) => void +export type NostrRequest = { + rpcName?: string + params?: Record + query?: Record + body?: any + authIdentifier?: string + requestId?: string +} +export type NostrOptions = { + logger?: Logger + throwErrors?: true + NostrUserAuthGuard: (identifier?: string) => Promise +} +const logErrorAndReturnResponse = (error: Error, response: string, res: NostrResponse, logger: Logger) => { logger.error(error.message || error); res({ status: 'ERROR', reason: response }) } +export default (methods: Types.ServerMethods, opts: NostrOptions) => { + const logger = opts.logger || { log: console.log, error: console.error } + return async (req: NostrRequest, res: NostrResponse) => { + switch (req.rpcName) { + case 'NewAddress': + try { + if (!methods.NewAddress) throw new Error('method: NewAddress is not implemented') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const request = req.body + const error = Types.NewAddressRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.NewAddress({ ...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 'PayAddress': + try { + if (!methods.PayAddress) throw new Error('method: PayAddress is not implemented') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const request = req.body + const error = Types.PayAddressRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.PayAddress({ ...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 'NewInvoice': + try { + if (!methods.NewInvoice) throw new Error('method: NewInvoice is not implemented') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const request = req.body + const error = Types.NewInvoiceRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.NewInvoice({ ...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') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const request = req.body + const error = Types.PayInvoiceRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.PayInvoice({ ...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 'OpenChannel': + try { + if (!methods.OpenChannel) throw new Error('method: OpenChannel is not implemented') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const request = req.body + const error = Types.OpenChannelRequestValidate(request) + if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) + const query = req.query + const params = req.params + const response = await methods.OpenChannel({ ...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 'GetLnurlWithdrawLink': + try { + if (!methods.GetLnurlWithdrawLink) throw new Error('method: GetLnurlWithdrawLink is not implemented') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const query = req.query + const params = req.params + const response = await methods.GetLnurlWithdrawLink({ ...authContext, ...query, ...params }) + 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 'GetLNURLChannelLink': + try { + if (!methods.GetLNURLChannelLink) throw new Error('method: GetLNURLChannelLink is not implemented') + const authContext = await opts.NostrUserAuthGuard(req.authIdentifier) + const query = req.query + const params = req.params + const response = await methods.GetLNURLChannelLink({ ...authContext, ...query, ...params }) + res({status: 'OK', ...response}) + }catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } + break + default: logger.error('unknown rpc call name from nostr event:'+req.rpcName) + } + } +} diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index a198cf78..46f5526b 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -129,25 +129,61 @@ export type OptionsBaseMessage = { allOptionalsAreSet?: true } -export type NewInvoiceRequest = { - amountSats: number - memo: string +export type NewAddressRequest = { + addressType: AddressType } -export const NewInvoiceRequestOptionalFields: [] = [] -export type NewInvoiceRequestOptions = OptionsBaseMessage & { +export const NewAddressRequestOptionalFields: [] = [] +export type NewAddressRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] - amountSats_CustomCheck?: (v: number) => boolean - memo_CustomCheck?: (v: string) => boolean + addressType_CustomCheck?: (v: AddressType) => boolean } -export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoiceRequestOptions = {}, path: string = 'NewInvoiceRequest::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.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 (!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`) - 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 PayAddressResponse = { + txId: string +} +export const PayAddressResponseOptionalFields: [] = [] +export type PayAddressResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + txId_CustomCheck?: (v: string) => boolean +} +export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddressResponseOptions = {}, path: string = 'PayAddressResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.txId !== 'string') return new Error(`${path}.txId: is not a string`) + if (opts.txId_CustomCheck && !opts.txId_CustomCheck(o.txId)) return new Error(`${path}.txId: custom check failed`) + + return null +} + +export type PayInvoiceRequest = { + invoice: string + amount: number +} +export const PayInvoiceRequestOptionalFields: [] = [] +export type PayInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) + if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) return null } @@ -233,290 +269,6 @@ export const HandleLnurlPayResponseValidate = (o?: HandleLnurlPayResponse, opts: 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 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 -} -export const PayAddressResponseOptionalFields: [] = [] -export type PayAddressResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - txId_CustomCheck?: (v: string) => boolean -} -export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddressResponseOptions = {}, path: string = 'PayAddressResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.txId !== 'string') return new Error(`${path}.txId: is not a string`) - if (opts.txId_CustomCheck && !opts.txId_CustomCheck(o.txId)) return new Error(`${path}.txId: custom check failed`) - - return null -} - -export type LnurlPayInfoResponse = { - tag: string - callback: string - maxSendable: number - minSendable: number - metadata: string -} -export const LnurlPayInfoResponseOptionalFields: [] = [] -export type LnurlPayInfoResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - tag_CustomCheck?: (v: string) => boolean - callback_CustomCheck?: (v: string) => boolean - maxSendable_CustomCheck?: (v: number) => boolean - minSendable_CustomCheck?: (v: number) => boolean - metadata_CustomCheck?: (v: string) => boolean -} -export const LnurlPayInfoResponseValidate = (o?: LnurlPayInfoResponse, opts: LnurlPayInfoResponseOptions = {}, path: string = 'LnurlPayInfoResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.tag !== 'string') return new Error(`${path}.tag: is not a string`) - if (opts.tag_CustomCheck && !opts.tag_CustomCheck(o.tag)) return new Error(`${path}.tag: custom check failed`) - - if (typeof o.callback !== 'string') return new Error(`${path}.callback: is not a string`) - if (opts.callback_CustomCheck && !opts.callback_CustomCheck(o.callback)) return new Error(`${path}.callback: custom check failed`) - - if (typeof o.maxSendable !== 'number') return new Error(`${path}.maxSendable: is not a number`) - if (opts.maxSendable_CustomCheck && !opts.maxSendable_CustomCheck(o.maxSendable)) return new Error(`${path}.maxSendable: custom check failed`) - - if (typeof o.minSendable !== 'number') return new Error(`${path}.minSendable: is not a number`) - if (opts.minSendable_CustomCheck && !opts.minSendable_CustomCheck(o.minSendable)) return new Error(`${path}.minSendable: custom check failed`) - - if (typeof o.metadata !== 'string') return new Error(`${path}.metadata: is not a string`) - if (opts.metadata_CustomCheck && !opts.metadata_CustomCheck(o.metadata)) return new Error(`${path}.metadata: 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 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 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 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 PayInvoiceRequest = { - invoice: string - amount: number -} -export const PayInvoiceRequestOptionalFields: [] = [] -export type PayInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type PayInvoiceResponse = { - preimage: string -} -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 -} - -export type LnurlLinkResponse = { - lnurl: string - k1: string -} -export const LnurlLinkResponseOptionalFields: [] = [] -export type LnurlLinkResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - lnurl_CustomCheck?: (v: string) => boolean - k1_CustomCheck?: (v: string) => boolean -} -export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLinkResponseOptions = {}, path: string = 'LnurlLinkResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.lnurl !== 'string') return new Error(`${path}.lnurl: is not a string`) - if (opts.lnurl_CustomCheck && !opts.lnurl_CustomCheck(o.lnurl)) return new Error(`${path}.lnurl: custom check failed`) - - if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) - if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) - - return null -} - -export type 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 OpenChannelResponse = { - channelId: string -} -export const OpenChannelResponseOptionalFields: [] = [] -export type OpenChannelResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - channelId_CustomCheck?: (v: string) => boolean -} -export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenChannelResponseOptions = {}, path: string = 'OpenChannelResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.channelId !== 'string') return new Error(`${path}.channelId: is not a string`) - if (opts.channelId_CustomCheck && !opts.channelId_CustomCheck(o.channelId)) return new Error(`${path}.channelId: custom check failed`) - - return null -} - export type AddUserResponse = { userId: string authToken: string @@ -540,52 +292,6 @@ export const AddUserResponseValidate = (o?: AddUserResponse, opts: AddUserRespon return null } -export type AuthUserRequest = { - name: string - secret: string -} -export const AuthUserRequestOptionalFields: [] = [] -export type AuthUserRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - name_CustomCheck?: (v: string) => boolean - secret_CustomCheck?: (v: string) => boolean -} -export const AuthUserRequestValidate = (o?: AuthUserRequest, opts: AuthUserRequestOptions = {}, path: string = 'AuthUserRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) - if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) - - if (typeof o.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 AuthUserResponse = { - userId: string - authToken: string -} -export const AuthUserResponseOptionalFields: [] = [] -export type AuthUserResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - userId_CustomCheck?: (v: string) => boolean - authToken_CustomCheck?: (v: string) => boolean -} -export const AuthUserResponseValidate = (o?: AuthUserResponse, opts: AuthUserResponseOptions = {}, path: string = 'AuthUserResponse::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 EncryptionExchangeRequest = { publicKey: string deviceId: string @@ -627,6 +333,80 @@ export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInf 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 +} + +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 AuthUserRequest = { + name: string + secret: string +} +export const AuthUserRequestOptionalFields: [] = [] +export type AuthUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + name_CustomCheck?: (v: string) => boolean + secret_CustomCheck?: (v: string) => boolean +} +export const AuthUserRequestValidate = (o?: AuthUserRequest, opts: AuthUserRequestOptions = {}, path: string = 'AuthUserRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) + if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) + + if (typeof o.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 PayAddressRequest = { address: string amoutSats: number @@ -655,3 +435,223 @@ export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddres 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 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 OpenChannelResponse = { + channelId: string +} +export const OpenChannelResponseOptionalFields: [] = [] +export type OpenChannelResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + channelId_CustomCheck?: (v: string) => boolean +} +export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenChannelResponseOptions = {}, path: string = 'OpenChannelResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.channelId !== 'string') return new Error(`${path}.channelId: is not a string`) + if (opts.channelId_CustomCheck && !opts.channelId_CustomCheck(o.channelId)) return new Error(`${path}.channelId: custom check failed`) + + return null +} + +export type LnurlPayInfoResponse = { + tag: string + callback: string + maxSendable: number + minSendable: number + metadata: string +} +export const LnurlPayInfoResponseOptionalFields: [] = [] +export type LnurlPayInfoResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + tag_CustomCheck?: (v: string) => boolean + callback_CustomCheck?: (v: string) => boolean + maxSendable_CustomCheck?: (v: number) => boolean + minSendable_CustomCheck?: (v: number) => boolean + metadata_CustomCheck?: (v: string) => boolean +} +export const LnurlPayInfoResponseValidate = (o?: LnurlPayInfoResponse, opts: LnurlPayInfoResponseOptions = {}, path: string = 'LnurlPayInfoResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.tag !== 'string') return new Error(`${path}.tag: is not a string`) + if (opts.tag_CustomCheck && !opts.tag_CustomCheck(o.tag)) return new Error(`${path}.tag: custom check failed`) + + if (typeof o.callback !== 'string') return new Error(`${path}.callback: is not a string`) + if (opts.callback_CustomCheck && !opts.callback_CustomCheck(o.callback)) return new Error(`${path}.callback: custom check failed`) + + if (typeof o.maxSendable !== 'number') return new Error(`${path}.maxSendable: is not a number`) + if (opts.maxSendable_CustomCheck && !opts.maxSendable_CustomCheck(o.maxSendable)) return new Error(`${path}.maxSendable: custom check failed`) + + if (typeof o.minSendable !== 'number') return new Error(`${path}.minSendable: is not a number`) + if (opts.minSendable_CustomCheck && !opts.minSendable_CustomCheck(o.minSendable)) return new Error(`${path}.minSendable: custom check failed`) + + if (typeof o.metadata !== 'string') return new Error(`${path}.metadata: is not a string`) + if (opts.metadata_CustomCheck && !opts.metadata_CustomCheck(o.metadata)) return new Error(`${path}.metadata: 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 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 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 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 LnurlLinkResponse = { + lnurl: string + k1: string +} +export const LnurlLinkResponseOptionalFields: [] = [] +export type LnurlLinkResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + lnurl_CustomCheck?: (v: string) => boolean + k1_CustomCheck?: (v: string) => boolean +} +export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLinkResponseOptions = {}, path: string = 'LnurlLinkResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.lnurl !== 'string') return new Error(`${path}.lnurl: is not a string`) + if (opts.lnurl_CustomCheck && !opts.lnurl_CustomCheck(o.lnurl)) return new Error(`${path}.lnurl: custom check failed`) + + if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) + if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) + + return null +} + +export type AuthUserResponse = { + userId: string + authToken: string +} +export const AuthUserResponseOptionalFields: [] = [] +export type AuthUserResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + userId_CustomCheck?: (v: string) => boolean + authToken_CustomCheck?: (v: string) => boolean +} +export const AuthUserResponseValidate = (o?: AuthUserResponse, opts: AuthUserResponseOptions = {}, path: string = 'AuthUserResponse::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 +} + diff --git a/proto/protoc-gen-pub.exe b/proto/protoc-gen-pub.exe index 9946f980..6b455447 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 4bb3181b..4c6e746f 100644 --- a/proto/service/methods.proto +++ b/proto/service/methods.proto @@ -43,6 +43,7 @@ extend google.protobuf.MethodOptions { // TODO: move this stuff to dep repo? string http_method = 50004; string http_route = 50005; MethodQueryOptions query = 50006; + bool nostr = 50007; } @@ -93,31 +94,37 @@ service LightningPub { option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/chain/new"; + option (nostr) = true; } rpc PayAddress(structs.PayAddressRequest) returns (structs.PayAddressResponse){ option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/chain/pay"; + option (nostr) = true; } rpc NewInvoice(structs.NewInvoiceRequest) returns (structs.NewInvoiceResponse){ option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/invoice/new"; + option (nostr) = true; } rpc PayInvoice(structs.PayInvoiceRequest) returns (structs.PayInvoiceResponse){ option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/invoice/pay"; + option (nostr) = true; } rpc OpenChannel(structs.OpenChannelRequest) returns (structs.OpenChannelResponse){ option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/open/channel"; + option (nostr) = true; } rpc GetLnurlWithdrawLink(structs.Empty) returns (structs.LnurlLinkResponse){ option (auth_type) = "User"; option (http_method) = "get"; option (http_route) = "/api/user/lnurl_withdraw/link"; + option (nostr) = true; } rpc GetLnurlWithdrawInfo(structs.Empty) returns (structs.LnurlWithdrawInfoResponse){ option (auth_type) = "Guest"; @@ -147,5 +154,6 @@ service LightningPub { option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/lnurl_channel/url"; + option (nostr) = true; } } \ No newline at end of file diff --git a/src/index.spec.ts b/src/index.spec.ts index 0ca81677..df1a7d9b 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,4 +1,5 @@ import 'dotenv/config' // TODO - test env +import crypto from 'crypto'; import { generatePrivateKey, getPublicKey } from 'nostr-tools'; import NewServer from '../proto/autogenerated/ts/express_server.js' import NewClient from '../proto/autogenerated/ts/http_client.js' @@ -10,6 +11,8 @@ import nostrMiddleware from './nostrMiddleware.js' import { LoadNosrtSettingsFromEnv } from './services/nostr/index.js'; import { expect } from 'chai'; import NostrHandler from './services/nostr/index.js' +import NewNostrClient from '../proto/autogenerated/ts/nostr_client.js' +import { NostrRequest } from '../proto/autogenerated/ts/nostr_transport.js'; const settings = LoadNosrtSettingsFromEnv(true) @@ -31,14 +34,48 @@ const client = NewClient({ encryptCallback: async (b) => b, deviceId: "device0" }) -const clientNostr = new NostrHandler({ +const clientCbs: Record void> = {} +const clientNostrHandler = new NostrHandler({ + allowedPubs: [], + privateKey: clientPrivateKey, + publicKey: clientPublicKey, + relays: settings.relays +}, (e) => { + const res = JSON.parse(e.content) as { requestId: string } + if (clientCbs[res.requestId]) { + const cb = clientCbs[res.requestId] + cb(res) + delete clientCbs[res.requestId] + } +}) +const clientSend = (to: string, message: NostrRequest): Promise => { + console.log("sending", message) + if (!message.requestId) { + message.requestId = crypto.randomBytes(20).toString('hex') + } + const reqId = message.requestId + if (clientCbs[reqId]) { + throw new Error("request was already sent") + } + clientNostrHandler.Send(to, JSON.stringify(message)) + return new Promise(res => { + clientCbs[reqId] = (response: any) => { + res(response) + } + }) +} +const clientNostr = NewNostrClient({ + pubDestination: serverPublicKey, + retrieveNostrUserAuth: async () => { return clientPublicKey } +}, clientSend) +/* new NostrHandler({ allowedPubs: [], privateKey: clientPrivateKey, publicKey: clientPublicKey, relays: settings.relays }, (event) => { console.log(event.content) -}) +})*/ const mainSettings = LoadMainSettingsFromEnv(true) const mainHandler = new Main(mainSettings) // TODO - test env file const serverMethods = GetServerMethods(mainHandler) @@ -57,7 +94,7 @@ export const setup = async () => { server.Listen(testPort) } export const teardown = async () => { - clientNostr.Stop() + clientNostrHandler.Stop() serverNostr.Stop() mainHandler.lnd.Stop() server.Close() @@ -82,8 +119,10 @@ export default async (d: (message: string, failure?: boolean) => void) => { console.log(await client.NewAddress({ addressType: Types.AddressType.WITNESS_PUBKEY_HASH })) d("new address ok") await new Promise(res => setTimeout(res, 2000)) - clientNostr.Send(serverPublicKey, JSON.stringify({ requestId: "a", method: '/api/user/chain/new', body: { address_type: 'WITNESS_PUBKEY_HASH' } })) - + //clientNostr.Send(serverPublicKey, JSON.stringify({ requestId: "a", method: '/api/user/chain/new', body: { address_type: 'WITNESS_PUBKEY_HASH' } })) + const nostrRes = await clientNostr.NewAddress({ addressType: Types.AddressType.WITNESS_PUBKEY_HASH }) + console.log(nostrRes) + d("nostr ok") const lnurlWithdrawLink = await client.GetLnurlWithdrawLink() if (lnurlWithdrawLink.status === 'ERROR') throw new Error(lnurlWithdrawLink.reason) const lnurlWithdrawInfo = await client.GetLnurlWithdrawInfo({ k1: lnurlWithdrawLink.k1 }) diff --git a/src/nostrMiddleware.ts b/src/nostrMiddleware.ts index 9280ddc5..da60f07b 100644 --- a/src/nostrMiddleware.ts +++ b/src/nostrMiddleware.ts @@ -2,16 +2,38 @@ import Main from "./services/main/index.js" import Nostr from "./services/nostr/index.js" import { NostrSettings } from "./services/nostr/handler.js" import * as Types from '../proto/autogenerated/ts/types.js' - +import NewNostrTransport, { NostrRequest } from '../proto/autogenerated/ts/nostr_transport.js'; const handledRequests: string[] = [] // TODO: - big memory leak here, add TTL -type EventRequest = { - requestId: string - method: string - params: Record - body: any - query: Record + +export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSettings: NostrSettings) => { + const nostrTransport = NewNostrTransport(serverMethods, { + NostrUserAuthGuard: async pub => { + if (!pub || !nostrSettings.allowedPubs.includes(pub)) { + throw new Error("nostr pub invalid or not allowed") + } + let nostrUser = await mainHandler.storage.FindNostrUser(pub) + if (!nostrUser) { // TODO: add POW + nostrUser = await mainHandler.storage.AddNostrUser(pub) + } + return { user_id: nostrUser.user.user_id } + } + }) + const nostr = new Nostr(nostrSettings, event => { + let j: NostrRequest + try { + j = JSON.parse(event.content) + } catch { + console.error("invalid json event received", event.content) + return + } + nostrTransport(j, res => { + nostr.Send(event.pub, JSON.stringify({ ...res, requestId: j.requestId })) + }) + }) + return { Stop: nostr.Stop } } +/* export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSettings: NostrSettings): Nostr => { // TODO: - move to codegen const nostr = new Nostr(nostrSettings, @@ -22,7 +44,6 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett } let nostrUser = await mainHandler.storage.FindNostrUser(event.pub) if (!nostrUser) { - nostrUser = await mainHandler.storage.AddNostrUser(event.pub) } let j: EventRequest @@ -52,4 +73,4 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett } }) return nostr -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/services/lnd/index.spec.ts b/src/services/lnd/index.spec.ts index 0d87f8af..cc792d12 100644 --- a/src/services/lnd/index.spec.ts +++ b/src/services/lnd/index.spec.ts @@ -21,7 +21,7 @@ export default async (d: (message: string, failure?: boolean) => void) => { console.log(addr) d("new address ok") - const invoice = await lnd.NewInvoice(1000) + const invoice = await lnd.NewInvoice(1000, "") console.log(invoice) d("new invoice ok") diff --git a/src/services/nostr/handler.ts b/src/services/nostr/handler.ts index 29c1a2db..2cbcf249 100644 --- a/src/services/nostr/handler.ts +++ b/src/services/nostr/handler.ts @@ -46,6 +46,7 @@ process.on("message", (message: ChildProcessRequest) => { break case 'send': sendToNostr(message.pub, message.message) + break default: console.error("unknown nostr request", message) break diff --git a/src/services/serverMethods/index.ts b/src/services/serverMethods/index.ts index f9969d3e..cb80efbf 100644 --- a/src/services/serverMethods/index.ts +++ b/src/services/serverMethods/index.ts @@ -52,15 +52,30 @@ export default (mainHandler: Main): Types.ServerMethods => { }, GetLnurlWithdrawInfo: async (ctx) => { if (!ctx.k1) { - throw new Error("invalid lnurl to get info") + throw new Error("invalid lnurl withdraw to get info") } return mainHandler.GetLnurlWithdrawInfo(ctx.k1) }, HandleLnurlWithdraw: async (ctx) => { if (!ctx.k1 || !ctx.pr) { - throw new Error("invalid lnurl to handle") + throw new Error("invalid lnurl withdraw to handle") } - await mainHandler.HandleLnurlWithdraw(ctx.k1, ctx.pr) + return mainHandler.HandleLnurlWithdraw(ctx.k1, ctx.pr) + }, + GetLnurlPayInfo: async (ctx) => { + if (!ctx.k1) { + throw new Error("invalid lnurl pay to get info") + } + return mainHandler.GetLnurlPayInfo(ctx.k1) + }, + HandleLnurlPay: async (ctx) => { + if (!ctx.k1 || !ctx.amount) { + throw new Error("invalid lnurl pay to handle") + } + if (isNaN(+ctx.amount)) { + throw new Error("invalid amount in lnurl pay to handle") + } + return mainHandler.HandleLnurlPay(ctx.k1, +ctx.amount) }, GetLNURLChannelLink: async (ctx) => { throw new Error("unimplemented") diff --git a/src/testRunner.ts b/src/testRunner.ts index 3af99a58..e02947fc 100644 --- a/src/testRunner.ts +++ b/src/testRunner.ts @@ -7,6 +7,7 @@ type TestModule = { default: (describe: Describe) => Promise teardown?: () => Promise } +let failures = 0 const start = async () => { const files = await globby("**/*.spec.js") @@ -15,6 +16,11 @@ const start = async () => { const module = await import(`./${file.slice("build/src/".length)}`) as TestModule await runTestFile(file, module) } + if (failures) { + console.error(redConsole, "there have been", `${failures}`, "failures in all tests", resetConsole) + } else { + console.log(greenConsole, "there have been 0 failures in all tests", resetConsole) + } } @@ -46,6 +52,7 @@ const runTestFile = async (fileName: string, mod: TestModule) => { const getDescribe = (fileName: string): Describe => { return (message, failure) => { if (failure) { + failures++ console.error(redConsole, fileName, ":", message, resetConsole) } else { console.log(greenConsole, fileName, ":", message, resetConsole)