lnurl pay info
This commit is contained in:
parent
6382cce337
commit
c5ea8c899d
9 changed files with 2043 additions and 1919 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -191,6 +191,20 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
|
|||
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.GetAppUserLNURLInfo) throw new Error('method: GetAppUserLNURLInfo is not implemented')
|
||||
app.post('/api/app/user/lnurl/pay/info', async (req, res) => {
|
||||
try {
|
||||
if (!methods.GetAppUserLNURLInfo) throw new Error('method: GetAppUserLNURLInfo is not implemented')
|
||||
const authContext = await opts.AppAuthGuard(req.headers['authorization'])
|
||||
const request = req.body
|
||||
const error = Types.GetAppUserLNURLInfoRequestValidate(request)
|
||||
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
|
||||
const query = req.query
|
||||
const params = req.params
|
||||
const response = await methods.GetAppUserLNURLInfo({ ...authContext, ...query, ...params }, request)
|
||||
res.json({status: 'OK', ...response})
|
||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||
})
|
||||
if (!opts.allowNotImplementedMethods && !methods.AddUser) throw new Error('method: AddUser is not implemented')
|
||||
app.post('/api/user/add', async (req, res) => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -168,6 +168,20 @@ export default (params: ClientParams) => ({
|
|||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
GetAppUserLNURLInfo: async (request: Types.GetAppUserLNURLInfoRequest): Promise<ResultError | ({ status: 'OK' }& Types.LnurlPayInfoResponse)> => {
|
||||
const auth = await params.retrieveAppAuth()
|
||||
if (auth === null) throw new Error('retrieveAppAuth() returned null')
|
||||
let finalRoute = '/api/app/user/lnurl/pay/info'
|
||||
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||
if (data.status === 'OK') {
|
||||
const result = data
|
||||
if(!params.checkResult) return { status: 'OK', ...result }
|
||||
const error = Types.LnurlPayInfoResponseValidate(result)
|
||||
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
|
||||
}
|
||||
return { status: 'ERROR', reason: 'invalid response' }
|
||||
},
|
||||
AddUser: async (request: Types.AddUserRequest): Promise<ResultError | ({ status: 'OK' }& Types.AddUserResponse)> => {
|
||||
const auth = await params.retrieveGuestAuth()
|
||||
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -144,6 +144,12 @@ service LightningPub {
|
|||
option (http_route) = "/api/app/internal/pay";
|
||||
}
|
||||
|
||||
rpc GetAppUserLNURLInfo(structs.GetAppUserLNURLInfoRequest) returns (structs.LnurlPayInfoResponse) {
|
||||
option (auth_type) = "App";
|
||||
option (http_method) = "post";
|
||||
option (http_route) = "/api/app/user/lnurl/pay/info";
|
||||
}
|
||||
|
||||
// </App>
|
||||
|
||||
rpc AddUser(structs.AddUserRequest)returns (structs.AddUserResponse){
|
||||
|
|
|
|||
|
|
@ -87,6 +87,10 @@ message SendAppUserToAppPaymentRequest {
|
|||
int64 amount = 2;
|
||||
}
|
||||
|
||||
message GetAppUserLNURLInfoRequest {
|
||||
string user_identifier = 1;
|
||||
}
|
||||
|
||||
enum AddressType {
|
||||
WITNESS_PUBKEY_HASH = 0;
|
||||
NESTED_PUBKEY_HASH = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue