ln address
This commit is contained in:
parent
d6633f8fd5
commit
3d4bd4be63
9 changed files with 2561 additions and 2465 deletions
|
|
@ -100,9 +100,9 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
|
|
||||||
- __User__:
|
- __User__:
|
||||||
- expected context content
|
- expected context content
|
||||||
- __user_id__: _string_
|
|
||||||
- __app_id__: _string_
|
- __app_id__: _string_
|
||||||
- __app_user_id__: _string_
|
- __app_user_id__: _string_
|
||||||
|
- __user_id__: _string_
|
||||||
|
|
||||||
- __Admin__:
|
- __Admin__:
|
||||||
- expected context content
|
- expected context content
|
||||||
|
|
@ -197,6 +197,15 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- This methods has an __empty__ __request__ body
|
- This methods has an __empty__ __request__ body
|
||||||
- output: [HandleLnurlPayResponse](#HandleLnurlPayResponse)
|
- output: [HandleLnurlPayResponse](#HandleLnurlPayResponse)
|
||||||
|
|
||||||
|
- HandleLnurlAddress
|
||||||
|
- auth type: __Guest__
|
||||||
|
- http method: __get__
|
||||||
|
- http route: __/.well-known/lnurlp/:address_name__
|
||||||
|
- the request url __params__ are the following string items:
|
||||||
|
- address_name
|
||||||
|
- This methods has an __empty__ __request__ body
|
||||||
|
- output: [LnurlPayInfoResponse](#LnurlPayInfoResponse)
|
||||||
|
|
||||||
- GetApp
|
- GetApp
|
||||||
- auth type: __App__
|
- auth type: __App__
|
||||||
- http method: __post__
|
- http method: __post__
|
||||||
|
|
@ -386,109 +395,48 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
## Messages
|
## Messages
|
||||||
### The content of requests and response from the methods
|
### The content of requests and response from the methods
|
||||||
|
|
||||||
### OpenChannelRequest
|
### PayAddressResponse
|
||||||
- __destination__: _string_
|
- __txId__: _string_
|
||||||
- __fundingAmount__: _number_
|
|
||||||
- __pushAmount__: _number_
|
|
||||||
- __closeAddress__: _string_
|
|
||||||
|
|
||||||
### HandleLnurlPayResponse
|
|
||||||
- __pr__: _string_
|
|
||||||
- __routes__: ARRAY of: _[Empty](#Empty)_
|
|
||||||
|
|
||||||
### GetUserOperationsResponse
|
|
||||||
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
|
||||||
|
|
||||||
### AddProductRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### NewAddressRequest
|
|
||||||
- __addressType__: _[AddressType](#AddressType)_
|
|
||||||
|
|
||||||
### NewInvoiceResponse
|
|
||||||
- __invoice__: _string_
|
|
||||||
|
|
||||||
### DecodeInvoiceResponse
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### PayInvoiceResponse
|
|
||||||
- __preimage__: _string_
|
|
||||||
- __amount_paid__: _number_
|
|
||||||
- __operation_id__: _string_
|
- __operation_id__: _string_
|
||||||
- __service_fee__: _number_
|
- __service_fee__: _number_
|
||||||
- __network_fee__: _number_
|
- __network_fee__: _number_
|
||||||
|
|
||||||
### EncryptionExchangeRequest
|
|
||||||
- __publicKey__: _string_
|
|
||||||
- __deviceId__: _string_
|
|
||||||
|
|
||||||
### AddAppRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __allow_user_creation__: _boolean_
|
|
||||||
|
|
||||||
### AddAppUserRequest
|
|
||||||
- __identifier__: _string_
|
|
||||||
- __fail_if_exists__: _boolean_
|
|
||||||
- __balance__: _number_
|
|
||||||
|
|
||||||
### UserInfo
|
|
||||||
- __userId__: _string_
|
|
||||||
- __balance__: _number_
|
|
||||||
- __max_withdrawable__: _number_
|
|
||||||
|
|
||||||
### GetUserOperationsRequest
|
|
||||||
- __latestIncomingInvoice__: _number_
|
|
||||||
- __latestOutgoingInvoice__: _number_
|
|
||||||
- __latestIncomingTx__: _number_
|
|
||||||
- __latestOutgoingTx__: _number_
|
|
||||||
- __latestIncomingUserToUserPayment__: _number_
|
|
||||||
- __latestOutgoingUserToUserPayment__: _number_
|
|
||||||
|
|
||||||
### GetProductBuyLinkResponse
|
|
||||||
- __link__: _string_
|
|
||||||
|
|
||||||
### LndGetInfoResponse
|
|
||||||
- __alias__: _string_
|
|
||||||
|
|
||||||
### GetAppUserRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
|
|
||||||
### NewInvoiceRequest
|
### NewInvoiceRequest
|
||||||
- __amountSats__: _number_
|
- __amountSats__: _number_
|
||||||
- __memo__: _string_
|
- __memo__: _string_
|
||||||
|
|
||||||
|
### UserOperations
|
||||||
|
- __fromIndex__: _number_
|
||||||
|
- __toIndex__: _number_
|
||||||
|
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||||
|
|
||||||
|
### AddProductRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __price_sats__: _number_
|
||||||
|
|
||||||
|
### EncryptionExchangeRequest
|
||||||
|
- __publicKey__: _string_
|
||||||
|
- __deviceId__: _string_
|
||||||
|
|
||||||
|
### AddAppInvoiceRequest
|
||||||
|
- __payer_identifier__: _string_
|
||||||
|
- __http_callback_url__: _string_
|
||||||
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
|
### PayAppUserInvoiceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### NewAddressResponse
|
||||||
|
- __address__: _string_
|
||||||
|
|
||||||
### LnurlLinkResponse
|
### LnurlLinkResponse
|
||||||
- __lnurl__: _string_
|
- __lnurl__: _string_
|
||||||
- __k1__: _string_
|
- __k1__: _string_
|
||||||
|
|
||||||
### SetMockInvoiceAsPaidRequest
|
### ClosureMigration
|
||||||
- __invoice__: _string_
|
- __closes_at_unix__: _number_
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### Application
|
|
||||||
- __name__: _string_
|
|
||||||
- __id__: _string_
|
|
||||||
- __balance__: _number_
|
|
||||||
- __npub__: _string_
|
|
||||||
|
|
||||||
### PayInvoiceRequest
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### RelaysMigration
|
|
||||||
- __relays__: ARRAY of: _string_
|
|
||||||
|
|
||||||
### LndGetInfoRequest
|
|
||||||
- __nodeId__: _number_
|
|
||||||
|
|
||||||
### NewAddressResponse
|
|
||||||
- __address__: _string_
|
|
||||||
|
|
||||||
### UserOperation
|
### UserOperation
|
||||||
- __paidAtUnix__: _number_
|
- __paidAtUnix__: _number_
|
||||||
|
|
@ -501,81 +449,15 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __network_fee__: _number_
|
- __network_fee__: _number_
|
||||||
- __confirmed__: _boolean_
|
- __confirmed__: _boolean_
|
||||||
|
|
||||||
### LiveUserOperation
|
### GetProductBuyLinkResponse
|
||||||
- __operation__: _[UserOperation](#UserOperation)_
|
- __link__: _string_
|
||||||
|
|
||||||
### UserOperations
|
### Empty
|
||||||
- __fromIndex__: _number_
|
|
||||||
- __toIndex__: _number_
|
|
||||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
|
||||||
|
|
||||||
### MigrationUpdate
|
|
||||||
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
|
||||||
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
|
||||||
|
|
||||||
### ClosureMigration
|
|
||||||
- __closes_at_unix__: _number_
|
|
||||||
|
|
||||||
### AuthAppRequest
|
### AuthAppRequest
|
||||||
- __name__: _string_
|
- __name__: _string_
|
||||||
- __allow_user_creation__: _boolean_ *this field is optional
|
- __allow_user_creation__: _boolean_ *this field is optional
|
||||||
|
|
||||||
### SendAppUserToAppPaymentRequest
|
|
||||||
- __from_user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### PayAddressResponse
|
|
||||||
- __txId__: _string_
|
|
||||||
- __operation_id__: _string_
|
|
||||||
- __service_fee__: _number_
|
|
||||||
- __network_fee__: _number_
|
|
||||||
|
|
||||||
### OpenChannelResponse
|
|
||||||
- __channelId__: _string_
|
|
||||||
|
|
||||||
### AddAppUserInvoiceRequest
|
|
||||||
- __receiver_identifier__: _string_
|
|
||||||
- __payer_identifier__: _string_
|
|
||||||
- __http_callback_url__: _string_
|
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
|
||||||
|
|
||||||
### SetMockAppBalanceRequest
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### LnurlPayInfoResponse
|
|
||||||
- __tag__: _string_
|
|
||||||
- __callback__: _string_
|
|
||||||
- __maxSendable__: _number_
|
|
||||||
- __minSendable__: _number_
|
|
||||||
- __metadata__: _string_
|
|
||||||
- __allowsNostr__: _boolean_
|
|
||||||
- __nostrPubkey__: _string_
|
|
||||||
|
|
||||||
### Product
|
|
||||||
- __id__: _string_
|
|
||||||
- __name__: _string_
|
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### PayAppUserInvoiceRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### SendAppUserToAppUserPaymentRequest
|
|
||||||
- __from_user_identifier__: _string_
|
|
||||||
- __to_user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### GetAppUserLNURLInfoRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __base_url_override__: _string_
|
|
||||||
|
|
||||||
### SetMockAppUserBalanceRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### Empty
|
|
||||||
|
|
||||||
### AuthApp
|
### AuthApp
|
||||||
- __app__: _[Application](#Application)_
|
- __app__: _[Application](#Application)_
|
||||||
- __auth_token__: _string_
|
- __auth_token__: _string_
|
||||||
|
|
@ -585,19 +467,113 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __info__: _[UserInfo](#UserInfo)_
|
- __info__: _[UserInfo](#UserInfo)_
|
||||||
- __max_withdrawable__: _number_
|
- __max_withdrawable__: _number_
|
||||||
|
|
||||||
### AddAppInvoiceRequest
|
### SendAppUserToAppPaymentRequest
|
||||||
|
- __from_user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### SetMockAppUserBalanceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### RelaysMigration
|
||||||
|
- __relays__: ARRAY of: _string_
|
||||||
|
|
||||||
|
### Application
|
||||||
|
- __name__: _string_
|
||||||
|
- __id__: _string_
|
||||||
|
- __balance__: _number_
|
||||||
|
- __npub__: _string_
|
||||||
|
|
||||||
|
### GetAppUserLNURLInfoRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __base_url_override__: _string_
|
||||||
|
|
||||||
|
### SetMockAppBalanceRequest
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### PayInvoiceResponse
|
||||||
|
- __preimage__: _string_
|
||||||
|
- __amount_paid__: _number_
|
||||||
|
- __operation_id__: _string_
|
||||||
|
- __service_fee__: _number_
|
||||||
|
- __network_fee__: _number_
|
||||||
|
|
||||||
|
### OpenChannelResponse
|
||||||
|
- __channelId__: _string_
|
||||||
|
|
||||||
|
### LnurlPayInfoResponse
|
||||||
|
- __tag__: _string_
|
||||||
|
- __callback__: _string_
|
||||||
|
- __maxSendable__: _number_
|
||||||
|
- __minSendable__: _number_
|
||||||
|
- __metadata__: _string_
|
||||||
|
- __allowsNostr__: _boolean_
|
||||||
|
- __nostrPubkey__: _string_
|
||||||
|
|
||||||
|
### AddAppRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __allow_user_creation__: _boolean_
|
||||||
|
|
||||||
|
### AddAppUserRequest
|
||||||
|
- __identifier__: _string_
|
||||||
|
- __fail_if_exists__: _boolean_
|
||||||
|
- __balance__: _number_
|
||||||
|
|
||||||
|
### NewAddressRequest
|
||||||
|
- __addressType__: _[AddressType](#AddressType)_
|
||||||
|
|
||||||
|
### PayInvoiceRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### OpenChannelRequest
|
||||||
|
- __destination__: _string_
|
||||||
|
- __fundingAmount__: _number_
|
||||||
|
- __pushAmount__: _number_
|
||||||
|
- __closeAddress__: _string_
|
||||||
|
|
||||||
|
### GetUserOperationsRequest
|
||||||
|
- __latestIncomingInvoice__: _number_
|
||||||
|
- __latestOutgoingInvoice__: _number_
|
||||||
|
- __latestIncomingTx__: _number_
|
||||||
|
- __latestOutgoingTx__: _number_
|
||||||
|
- __latestIncomingUserToUserPayment__: _number_
|
||||||
|
- __latestOutgoingUserToUserPayment__: _number_
|
||||||
|
|
||||||
|
### Product
|
||||||
|
- __id__: _string_
|
||||||
|
- __name__: _string_
|
||||||
|
- __price_sats__: _number_
|
||||||
|
|
||||||
|
### SetMockInvoiceAsPaidRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### AddAppUserInvoiceRequest
|
||||||
|
- __receiver_identifier__: _string_
|
||||||
- __payer_identifier__: _string_
|
- __payer_identifier__: _string_
|
||||||
- __http_callback_url__: _string_
|
- __http_callback_url__: _string_
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
### PayAddressRequest
|
### SendAppUserToAppUserPaymentRequest
|
||||||
- __address__: _string_
|
- __from_user_identifier__: _string_
|
||||||
- __amoutSats__: _number_
|
- __to_user_identifier__: _string_
|
||||||
- __satsPerVByte__: _number_
|
- __amount__: _number_
|
||||||
|
|
||||||
### DecodeInvoiceRequest
|
### DecodeInvoiceRequest
|
||||||
- __invoice__: _string_
|
- __invoice__: _string_
|
||||||
|
|
||||||
|
### DecodeInvoiceResponse
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### UserInfo
|
||||||
|
- __userId__: _string_
|
||||||
|
- __balance__: _number_
|
||||||
|
- __max_withdrawable__: _number_
|
||||||
|
|
||||||
|
### NewInvoiceResponse
|
||||||
|
- __invoice__: _string_
|
||||||
|
|
||||||
### LnurlWithdrawInfoResponse
|
### LnurlWithdrawInfoResponse
|
||||||
- __tag__: _string_
|
- __tag__: _string_
|
||||||
- __callback__: _string_
|
- __callback__: _string_
|
||||||
|
|
@ -607,6 +583,39 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __maxWithdrawable__: _number_
|
- __maxWithdrawable__: _number_
|
||||||
- __balanceCheck__: _string_
|
- __balanceCheck__: _string_
|
||||||
- __payLink__: _string_
|
- __payLink__: _string_
|
||||||
|
|
||||||
|
### HandleLnurlPayResponse
|
||||||
|
- __pr__: _string_
|
||||||
|
- __routes__: ARRAY of: _[Empty](#Empty)_
|
||||||
|
|
||||||
|
### MigrationUpdate
|
||||||
|
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
||||||
|
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
||||||
|
|
||||||
|
### LndGetInfoRequest
|
||||||
|
- __nodeId__: _number_
|
||||||
|
|
||||||
|
### LndGetInfoResponse
|
||||||
|
- __alias__: _string_
|
||||||
|
|
||||||
|
### GetAppUserRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
|
||||||
|
### PayAddressRequest
|
||||||
|
- __address__: _string_
|
||||||
|
- __amoutSats__: _number_
|
||||||
|
- __satsPerVByte__: _number_
|
||||||
|
|
||||||
|
### GetUserOperationsResponse
|
||||||
|
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
||||||
|
|
||||||
|
### LiveUserOperation
|
||||||
|
- __operation__: _[UserOperation](#UserOperation)_
|
||||||
## Enums
|
## Enums
|
||||||
### The enumerators used in the messages
|
### The enumerators used in the messages
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -156,6 +156,17 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
|
||||||
if (overrides.HandleLnurlPay_Override) await overrides.HandleLnurlPay_Override(res, response); else res.json({status: 'OK', ...response})
|
if (overrides.HandleLnurlPay_Override) await overrides.HandleLnurlPay_Override(res, response); else res.json({status: 'OK', ...response})
|
||||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||||
})
|
})
|
||||||
|
if (!opts.allowNotImplementedMethods && !methods.HandleLnurlAddress) throw new Error('method: HandleLnurlAddress is not implemented')
|
||||||
|
app.get('/.well-known/lnurlp/:address_name', async (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!methods.HandleLnurlAddress) throw new Error('method: HandleLnurlAddress is not implemented')
|
||||||
|
const authContext = await opts.GuestAuthGuard(req.headers['authorization'])
|
||||||
|
const query = req.query
|
||||||
|
const params = req.params
|
||||||
|
const response = await methods.HandleLnurlAddress({ ...authContext, ...query, ...params })
|
||||||
|
if (overrides.HandleLnurlAddress_Override) await overrides.HandleLnurlAddress_Override(res, response); else 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.GetApp) throw new Error('method: GetApp is not implemented')
|
if (!opts.allowNotImplementedMethods && !methods.GetApp) throw new Error('method: GetApp is not implemented')
|
||||||
app.post('/api/app/get', async (req, res) => {
|
app.post('/api/app/get', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -495,6 +506,7 @@ export type MethodsOverride = {
|
||||||
HandleLnurlWithdraw_Override?: (httpRes:Response) => Promise<void>
|
HandleLnurlWithdraw_Override?: (httpRes:Response) => Promise<void>
|
||||||
GetLnurlPayInfo_Override?: (httpRes:Response, handlerRes:Types.LnurlPayInfoResponse) => Promise<void>
|
GetLnurlPayInfo_Override?: (httpRes:Response, handlerRes:Types.LnurlPayInfoResponse) => Promise<void>
|
||||||
HandleLnurlPay_Override?: (httpRes:Response, handlerRes:Types.HandleLnurlPayResponse) => Promise<void>
|
HandleLnurlPay_Override?: (httpRes:Response, handlerRes:Types.HandleLnurlPayResponse) => Promise<void>
|
||||||
|
HandleLnurlAddress_Override?: (httpRes:Response, handlerRes:Types.LnurlPayInfoResponse) => Promise<void>
|
||||||
GetApp_Override?: (httpRes:Response, handlerRes:Types.Application) => Promise<void>
|
GetApp_Override?: (httpRes:Response, handlerRes:Types.Application) => Promise<void>
|
||||||
AddAppUser_Override?: (httpRes:Response, handlerRes:Types.AppUser) => Promise<void>
|
AddAppUser_Override?: (httpRes:Response, handlerRes:Types.AppUser) => Promise<void>
|
||||||
AddAppInvoice_Override?: (httpRes:Response, handlerRes:Types.NewInvoiceResponse) => Promise<void>
|
AddAppInvoice_Override?: (httpRes:Response, handlerRes:Types.NewInvoiceResponse) => Promise<void>
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,21 @@ export default (params: ClientParams) => ({
|
||||||
}
|
}
|
||||||
return { status: 'ERROR', reason: 'invalid response' }
|
return { status: 'ERROR', reason: 'invalid response' }
|
||||||
},
|
},
|
||||||
|
HandleLnurlAddress: async (routeParams: Types.HandleLnurlAddress_RouteParams): Promise<ResultError | ({ status: 'OK' }& Types.LnurlPayInfoResponse)> => {
|
||||||
|
const auth = await params.retrieveGuestAuth()
|
||||||
|
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
|
||||||
|
let finalRoute = '/.well-known/lnurlp/:address_name'
|
||||||
|
finalRoute = finalRoute.replace(':address_name', routeParams['address_name'])
|
||||||
|
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') {
|
||||||
|
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' }
|
||||||
|
},
|
||||||
GetApp: async (): Promise<ResultError | ({ status: 'OK' }& Types.Application)> => {
|
GetApp: async (): Promise<ResultError | ({ status: 'OK' }& Types.Application)> => {
|
||||||
const auth = await params.retrieveAppAuth()
|
const auth = await params.retrieveAppAuth()
|
||||||
if (auth === null) throw new Error('retrieveAppAuth() returned null')
|
if (auth === null) throw new Error('retrieveAppAuth() returned null')
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -138,6 +138,11 @@ service LightningPub {
|
||||||
option (http_route) = "/api/guest/lnurl_pay/handle";
|
option (http_route) = "/api/guest/lnurl_pay/handle";
|
||||||
option (query) = {items: ["k1", "amount", "nostr", "lnurl"]};
|
option (query) = {items: ["k1", "amount", "nostr", "lnurl"]};
|
||||||
}
|
}
|
||||||
|
rpc HandleLnurlAddress(structs.Empty)returns (structs.LnurlPayInfoResponse) {
|
||||||
|
option (auth_type) = "Guest";
|
||||||
|
option (http_method) = "get";
|
||||||
|
option (http_route) = "/.well-known/lnurlp/:address_name";
|
||||||
|
}
|
||||||
//</Guest>
|
//</Guest>
|
||||||
|
|
||||||
// <App>
|
// <App>
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,14 @@ export default class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async HandleLnurlAddress(ctx: Types.HandleLnurlAddress_Context): Promise<Types.LnurlPayInfoResponse> {
|
||||||
|
const linkedUser = await this.storage.applicationStorage.FindNostrAppUser(ctx.address_name)
|
||||||
|
if (!linkedUser) {
|
||||||
|
throw new Error("this address is not linked to any user")
|
||||||
|
}
|
||||||
|
return this.GetLnurlPayInfoFromUser(linkedUser.user.user_id, linkedUser.application)
|
||||||
|
}
|
||||||
|
|
||||||
async OpenChannel(userId: string, req: Types.OpenChannelRequest): Promise<Types.OpenChannelResponse> { throw new Error("WIP") }
|
async OpenChannel(userId: string, req: Types.OpenChannelRequest): Promise<Types.OpenChannelResponse> { throw new Error("WIP") }
|
||||||
|
|
||||||
mapOperations(operations: UserOperationInfo[], type: Types.UserOperationType, inbound: boolean): Types.UserOperations {
|
mapOperations(operations: UserOperationInfo[], type: Types.UserOperationType, inbound: boolean): Types.UserOperations {
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,12 @@ export default (mainHandler: Main): Types.ServerMethods => {
|
||||||
HandleLnurlPay: async (ctx) => {
|
HandleLnurlPay: async (ctx) => {
|
||||||
return mainHandler.paymentManager.HandleLnurlPay(ctx)
|
return mainHandler.paymentManager.HandleLnurlPay(ctx)
|
||||||
},
|
},
|
||||||
|
HandleLnurlAddress: async (ctx) => {
|
||||||
|
if (!ctx.address_name) {
|
||||||
|
throw new Error("invalid address_name to lnurl address")
|
||||||
|
}
|
||||||
|
return mainHandler.paymentManager.HandleLnurlAddress(ctx)
|
||||||
|
},
|
||||||
AddProduct: async (ctx, req) => {
|
AddProduct: async (ctx, req) => {
|
||||||
return mainHandler.productManager.AddProduct(ctx.user_id, req)
|
return mainHandler.productManager.AddProduct(ctx.user_id, req)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ export default class {
|
||||||
if (!nostrPub) {
|
if (!nostrPub) {
|
||||||
throw new Error("no nostrPub provided")
|
throw new Error("no nostrPub provided")
|
||||||
}
|
}
|
||||||
const user = await entityManager.getRepository(ApplicationUser).findOne({ where: { application: { serial_id: application.serial_id }, nostr_public_key: nostrPub } })
|
const user = await entityManager.getRepository(ApplicationUser).findOne({ where: { nostr_public_key: nostrPub } })
|
||||||
if (user) {
|
if (user) {
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
@ -98,6 +98,10 @@ export default class {
|
||||||
return this.AddApplicationUser(application, crypto.randomBytes(32).toString('hex'), 0, nostrPub)
|
return this.AddApplicationUser(application, crypto.randomBytes(32).toString('hex'), 0, nostrPub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async FindNostrAppUser(nostrPub: string, entityManager = this.DB) {
|
||||||
|
return entityManager.getRepository(ApplicationUser).findOne({ where: { nostr_public_key: nostrPub } })
|
||||||
|
}
|
||||||
|
|
||||||
async GetOrCreateApplicationUser(application: Application, userIdentifier: string, balance: number, entityManager = this.DB): Promise<{ user: ApplicationUser, created: boolean }> {
|
async GetOrCreateApplicationUser(application: Application, userIdentifier: string, balance: number, entityManager = this.DB): Promise<{ user: ApplicationUser, created: boolean }> {
|
||||||
const user = await this.GetApplicationUserIfExists(application, userIdentifier, entityManager)
|
const user = await this.GetApplicationUserIfExists(application, userIdentifier, entityManager)
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue