up
This commit is contained in:
parent
c5fd454089
commit
4f550a937f
69 changed files with 8098 additions and 23341 deletions
|
|
@ -1,5 +1,5 @@
|
|||
([]*main.Method) (len=3 cap=4) {
|
||||
(*main.Method)(0xc00029e730)({
|
||||
([]*main.Method) (len=11 cap=16) {
|
||||
(*main.Method)(0xc0002b6730)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=5) "Empty",
|
||||
hasZeroFields: (bool) true
|
||||
|
|
@ -9,23 +9,23 @@
|
|||
name: (string) (len=5) "Empty",
|
||||
hasZeroFields: (bool) true
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc000039b60)({
|
||||
authType: (*main.supportedAuth)(0xc0003a2b40)({
|
||||
id: (string) (len=7) "no_auth",
|
||||
name: (string) (len=6) "NoAuth",
|
||||
opts: (*main.methodOptions)(0xc0003f2480)({
|
||||
authType: (*main.supportedAuth)(0xc0003c3dd0)({
|
||||
id: (string) (len=5) "guest",
|
||||
name: (string) (len=5) "Guest",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) {
|
||||
}
|
||||
}),
|
||||
method: (string) (len=3) "get",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=7) "/health",
|
||||
route: (string) (len=11) "/api/health",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc00029e780)({
|
||||
(*main.Method)(0xc0002b6780)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=25) "EncryptionExchangeRequest",
|
||||
hasZeroFields: (bool) false
|
||||
|
|
@ -35,10 +35,10 @@
|
|||
name: (string) (len=5) "Empty",
|
||||
hasZeroFields: (bool) true
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc000039ce0)({
|
||||
authType: (*main.supportedAuth)(0xc0003a2c00)({
|
||||
id: (string) (len=7) "no_auth",
|
||||
name: (string) (len=6) "NoAuth",
|
||||
opts: (*main.methodOptions)(0xc0003f2600)({
|
||||
authType: (*main.supportedAuth)(0xc0003c3ec0)({
|
||||
id: (string) (len=5) "guest",
|
||||
name: (string) (len=5) "Guest",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) {
|
||||
}
|
||||
|
|
@ -51,27 +51,242 @@
|
|||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc00029e7d0)({
|
||||
(*main.Method)(0xc0002b67d0)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=5) "Empty",
|
||||
hasZeroFields: (bool) true
|
||||
name: (string) (len=17) "LndGetInfoRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=10) "LndGetInfo",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=18) "LndGetInfoResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc000039e60)({
|
||||
authType: (*main.supportedAuth)(0xc0003a2cc0)({
|
||||
id: (string) (len=7) "no_auth",
|
||||
name: (string) (len=6) "NoAuth",
|
||||
opts: (*main.methodOptions)(0xc0003f2780)({
|
||||
authType: (*main.supportedAuth)(0xc0003c3f80)({
|
||||
id: (string) (len=5) "admin",
|
||||
name: (string) (len=5) "Admin",
|
||||
encrypted: (bool) true,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=8) "admin_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=16) "/api/lnd/getinfo",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6820)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=14) "AddUserRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=7) "AddUser",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=15) "AddUserResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f2900)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe060)({
|
||||
id: (string) (len=5) "guest",
|
||||
name: (string) (len=5) "Guest",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) {
|
||||
}
|
||||
}),
|
||||
method: (string) (len=3) "get",
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=16) "/api/lnd/getinfo",
|
||||
route: (string) (len=13) "/api/user/add",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6870)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=15) "AuthUserRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=8) "AuthUser",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=16) "AuthUserResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f2a80)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe120)({
|
||||
id: (string) (len=5) "guest",
|
||||
name: (string) (len=5) "Guest",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) {
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=14) "/api/user/auth",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6910)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=5) "Empty",
|
||||
hasZeroFields: (bool) true
|
||||
},
|
||||
name: (string) (len=10) "NewAddress",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=18) "NewAddressResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f2c00)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe1e0)({
|
||||
id: (string) (len=4) "user",
|
||||
name: (string) (len=4) "User",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=7) "user_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=19) "/api/user/chain/new",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b69b0)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=17) "PayAddressRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=10) "PayAddress",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=18) "PayAddressResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f2d80)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe2a0)({
|
||||
id: (string) (len=4) "user",
|
||||
name: (string) (len=4) "User",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=7) "user_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=19) "/api/user/chain/pay",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6a50)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=17) "NewInvoiceRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=10) "NewInvoice",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=18) "NewInvoiceResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f2f00)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe360)({
|
||||
id: (string) (len=4) "user",
|
||||
name: (string) (len=4) "User",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=7) "user_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=21) "/api/user/invoice/new",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6af0)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=17) "PayInvoiceRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=10) "PayInvoice",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=18) "PayInvoiceResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f3080)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe420)({
|
||||
id: (string) (len=4) "user",
|
||||
name: (string) (len=4) "User",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=7) "user_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=21) "/api/user/invoice/pay",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6b90)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=18) "OpenChannelRequest",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
name: (string) (len=11) "OpenChannel",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=19) "OpenChannelResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f3200)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe4e0)({
|
||||
id: (string) (len=4) "user",
|
||||
name: (string) (len=4) "User",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=7) "user_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=22) "/api/user/open/channel",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
})
|
||||
}),
|
||||
(*main.Method)(0xc0002b6be0)({
|
||||
in: (main.MethodMessage) {
|
||||
name: (string) (len=5) "Empty",
|
||||
hasZeroFields: (bool) true
|
||||
},
|
||||
name: (string) (len=19) "GetOpenChannelLNURL",
|
||||
out: (main.MethodMessage) {
|
||||
name: (string) (len=27) "GetOpenChannelLNURLResponse",
|
||||
hasZeroFields: (bool) false
|
||||
},
|
||||
opts: (*main.methodOptions)(0xc0003f3380)({
|
||||
authType: (*main.supportedAuth)(0xc0003fe5a0)({
|
||||
id: (string) (len=4) "user",
|
||||
name: (string) (len=4) "User",
|
||||
encrypted: (bool) false,
|
||||
context: (map[string]string) (len=1) {
|
||||
(string) (len=7) "user_id": (string) (len=6) "string"
|
||||
}
|
||||
}),
|
||||
method: (string) (len=4) "post",
|
||||
route: (main.decodedRoute) {
|
||||
route: (string) (len=23) "/api/user/lnurl_channel",
|
||||
params: ([]string) <nil>
|
||||
},
|
||||
query: ([]string) <nil>
|
||||
|
|
@ -81,36 +296,12 @@
|
|||
|
||||
([]*main.Enum) <nil>
|
||||
|
||||
(map[string]*main.Message) (len=3) {
|
||||
(string) (len=25) "EncryptionExchangeRequest": (*main.Message)(0xc000238f40)({
|
||||
fullName: (string) (len=25) "EncryptionExchangeRequest",
|
||||
name: (string) (len=25) "EncryptionExchangeRequest",
|
||||
fields: ([]*main.Field) (len=2 cap=2) {
|
||||
(*main.Field)(0xc0003a2390)({
|
||||
name: (string) (len=10) "public_key",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003a23c0)({
|
||||
name: (string) (len=9) "device_id",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc000238f80)({
|
||||
(map[string]*main.Message) (len=18) {
|
||||
(string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc0002470c0)({
|
||||
fullName: (string) (len=18) "LndGetInfoResponse",
|
||||
name: (string) (len=18) "LndGetInfoResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003a23f0)({
|
||||
(*main.Field)(0xc0003c3260)({
|
||||
name: (string) (len=5) "alias",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
|
|
@ -121,14 +312,335 @@
|
|||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=5) "Empty": (*main.Message)(0xc000238f00)({
|
||||
(string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc000247200)({
|
||||
fullName: (string) (len=18) "NewInvoiceResponse",
|
||||
name: (string) (len=18) "NewInvoiceResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c3380)({
|
||||
name: (string) (len=7) "invoice",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=17) "PayInvoiceRequest": (*main.Message)(0xc000247240)({
|
||||
fullName: (string) (len=17) "PayInvoiceRequest",
|
||||
name: (string) (len=17) "PayInvoiceRequest",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c33b0)({
|
||||
name: (string) (len=6) "invoce",
|
||||
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)(0xc000247040)({
|
||||
fullName: (string) (len=25) "EncryptionExchangeRequest",
|
||||
name: (string) (len=25) "EncryptionExchangeRequest",
|
||||
fields: ([]*main.Field) (len=2 cap=2) {
|
||||
(*main.Field)(0xc0003c31d0)({
|
||||
name: (string) (len=10) "public_key",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3200)({
|
||||
name: (string) (len=9) "device_id",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc000247080)({
|
||||
fullName: (string) (len=17) "LndGetInfoRequest",
|
||||
name: (string) (len=17) "LndGetInfoRequest",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c3230)({
|
||||
name: (string) (len=7) "node_id",
|
||||
kind: (string) (len=5) "int64",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=18) "NewAddressResponse": (*main.Message)(0xc000247100)({
|
||||
fullName: (string) (len=18) "NewAddressResponse",
|
||||
name: (string) (len=18) "NewAddressResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c3290)({
|
||||
name: (string) (len=7) "address",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=17) "NewInvoiceRequest": (*main.Message)(0xc0002471c0)({
|
||||
fullName: (string) (len=17) "NewInvoiceRequest",
|
||||
name: (string) (len=17) "NewInvoiceRequest",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c3350)({
|
||||
name: (string) (len=11) "amount_sats",
|
||||
kind: (string) (len=5) "int64",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=18) "OpenChannelRequest": (*main.Message)(0xc0002472c0)({
|
||||
fullName: (string) (len=18) "OpenChannelRequest",
|
||||
name: (string) (len=18) "OpenChannelRequest",
|
||||
fields: ([]*main.Field) (len=3 cap=4) {
|
||||
(*main.Field)(0xc0003c3410)({
|
||||
name: (string) (len=11) "destination",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3440)({
|
||||
name: (string) (len=15) "channel_balance",
|
||||
kind: (string) (len=5) "int64",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3470)({
|
||||
name: (string) (len=11) "push_amount",
|
||||
kind: (string) (len=5) "int64",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=14) "AddUserRequest": (*main.Message)(0xc000247380)({
|
||||
fullName: (string) (len=14) "AddUserRequest",
|
||||
name: (string) (len=14) "AddUserRequest",
|
||||
fields: ([]*main.Field) (len=3 cap=4) {
|
||||
(*main.Field)(0xc0003c3500)({
|
||||
name: (string) (len=12) "callback_url",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3530)({
|
||||
name: (string) (len=4) "name",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3560)({
|
||||
name: (string) (len=6) "secret",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=15) "AuthUserRequest": (*main.Message)(0xc000247400)({
|
||||
fullName: (string) (len=15) "AuthUserRequest",
|
||||
name: (string) (len=15) "AuthUserRequest",
|
||||
fields: ([]*main.Field) (len=2 cap=2) {
|
||||
(*main.Field)(0xc0003c35f0)({
|
||||
name: (string) (len=4) "name",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3620)({
|
||||
name: (string) (len=6) "secret",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=17) "PayAddressRequest": (*main.Message)(0xc000247140)({
|
||||
fullName: (string) (len=17) "PayAddressRequest",
|
||||
name: (string) (len=17) "PayAddressRequest",
|
||||
fields: ([]*main.Field) (len=2 cap=2) {
|
||||
(*main.Field)(0xc0003c32c0)({
|
||||
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)(0xc0003c32f0)({
|
||||
name: (string) (len=10) "amout_sats",
|
||||
kind: (string) (len=5) "int64",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=18) "PayAddressResponse": (*main.Message)(0xc000247180)({
|
||||
fullName: (string) (len=18) "PayAddressResponse",
|
||||
name: (string) (len=18) "PayAddressResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c3320)({
|
||||
name: (string) (len=5) "tx_id",
|
||||
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)(0xc000247440)({
|
||||
fullName: (string) (len=16) "AuthUserResponse",
|
||||
name: (string) (len=16) "AuthUserResponse",
|
||||
fields: ([]*main.Field) (len=2 cap=2) {
|
||||
(*main.Field)(0xc0003c3650)({
|
||||
name: (string) (len=7) "user_id",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c3680)({
|
||||
name: (string) (len=10) "auth_token",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=5) "Empty": (*main.Message)(0xc000247000)({
|
||||
fullName: (string) (len=5) "Empty",
|
||||
name: (string) (len=5) "Empty",
|
||||
fields: ([]*main.Field) <nil>
|
||||
}),
|
||||
(string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc000247280)({
|
||||
fullName: (string) (len=18) "PayInvoiceResponse",
|
||||
name: (string) (len=18) "PayInvoiceResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c33e0)({
|
||||
name: (string) (len=8) "preimage",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=19) "OpenChannelResponse": (*main.Message)(0xc000247300)({
|
||||
fullName: (string) (len=19) "OpenChannelResponse",
|
||||
name: (string) (len=19) "OpenChannelResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c34a0)({
|
||||
name: (string) (len=10) "channel_id",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=27) "GetOpenChannelLNURLResponse": (*main.Message)(0xc000247340)({
|
||||
fullName: (string) (len=27) "GetOpenChannelLNURLResponse",
|
||||
name: (string) (len=27) "GetOpenChannelLNURLResponse",
|
||||
fields: ([]*main.Field) (len=1 cap=1) {
|
||||
(*main.Field)(0xc0003c34d0)({
|
||||
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
|
||||
})
|
||||
}
|
||||
}),
|
||||
(string) (len=15) "AddUserResponse": (*main.Message)(0xc0002473c0)({
|
||||
fullName: (string) (len=15) "AddUserResponse",
|
||||
name: (string) (len=15) "AddUserResponse",
|
||||
fields: ([]*main.Field) (len=2 cap=2) {
|
||||
(*main.Field)(0xc0003c3590)({
|
||||
name: (string) (len=7) "user_id",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
}),
|
||||
(*main.Field)(0xc0003c35c0)({
|
||||
name: (string) (len=10) "auth_token",
|
||||
kind: (string) (len=6) "string",
|
||||
isMap: (bool) false,
|
||||
isArray: (bool) false,
|
||||
isEnum: (bool) false,
|
||||
isMessage: (bool) false,
|
||||
isOptional: (bool) false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
parsing file: structs 3
|
||||
parsing file: structs 18
|
||||
parsing file: methods 2
|
||||
-> [{no_auth NoAuth false map[]} {guest Guest false map[token:string]} {admin Admin true map[pub:string]}]
|
||||
-> [{guest Guest false map[]} {user User false map[user_id:string]} {admin Admin true map[admin_id:string]}]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,57 +1,180 @@
|
|||
// This file was autogenerated from a .proto file, DO NOT EDIT!
|
||||
|
||||
import express, { Response } from 'express'
|
||||
import express, { Response, json, urlencoded } from 'express'
|
||||
import cors from 'cors'
|
||||
import * as Types from './types'
|
||||
export type Logger = { log: (v: any) => void, error: (v: any) => void }
|
||||
export type ServerOptions = {
|
||||
allowCors?: true
|
||||
staticFiles?: string
|
||||
allowNotImplementedMethods?: number
|
||||
logger?: Logger
|
||||
throwErrors?: true
|
||||
NoAuthAuthGuard: (authorizationHeader?: string) => Promise<Types.NoAuthContext>
|
||||
GuestAuthGuard: (authorizationHeader?: string) => Promise<Types.GuestContext>
|
||||
UserAuthGuard: (authorizationHeader?: string) => Promise<Types.UserContext>
|
||||
AdminAuthGuard: (authorizationHeader?: string) => Promise<Types.AdminContext>
|
||||
encryptionCallback: (ctx: Types.AuthContext, body: any) => Promise<string>
|
||||
decryptCallback: (encryptionDeviceId: string, body: any) => Promise<any>
|
||||
encryptCallback: (encryptionDeviceId: string, plain: any) => Promise<any>
|
||||
}
|
||||
const logErrorAndReturnResponse = (error: Error, response: string, res: Response, logger: Logger) => { logger.error(error.message || error); res.json({ status: 'ERROR', reason: response }) }
|
||||
export default (methods: Types.ServerMethods, opts: ServerOptions) => {
|
||||
const logger = opts.logger || { log: console.log, error: console.error }
|
||||
const app = express()
|
||||
if (opts.allowCors) {
|
||||
app.use(cors())
|
||||
}
|
||||
app.use(json())
|
||||
app.use(urlencoded({ extended: true }))
|
||||
if (!opts.allowNotImplementedMethods && !methods.Health) throw new Error('method: Health is not implemented')
|
||||
app.get('/health', async (req, res) => {
|
||||
app.get('/api/health', async (req, res) => {
|
||||
try {
|
||||
if (!methods.Health) throw new Error('method: Health is not implemented')
|
||||
const authContext = await opts.NoAuthAuthGuard(req.headers['authorization'])
|
||||
const authContext = await opts.GuestAuthGuard(req.headers['authorization'])
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
await methods.Health({ ...authContext, ...query, ...params })
|
||||
res.json({ status: 'OK' })
|
||||
res.json({status: 'OK'})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.EncryptionExchange) throw new Error('method: EncryptionExchange is not implemented')
|
||||
app.post('/api/encryption/exchange', async (req, res) => {
|
||||
try {
|
||||
if (!methods.EncryptionExchange) throw new Error('method: EncryptionExchange is not implemented')
|
||||
const authContext = await opts.NoAuthAuthGuard(req.headers['authorization'])
|
||||
const authContext = await opts.GuestAuthGuard(req.headers['authorization'])
|
||||
const request = req.body
|
||||
const error = Types.EncryptionExchangeRequestValidate(request)
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
await methods.EncryptionExchange({ ...authContext, ...query, ...params }, request)
|
||||
res.json({ status: 'OK' })
|
||||
res.json({status: 'OK'})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.LndGetInfo) throw new Error('method: LndGetInfo is not implemented')
|
||||
app.get('/api/lnd/getinfo', async (req, res) => {
|
||||
app.post('/api/lnd/getinfo', async (req, res) => {
|
||||
try {
|
||||
if (!methods.LndGetInfo) throw new Error('method: LndGetInfo is not implemented')
|
||||
const authContext = await opts.NoAuthAuthGuard(req.headers['authorization'])
|
||||
const authContext = await opts.AdminAuthGuard(req.headers['authorization'])
|
||||
const encryptionDeviceId = req.headers['x-e2ee-device-id-x']
|
||||
if (typeof encryptionDeviceId !== 'string' || encryptionDeviceId === '') throw new Error('invalid encryption header provided')
|
||||
const request = await opts.decryptCallback(encryptionDeviceId, req.body)
|
||||
const error = Types.LndGetInfoRequestValidate(request)
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
const response = await methods.LndGetInfo({ ...authContext, ...query, ...params })
|
||||
res.json({ status: 'OK', result: response })
|
||||
const response = await methods.LndGetInfo({ ...authContext, ...query, ...params }, request)
|
||||
res.json({status: 'OK', result: await opts.encryptCallback(encryptionDeviceId, response)})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.AddUser) throw new Error('method: AddUser is not implemented')
|
||||
app.post('/api/user/add', async (req, res) => {
|
||||
try {
|
||||
if (!methods.AddUser) throw new Error('method: AddUser is not implemented')
|
||||
const authContext = await opts.GuestAuthGuard(req.headers['authorization'])
|
||||
const request = req.body
|
||||
const error = Types.AddUserRequestValidate(request)
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
const response = await methods.AddUser({ ...authContext, ...query, ...params }, request)
|
||||
res.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.AuthUser) throw new Error('method: AuthUser is not implemented')
|
||||
app.post('/api/user/auth', async (req, res) => {
|
||||
try {
|
||||
if (!methods.AuthUser) throw new Error('method: AuthUser is not implemented')
|
||||
const authContext = await opts.GuestAuthGuard(req.headers['authorization'])
|
||||
const request = req.body
|
||||
const error = Types.AuthUserRequestValidate(request)
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
const response = await methods.AuthUser({ ...authContext, ...query, ...params }, request)
|
||||
res.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.NewAddress) throw new Error('method: NewAddress is not implemented')
|
||||
app.post('/api/user/chain/new', async (req, res) => {
|
||||
try {
|
||||
if (!methods.NewAddress) throw new Error('method: NewAddress is not implemented')
|
||||
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
const response = await methods.NewAddress({ ...authContext, ...query, ...params })
|
||||
res.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.PayAddress) throw new Error('method: PayAddress is not implemented')
|
||||
app.post('/api/user/chain/pay', async (req, res) => {
|
||||
try {
|
||||
if (!methods.PayAddress) throw new Error('method: PayAddress is not implemented')
|
||||
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
|
||||
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.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.NewInvoice) throw new Error('method: NewInvoice is not implemented')
|
||||
app.post('/api/user/invoice/new', async (req, res) => {
|
||||
try {
|
||||
if (!methods.NewInvoice) throw new Error('method: NewInvoice is not implemented')
|
||||
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
|
||||
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.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.PayInvoice) throw new Error('method: PayInvoice is not implemented')
|
||||
app.post('/api/user/invoice/pay', async (req, res) => {
|
||||
try {
|
||||
if (!methods.PayInvoice) throw new Error('method: PayInvoice is not implemented')
|
||||
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
|
||||
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.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.OpenChannel) throw new Error('method: OpenChannel is not implemented')
|
||||
app.post('/api/user/open/channel', async (req, res) => {
|
||||
try {
|
||||
if (!methods.OpenChannel) throw new Error('method: OpenChannel is not implemented')
|
||||
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
|
||||
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.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.GetOpenChannelLNURL) throw new Error('method: GetOpenChannelLNURL is not implemented')
|
||||
app.post('/api/user/lnurl_channel', async (req, res) => {
|
||||
try {
|
||||
if (!methods.GetOpenChannelLNURL) throw new Error('method: GetOpenChannelLNURL is not implemented')
|
||||
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
const response = await methods.GetOpenChannelLNURL({ ...authContext, ...query, ...params })
|
||||
res.json({status: 'OK', result: response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (opts.staticFiles) {
|
||||
app.use(express.static(opts.staticFiles))
|
||||
}
|
||||
var server: { close: () => void } | undefined
|
||||
return {
|
||||
Close: () => { if (!server) { throw new Error('tried closing server before starting') } else server.close() },
|
||||
|
|
|
|||
|
|
@ -5,15 +5,19 @@ export type ResultError = { status: 'ERROR', reason: string }
|
|||
|
||||
export type ClientParams = {
|
||||
baseUrl: string
|
||||
retrieveNoAuthAuth: () => Promise<string | null>
|
||||
retrieveGuestAuth: () => Promise<string | null>
|
||||
retrieveUserAuth: () => Promise<string | null>
|
||||
retrieveAdminAuth: () => Promise<string | null>
|
||||
encryptCallback: (plain: any) => Promise<any>
|
||||
decryptCallback: (encrypted: any) => Promise<any>
|
||||
deviceId: string
|
||||
}
|
||||
export default (params: ClientParams) => ({
|
||||
Health: async (): Promise<ResultError | { status: 'OK' }> => {
|
||||
const auth = await params.retrieveNoAuthAuth()
|
||||
if (auth === null) throw new Error('retrieveNoAuthAuth() returned null')
|
||||
const { data } = await axios.get(params.baseUrl + '/health', { headers: { 'authorization': auth } })
|
||||
const auth = await params.retrieveGuestAuth()
|
||||
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
|
||||
let finalRoute = '/api/health'
|
||||
const { data } = await axios.get(params.baseUrl + finalRoute, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
return data
|
||||
|
|
@ -21,23 +25,130 @@ export default (params: ClientParams) => ({
|
|||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
EncryptionExchange: async (request: Types.EncryptionExchangeRequest): Promise<ResultError | { status: 'OK' }> => {
|
||||
const auth = await params.retrieveNoAuthAuth()
|
||||
if (auth === null) throw new Error('retrieveNoAuthAuth() returned null')
|
||||
const { data } = await axios.post(params.baseUrl + '/api/encryption/exchange', request, { headers: { 'authorization': auth } })
|
||||
const auth = await params.retrieveGuestAuth()
|
||||
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
|
||||
let finalRoute = '/api/encryption/exchange'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
return data
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
LndGetInfo: async (): Promise<ResultError | { status: 'OK', result: Types.Empty }> => {
|
||||
const auth = await params.retrieveNoAuthAuth()
|
||||
if (auth === null) throw new Error('retrieveNoAuthAuth() returned null')
|
||||
const { data } = await axios.get(params.baseUrl + '/api/lnd/getinfo', { headers: { 'authorization': auth } })
|
||||
LndGetInfo: async (request: Types.LndGetInfoRequest): Promise<ResultError | { status: 'OK', result: Types.LndGetInfoResponse }> => {
|
||||
const auth = await params.retrieveAdminAuth()
|
||||
if (auth === null) throw new Error('retrieveAdminAuth() returned null')
|
||||
let finalRoute = '/api/lnd/getinfo'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, await params.encryptCallback(request), { headers: { 'authorization': auth, 'x-e2ee-device-id-x': params.deviceId } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const error = Types.LndGetInfoResponseValidate(data.result)
|
||||
if (error === null) { return data } else return { status: 'ERROR', reason: error.message }
|
||||
const result = await params.decryptCallback(data.result)
|
||||
const error = Types.LndGetInfoResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
AddUser: async (request: Types.AddUserRequest): Promise<ResultError | { status: 'OK', result: Types.AddUserResponse }> => {
|
||||
const auth = await params.retrieveGuestAuth()
|
||||
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
|
||||
let finalRoute = '/api/user/add'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.AddUserResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
AuthUser: async (request: Types.AuthUserRequest): Promise<ResultError | { status: 'OK', result: Types.AuthUserResponse }> => {
|
||||
const auth = await params.retrieveGuestAuth()
|
||||
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
|
||||
let finalRoute = '/api/user/auth'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.AuthUserResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
NewAddress: async (): Promise<ResultError | { status: 'OK', result: Types.NewAddressResponse }> => {
|
||||
const auth = await params.retrieveUserAuth()
|
||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||
let finalRoute = '/api/user/chain/new'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, {}, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.NewAddressResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
PayAddress: async (request: Types.PayAddressRequest): Promise<ResultError | { status: 'OK', result: Types.PayAddressResponse }> => {
|
||||
const auth = await params.retrieveUserAuth()
|
||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||
let finalRoute = '/api/user/chain/pay'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.PayAddressResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
NewInvoice: async (request: Types.NewInvoiceRequest): Promise<ResultError | { status: 'OK', result: Types.NewInvoiceResponse }> => {
|
||||
const auth = await params.retrieveUserAuth()
|
||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||
let finalRoute = '/api/user/invoice/new'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.NewInvoiceResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
PayInvoice: async (request: Types.PayInvoiceRequest): Promise<ResultError | { status: 'OK', result: Types.PayInvoiceResponse }> => {
|
||||
const auth = await params.retrieveUserAuth()
|
||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||
let finalRoute = '/api/user/invoice/pay'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.PayInvoiceResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
OpenChannel: async (request: Types.OpenChannelRequest): Promise<ResultError | { status: 'OK', result: Types.OpenChannelResponse }> => {
|
||||
const auth = await params.retrieveUserAuth()
|
||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||
let finalRoute = '/api/user/open/channel'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.OpenChannelResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
GetOpenChannelLNURL: async (): Promise<ResultError | { status: 'OK', result: Types.GetOpenChannelLNURLResponse }> => {
|
||||
const auth = await params.retrieveUserAuth()
|
||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||
let finalRoute = '/api/user/lnurl_channel'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, {}, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data.result
|
||||
const error = Types.GetOpenChannelLNURLResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', result: result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,34 +1,82 @@
|
|||
// This file was autogenerated from a .proto file, DO NOT EDIT!
|
||||
|
||||
export type NoAuthContext = {
|
||||
}
|
||||
export type GuestContext = {
|
||||
token: string
|
||||
}
|
||||
export type UserContext = {
|
||||
user_id: string
|
||||
}
|
||||
export type AdminContext = {
|
||||
pub: string
|
||||
admin_id: string
|
||||
}
|
||||
export type AuthContext = NoAuthContext | GuestContext | AdminContext
|
||||
export type AuthContext = GuestContext | UserContext | AdminContext
|
||||
|
||||
export type Health_Query = {
|
||||
}
|
||||
export type Health_RouteParams = {
|
||||
}
|
||||
export type Health_Context = Health_Query & Health_RouteParams & NoAuthContext
|
||||
export type Health_Context = Health_Query & Health_RouteParams & GuestContext
|
||||
export type EncryptionExchange_Query = {
|
||||
}
|
||||
export type EncryptionExchange_RouteParams = {
|
||||
}
|
||||
export type EncryptionExchange_Context = EncryptionExchange_Query & EncryptionExchange_RouteParams & NoAuthContext
|
||||
export type EncryptionExchange_Context = EncryptionExchange_Query & EncryptionExchange_RouteParams & GuestContext
|
||||
export type LndGetInfo_Query = {
|
||||
}
|
||||
export type LndGetInfo_RouteParams = {
|
||||
}
|
||||
export type LndGetInfo_Context = LndGetInfo_Query & LndGetInfo_RouteParams & NoAuthContext
|
||||
export type LndGetInfo_Context = LndGetInfo_Query & LndGetInfo_RouteParams & AdminContext
|
||||
export type AddUser_Query = {
|
||||
}
|
||||
export type AddUser_RouteParams = {
|
||||
}
|
||||
export type AddUser_Context = AddUser_Query & AddUser_RouteParams & GuestContext
|
||||
export type AuthUser_Query = {
|
||||
}
|
||||
export type AuthUser_RouteParams = {
|
||||
}
|
||||
export type AuthUser_Context = AuthUser_Query & AuthUser_RouteParams & GuestContext
|
||||
export type NewAddress_Query = {
|
||||
}
|
||||
export type NewAddress_RouteParams = {
|
||||
}
|
||||
export type NewAddress_Context = NewAddress_Query & NewAddress_RouteParams & UserContext
|
||||
export type PayAddress_Query = {
|
||||
}
|
||||
export type PayAddress_RouteParams = {
|
||||
}
|
||||
export type PayAddress_Context = PayAddress_Query & PayAddress_RouteParams & UserContext
|
||||
export type NewInvoice_Query = {
|
||||
}
|
||||
export type NewInvoice_RouteParams = {
|
||||
}
|
||||
export type NewInvoice_Context = NewInvoice_Query & NewInvoice_RouteParams & UserContext
|
||||
export type PayInvoice_Query = {
|
||||
}
|
||||
export type PayInvoice_RouteParams = {
|
||||
}
|
||||
export type PayInvoice_Context = PayInvoice_Query & PayInvoice_RouteParams & UserContext
|
||||
export type OpenChannel_Query = {
|
||||
}
|
||||
export type OpenChannel_RouteParams = {
|
||||
}
|
||||
export type OpenChannel_Context = OpenChannel_Query & OpenChannel_RouteParams & UserContext
|
||||
export type GetOpenChannelLNURL_Query = {
|
||||
}
|
||||
export type GetOpenChannelLNURL_RouteParams = {
|
||||
}
|
||||
export type GetOpenChannelLNURL_Context = GetOpenChannelLNURL_Query & GetOpenChannelLNURL_RouteParams & UserContext
|
||||
export type ServerMethods = {
|
||||
Health?: (ctx: Health_Context) => Promise<void>
|
||||
EncryptionExchange?: (ctx: EncryptionExchange_Context, req: EncryptionExchangeRequest) => Promise<void>
|
||||
LndGetInfo?: (ctx: LndGetInfo_Context) => Promise<LndGetInfoResponse>
|
||||
LndGetInfo?: (ctx: LndGetInfo_Context, req: LndGetInfoRequest) => Promise<LndGetInfoResponse>
|
||||
AddUser?: (ctx: AddUser_Context, req: AddUserRequest) => Promise<AddUserResponse>
|
||||
AuthUser?: (ctx: AuthUser_Context, req: AuthUserRequest) => Promise<AuthUserResponse>
|
||||
NewAddress?: (ctx: NewAddress_Context) => Promise<NewAddressResponse>
|
||||
PayAddress?: (ctx: PayAddress_Context, req: PayAddressRequest) => Promise<PayAddressResponse>
|
||||
NewInvoice?: (ctx: NewInvoice_Context, req: NewInvoiceRequest) => Promise<NewInvoiceResponse>
|
||||
PayInvoice?: (ctx: PayInvoice_Context, req: PayInvoiceRequest) => Promise<PayInvoiceResponse>
|
||||
OpenChannel?: (ctx: OpenChannel_Context, req: OpenChannelRequest) => Promise<OpenChannelResponse>
|
||||
GetOpenChannelLNURL?: (ctx: GetOpenChannelLNURL_Context) => Promise<GetOpenChannelLNURLResponse>
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -36,6 +84,178 @@ export type OptionsBaseMessage = {
|
|||
allOptionalsAreSet?: true
|
||||
}
|
||||
|
||||
export type AuthUserResponse = {
|
||||
user_id: string
|
||||
auth_token: string
|
||||
}
|
||||
export const AuthUserResponseOptionalFields: [] = []
|
||||
export type AuthUserResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
user_id_CustomCheck?: (v: string) => boolean
|
||||
auth_token_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.user_id !== 'string') return new Error(`${path}.user_id: is not a string`)
|
||||
if (opts.user_id_CustomCheck && !opts.user_id_CustomCheck(o.user_id)) return new Error(`${path}.user_id: custom check failed`)
|
||||
|
||||
if (typeof o.auth_token !== 'string') return new Error(`${path}.auth_token: is not a string`)
|
||||
if (opts.auth_token_CustomCheck && !opts.auth_token_CustomCheck(o.auth_token)) return new Error(`${path}.auth_token: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type PayAddressRequest = {
|
||||
address: string
|
||||
amout_sats: number
|
||||
}
|
||||
export const PayAddressRequestOptionalFields: [] = []
|
||||
export type PayAddressRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
address_CustomCheck?: (v: string) => boolean
|
||||
amout_sats_CustomCheck?: (v: number) => boolean
|
||||
}
|
||||
export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddressRequestOptions = {}, path: string = 'PayAddressRequest::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`)
|
||||
if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`)
|
||||
|
||||
if (typeof o.amout_sats !== 'number') return new Error(`${path}.amout_sats: is not a number`)
|
||||
if (opts.amout_sats_CustomCheck && !opts.amout_sats_CustomCheck(o.amout_sats)) return new Error(`${path}.amout_sats: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type PayAddressResponse = {
|
||||
tx_id: string
|
||||
}
|
||||
export const PayAddressResponseOptionalFields: [] = []
|
||||
export type PayAddressResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
tx_id_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.tx_id !== 'string') return new Error(`${path}.tx_id: is not a string`)
|
||||
if (opts.tx_id_CustomCheck && !opts.tx_id_CustomCheck(o.tx_id)) return new Error(`${path}.tx_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type OpenChannelResponse = {
|
||||
channel_id: string
|
||||
}
|
||||
export const OpenChannelResponseOptionalFields: [] = []
|
||||
export type OpenChannelResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
channel_id_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.channel_id !== 'string') return new Error(`${path}.channel_id: is not a string`)
|
||||
if (opts.channel_id_CustomCheck && !opts.channel_id_CustomCheck(o.channel_id)) return new Error(`${path}.channel_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type GetOpenChannelLNURLResponse = {
|
||||
lnurl: string
|
||||
}
|
||||
export const GetOpenChannelLNURLResponseOptionalFields: [] = []
|
||||
export type GetOpenChannelLNURLResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
lnurl_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const GetOpenChannelLNURLResponseValidate = (o?: GetOpenChannelLNURLResponse, opts: GetOpenChannelLNURLResponseOptions = {}, path: string = 'GetOpenChannelLNURLResponse::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`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type AddUserResponse = {
|
||||
user_id: string
|
||||
auth_token: string
|
||||
}
|
||||
export const AddUserResponseOptionalFields: [] = []
|
||||
export type AddUserResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
user_id_CustomCheck?: (v: string) => boolean
|
||||
auth_token_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const AddUserResponseValidate = (o?: AddUserResponse, opts: AddUserResponseOptions = {}, path: string = 'AddUserResponse::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.user_id !== 'string') return new Error(`${path}.user_id: is not a string`)
|
||||
if (opts.user_id_CustomCheck && !opts.user_id_CustomCheck(o.user_id)) return new Error(`${path}.user_id: custom check failed`)
|
||||
|
||||
if (typeof o.auth_token !== 'string') return new Error(`${path}.auth_token: is not a string`)
|
||||
if (opts.auth_token_CustomCheck && !opts.auth_token_CustomCheck(o.auth_token)) return new Error(`${path}.auth_token: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type 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 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 PayInvoiceRequest = {
|
||||
invoce: string
|
||||
}
|
||||
export const PayInvoiceRequestOptionalFields: [] = []
|
||||
export type PayInvoiceRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
invoce_CustomCheck?: (v: string) => 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.invoce !== 'string') return new Error(`${path}.invoce: is not a string`)
|
||||
if (opts.invoce_CustomCheck && !opts.invoce_CustomCheck(o.invoce)) return new Error(`${path}.invoce: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type LndGetInfoResponse = {
|
||||
alias: string
|
||||
}
|
||||
|
|
@ -54,16 +274,136 @@ export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetI
|
|||
return null
|
||||
}
|
||||
|
||||
export type Empty = {
|
||||
export type NewInvoiceResponse = {
|
||||
invoice: string
|
||||
}
|
||||
export const EmptyOptionalFields: [] = []
|
||||
export type EmptyOptions = OptionsBaseMessage & {
|
||||
export const NewInvoiceResponseOptionalFields: [] = []
|
||||
export type NewInvoiceResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
invoice_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const EmptyValidate = (o?: Empty, opts: EmptyOptions = {}, path: string = 'Empty::root.'): Error | null => {
|
||||
export const NewInvoiceResponseValidate = (o?: NewInvoiceResponse, opts: NewInvoiceResponseOptions = {}, path: string = 'NewInvoiceResponse::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`)
|
||||
if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type NewAddressResponse = {
|
||||
address: string
|
||||
}
|
||||
export const NewAddressResponseOptionalFields: [] = []
|
||||
export type NewAddressResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
address_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const NewAddressResponseValidate = (o?: NewAddressResponse, opts: NewAddressResponseOptions = {}, path: string = 'NewAddressResponse::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`)
|
||||
if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type NewInvoiceRequest = {
|
||||
amount_sats: number
|
||||
}
|
||||
export const NewInvoiceRequestOptionalFields: [] = []
|
||||
export type NewInvoiceRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
amount_sats_CustomCheck?: (v: number) => 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.amount_sats !== 'number') return new Error(`${path}.amount_sats: is not a number`)
|
||||
if (opts.amount_sats_CustomCheck && !opts.amount_sats_CustomCheck(o.amount_sats)) return new Error(`${path}.amount_sats: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type OpenChannelRequest = {
|
||||
destination: string
|
||||
channel_balance: number
|
||||
push_amount: number
|
||||
}
|
||||
export const OpenChannelRequestOptionalFields: [] = []
|
||||
export type OpenChannelRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
destination_CustomCheck?: (v: string) => boolean
|
||||
channel_balance_CustomCheck?: (v: number) => boolean
|
||||
push_amount_CustomCheck?: (v: number) => 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.channel_balance !== 'number') return new Error(`${path}.channel_balance: is not a number`)
|
||||
if (opts.channel_balance_CustomCheck && !opts.channel_balance_CustomCheck(o.channel_balance)) return new Error(`${path}.channel_balance: custom check failed`)
|
||||
|
||||
if (typeof o.push_amount !== 'number') return new Error(`${path}.push_amount: is not a number`)
|
||||
if (opts.push_amount_CustomCheck && !opts.push_amount_CustomCheck(o.push_amount)) return new Error(`${path}.push_amount: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export type AddUserRequest = {
|
||||
callback_url: string
|
||||
name: string
|
||||
secret: string
|
||||
}
|
||||
export const AddUserRequestOptionalFields: [] = []
|
||||
export type AddUserRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
callback_url_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.callback_url !== 'string') return new Error(`${path}.callback_url: is not a string`)
|
||||
if (opts.callback_url_CustomCheck && !opts.callback_url_CustomCheck(o.callback_url)) return new Error(`${path}.callback_url: 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 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
|
||||
}
|
||||
|
||||
|
|
@ -90,3 +430,21 @@ export const EncryptionExchangeRequestValidate = (o?: EncryptionExchangeRequest,
|
|||
return null
|
||||
}
|
||||
|
||||
export type LndGetInfoRequest = {
|
||||
node_id: number
|
||||
}
|
||||
export const LndGetInfoRequestOptionalFields: [] = []
|
||||
export type LndGetInfoRequestOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
node_id_CustomCheck?: (v: number) => boolean
|
||||
}
|
||||
export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInfoRequestOptions = {}, path: string = 'LndGetInfoRequest::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||
|
||||
if (typeof o.node_id !== 'number') return new Error(`${path}.node_id: is not a number`)
|
||||
if (opts.node_id_CustomCheck && !opts.node_id_CustomCheck(o.node_id)) return new Error(`${path}.node_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue