fix chan fees
This commit is contained in:
parent
bfa23681e6
commit
9034a62fe7
6 changed files with 2141 additions and 2141 deletions
|
|
@ -360,157 +360,30 @@ 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
|
||||||
|
|
||||||
### LnurlPayInfoResponse
|
|
||||||
- __tag__: _string_
|
|
||||||
- __callback__: _string_
|
|
||||||
- __maxSendable__: _number_
|
|
||||||
- __minSendable__: _number_
|
|
||||||
- __metadata__: _string_
|
|
||||||
|
|
||||||
### AddUserRequest
|
### AddUserRequest
|
||||||
- __callbackUrl__: _string_
|
- __callbackUrl__: _string_
|
||||||
- __name__: _string_
|
- __name__: _string_
|
||||||
- __secret__: _string_
|
- __secret__: _string_
|
||||||
|
|
||||||
### GetUserOperationsRequest
|
|
||||||
- __latestIncomingInvoice__: _number_
|
|
||||||
- __latestOutgoingInvoice__: _number_
|
|
||||||
- __latestIncomingTx__: _number_
|
|
||||||
- __latestOutgoingTx__: _number_
|
|
||||||
- __latestIncomingUserToUserPayment__: _number_
|
|
||||||
- __latestOutgoingUserToUserPayment__: _number_
|
|
||||||
|
|
||||||
### Empty
|
|
||||||
|
|
||||||
### AddAppUserRequest
|
|
||||||
- __identifier__: _string_
|
|
||||||
- __fail_if_exists__: _boolean_
|
|
||||||
- __balance__: _number_
|
|
||||||
|
|
||||||
### SetMockAppBalanceRequest
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### NewAddressRequest
|
|
||||||
- __addressType__: _[AddressType](#AddressType)_
|
|
||||||
|
|
||||||
### NewInvoiceRequest
|
|
||||||
- __amountSats__: _number_
|
|
||||||
- __memo__: _string_
|
|
||||||
|
|
||||||
### GetUserOperationsResponse
|
|
||||||
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
|
||||||
|
|
||||||
### Application
|
|
||||||
- __name__: _string_
|
|
||||||
- __id__: _string_
|
|
||||||
- __balance__: _number_
|
|
||||||
- __npub__: _string_
|
|
||||||
|
|
||||||
### AddAppInvoiceRequest
|
|
||||||
- __payer_identifier__: _string_
|
|
||||||
- __http_callback_url__: _string_
|
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
|
||||||
|
|
||||||
### GetAppUserLNURLInfoRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __base_url_override__: _string_
|
|
||||||
|
|
||||||
### AuthUserResponse
|
|
||||||
- __userId__: _string_
|
|
||||||
- __authToken__: _string_
|
|
||||||
|
|
||||||
### AddProductRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### EncryptionExchangeRequest
|
|
||||||
- __publicKey__: _string_
|
|
||||||
- __deviceId__: _string_
|
|
||||||
|
|
||||||
### AppUser
|
|
||||||
- __identifier__: _string_
|
|
||||||
- __info__: _[UserInfo](#UserInfo)_
|
|
||||||
- __max_withdrawable__: _number_
|
|
||||||
|
|
||||||
### DecodeInvoiceResponse
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### PayInvoiceRequest
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### AuthUserRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __secret__: _string_
|
|
||||||
|
|
||||||
### PayAddressResponse
|
|
||||||
- __txId__: _string_
|
|
||||||
|
|
||||||
### OpenChannelRequest
|
|
||||||
- __destination__: _string_
|
|
||||||
- __fundingAmount__: _number_
|
|
||||||
- __pushAmount__: _number_
|
|
||||||
- __closeAddress__: _string_
|
|
||||||
|
|
||||||
### LnurlLinkResponse
|
|
||||||
- __lnurl__: _string_
|
|
||||||
- __k1__: _string_
|
|
||||||
|
|
||||||
### SetMockInvoiceAsPaidRequest
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### AddAppUserInvoiceRequest
|
|
||||||
- __receiver_identifier__: _string_
|
|
||||||
- __payer_identifier__: _string_
|
|
||||||
- __http_callback_url__: _string_
|
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
|
||||||
|
|
||||||
### PayAppUserInvoiceRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### SendAppUserToAppPaymentRequest
|
|
||||||
- __from_user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### PayAddressRequest
|
|
||||||
- __address__: _string_
|
|
||||||
- __amoutSats__: _number_
|
|
||||||
- __targetConf__: _number_
|
|
||||||
|
|
||||||
### UserOperation
|
### UserOperation
|
||||||
- __paidAtUnix__: _number_
|
- __paidAtUnix__: _number_
|
||||||
- __type__: _[UserOperationType](#UserOperationType)_
|
- __type__: _[UserOperationType](#UserOperationType)_
|
||||||
- __inbound__: _boolean_
|
- __inbound__: _boolean_
|
||||||
- __amount__: _number_
|
- __amount__: _number_
|
||||||
|
|
||||||
### UserInfo
|
### LndGetInfoRequest
|
||||||
- __userId__: _string_
|
- __nodeId__: _number_
|
||||||
- __balance__: _number_
|
|
||||||
|
|
||||||
### Product
|
### NewInvoiceRequest
|
||||||
- __id__: _string_
|
- __amountSats__: _number_
|
||||||
- __name__: _string_
|
- __memo__: _string_
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### SendAppUserToAppUserPaymentRequest
|
### PayInvoiceResponse
|
||||||
- __from_user_identifier__: _string_
|
- __preimage__: _string_
|
||||||
- __to_user_identifier__: _string_
|
- __amount_paid__: _number_
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### SetMockAppUserBalanceRequest
|
### OpenChannelResponse
|
||||||
- __user_identifier__: _string_
|
- __channelId__: _string_
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### NewAddressResponse
|
|
||||||
- __address__: _string_
|
|
||||||
|
|
||||||
### LnurlWithdrawInfoResponse
|
### LnurlWithdrawInfoResponse
|
||||||
- __tag__: _string_
|
- __tag__: _string_
|
||||||
|
|
@ -526,55 +399,182 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __pr__: _string_
|
- __pr__: _string_
|
||||||
- __routes__: ARRAY of: _[Empty](#Empty)_
|
- __routes__: ARRAY of: _[Empty](#Empty)_
|
||||||
|
|
||||||
### AddUserResponse
|
|
||||||
- __userId__: _string_
|
|
||||||
- __authToken__: _string_
|
|
||||||
|
|
||||||
### UserOperations
|
### UserOperations
|
||||||
- __fromIndex__: _number_
|
- __fromIndex__: _number_
|
||||||
- __toIndex__: _number_
|
- __toIndex__: _number_
|
||||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||||
|
|
||||||
### AuthAppRequest
|
### PayInvoiceRequest
|
||||||
- __name__: _string_
|
|
||||||
- __allow_user_creation__: _boolean_ *this field is optional
|
|
||||||
|
|
||||||
### GetAppUserRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
|
|
||||||
### NewInvoiceResponse
|
|
||||||
- __invoice__: _string_
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
### DecodeInvoiceRequest
|
### AddUserResponse
|
||||||
- __invoice__: _string_
|
- __userId__: _string_
|
||||||
|
- __authToken__: _string_
|
||||||
|
|
||||||
### OpenChannelResponse
|
### AddAppUserRequest
|
||||||
- __channelId__: _string_
|
- __identifier__: _string_
|
||||||
|
- __fail_if_exists__: _boolean_
|
||||||
|
- __balance__: _number_
|
||||||
|
|
||||||
### AddAppRequest
|
### AddAppInvoiceRequest
|
||||||
- __name__: _string_
|
- __payer_identifier__: _string_
|
||||||
- __allow_user_creation__: _boolean_
|
- __http_callback_url__: _string_
|
||||||
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
|
### AddAppUserInvoiceRequest
|
||||||
|
- __receiver_identifier__: _string_
|
||||||
|
- __payer_identifier__: _string_
|
||||||
|
- __http_callback_url__: _string_
|
||||||
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
### PayAppUserInvoiceResponse
|
### PayAppUserInvoiceResponse
|
||||||
- __preimage__: _string_
|
- __preimage__: _string_
|
||||||
- __amount_paid__: _number_
|
- __amount_paid__: _number_
|
||||||
|
|
||||||
### PayInvoiceResponse
|
### SendAppUserToAppPaymentRequest
|
||||||
- __preimage__: _string_
|
- __from_user_identifier__: _string_
|
||||||
- __amount_paid__: _number_
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### NewAddressRequest
|
||||||
|
- __addressType__: _[AddressType](#AddressType)_
|
||||||
|
|
||||||
|
### UserInfo
|
||||||
|
- __userId__: _string_
|
||||||
|
- __balance__: _number_
|
||||||
|
|
||||||
|
### SetMockInvoiceAsPaidRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### SetMockAppBalanceRequest
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### AuthUserRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __secret__: _string_
|
||||||
|
|
||||||
|
### AuthUserResponse
|
||||||
|
- __userId__: _string_
|
||||||
|
- __authToken__: _string_
|
||||||
|
|
||||||
|
### Empty
|
||||||
|
|
||||||
|
### EncryptionExchangeRequest
|
||||||
|
- __publicKey__: _string_
|
||||||
|
- __deviceId__: _string_
|
||||||
|
|
||||||
|
### Application
|
||||||
|
- __name__: _string_
|
||||||
|
- __id__: _string_
|
||||||
|
- __balance__: _number_
|
||||||
|
- __npub__: _string_
|
||||||
|
|
||||||
|
### GetAppUserRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
|
||||||
|
### GetAppUserLNURLInfoRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __base_url_override__: _string_
|
||||||
|
|
||||||
|
### DecodeInvoiceRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
|
||||||
|
### AddAppRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __allow_user_creation__: _boolean_
|
||||||
|
|
||||||
|
### PayAddressResponse
|
||||||
|
- __txId__: _string_
|
||||||
|
|
||||||
|
### OpenChannelRequest
|
||||||
|
- __destination__: _string_
|
||||||
|
- __fundingAmount__: _number_
|
||||||
|
- __pushAmount__: _number_
|
||||||
|
- __closeAddress__: _string_
|
||||||
|
|
||||||
|
### GetUserOperationsRequest
|
||||||
|
- __latestIncomingInvoice__: _number_
|
||||||
|
- __latestOutgoingInvoice__: _number_
|
||||||
|
- __latestIncomingTx__: _number_
|
||||||
|
- __latestOutgoingTx__: _number_
|
||||||
|
- __latestIncomingUserToUserPayment__: _number_
|
||||||
|
- __latestOutgoingUserToUserPayment__: _number_
|
||||||
|
|
||||||
### GetProductBuyLinkResponse
|
### GetProductBuyLinkResponse
|
||||||
- __link__: _string_
|
- __link__: _string_
|
||||||
|
|
||||||
### LndGetInfoRequest
|
### AuthAppRequest
|
||||||
- __nodeId__: _number_
|
- __name__: _string_
|
||||||
|
- __allow_user_creation__: _boolean_ *this field is optional
|
||||||
|
|
||||||
|
### AppUser
|
||||||
|
- __identifier__: _string_
|
||||||
|
- __info__: _[UserInfo](#UserInfo)_
|
||||||
|
- __max_withdrawable__: _number_
|
||||||
|
|
||||||
|
### SetMockAppUserBalanceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### DecodeInvoiceResponse
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### Product
|
||||||
|
- __id__: _string_
|
||||||
|
- __name__: _string_
|
||||||
|
- __price_sats__: _number_
|
||||||
|
|
||||||
### LndGetInfoResponse
|
### LndGetInfoResponse
|
||||||
- __alias__: _string_
|
- __alias__: _string_
|
||||||
|
|
||||||
|
### SendAppUserToAppUserPaymentRequest
|
||||||
|
- __from_user_identifier__: _string_
|
||||||
|
- __to_user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### PayAddressRequest
|
||||||
|
- __address__: _string_
|
||||||
|
- __amoutSats__: _number_
|
||||||
|
- __satsPerVByte__: _number_
|
||||||
|
|
||||||
|
### NewInvoiceResponse
|
||||||
|
- __invoice__: _string_
|
||||||
|
|
||||||
|
### LnurlLinkResponse
|
||||||
|
- __lnurl__: _string_
|
||||||
|
- __k1__: _string_
|
||||||
|
|
||||||
### AuthApp
|
### AuthApp
|
||||||
- __app__: _[Application](#Application)_
|
- __app__: _[Application](#Application)_
|
||||||
- __auth_token__: _string_
|
- __auth_token__: _string_
|
||||||
|
|
||||||
|
### PayAppUserInvoiceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### NewAddressResponse
|
||||||
|
- __address__: _string_
|
||||||
|
|
||||||
|
### LnurlPayInfoResponse
|
||||||
|
- __tag__: _string_
|
||||||
|
- __callback__: _string_
|
||||||
|
- __maxSendable__: _number_
|
||||||
|
- __minSendable__: _number_
|
||||||
|
- __metadata__: _string_
|
||||||
|
|
||||||
|
### 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_
|
||||||
## Enums
|
## Enums
|
||||||
### The enumerators used in the messages
|
### The enumerators used in the messages
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -15,7 +15,7 @@ export type NostrRequest = {
|
||||||
export type NostrOptions = {
|
export type NostrOptions = {
|
||||||
logger?: Logger
|
logger?: Logger
|
||||||
throwErrors?: true
|
throwErrors?: true
|
||||||
NostrUserAuthGuard: (appId?: string, identifier?: string) => Promise<Types.UserContext>
|
NostrUserAuthGuard: (appId?:string, identifier?: string) => Promise<Types.UserContext>
|
||||||
}
|
}
|
||||||
const logErrorAndReturnResponse = (error: Error, response: string, res: NostrResponse, logger: Logger) => { logger.error(error.message || error); res({ status: 'ERROR', reason: response }) }
|
const logErrorAndReturnResponse = (error: Error, response: string, res: NostrResponse, logger: Logger) => { logger.error(error.message || error); res({ status: 'ERROR', reason: response }) }
|
||||||
export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
|
|
@ -29,8 +29,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.GetUserInfo({ ...authContext, ...query, ...params })
|
const response = await methods.GetUserInfo({ ...authContext, ...query, ...params })
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'AddProduct':
|
case 'AddProduct':
|
||||||
try {
|
try {
|
||||||
|
|
@ -42,8 +42,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.AddProduct({ ...authContext, ...query, ...params }, request)
|
const response = await methods.AddProduct({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'NewProductInvoice':
|
case 'NewProductInvoice':
|
||||||
try {
|
try {
|
||||||
|
|
@ -52,8 +52,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.NewProductInvoice({ ...authContext, ...query, ...params })
|
const response = await methods.NewProductInvoice({ ...authContext, ...query, ...params })
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'GetUserOperations':
|
case 'GetUserOperations':
|
||||||
try {
|
try {
|
||||||
|
|
@ -65,8 +65,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.GetUserOperations({ ...authContext, ...query, ...params }, request)
|
const response = await methods.GetUserOperations({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'NewAddress':
|
case 'NewAddress':
|
||||||
try {
|
try {
|
||||||
|
|
@ -78,8 +78,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.NewAddress({ ...authContext, ...query, ...params }, request)
|
const response = await methods.NewAddress({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'PayAddress':
|
case 'PayAddress':
|
||||||
try {
|
try {
|
||||||
|
|
@ -91,8 +91,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.PayAddress({ ...authContext, ...query, ...params }, request)
|
const response = await methods.PayAddress({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'NewInvoice':
|
case 'NewInvoice':
|
||||||
try {
|
try {
|
||||||
|
|
@ -104,8 +104,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.NewInvoice({ ...authContext, ...query, ...params }, request)
|
const response = await methods.NewInvoice({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'DecodeInvoice':
|
case 'DecodeInvoice':
|
||||||
try {
|
try {
|
||||||
|
|
@ -117,8 +117,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.DecodeInvoice({ ...authContext, ...query, ...params }, request)
|
const response = await methods.DecodeInvoice({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'PayInvoice':
|
case 'PayInvoice':
|
||||||
try {
|
try {
|
||||||
|
|
@ -130,8 +130,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.PayInvoice({ ...authContext, ...query, ...params }, request)
|
const response = await methods.PayInvoice({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'OpenChannel':
|
case 'OpenChannel':
|
||||||
try {
|
try {
|
||||||
|
|
@ -143,8 +143,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.OpenChannel({ ...authContext, ...query, ...params }, request)
|
const response = await methods.OpenChannel({ ...authContext, ...query, ...params }, request)
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'GetLnurlWithdrawLink':
|
case 'GetLnurlWithdrawLink':
|
||||||
try {
|
try {
|
||||||
|
|
@ -153,8 +153,8 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.GetLnurlWithdrawLink({ ...authContext, ...query, ...params })
|
const response = await methods.GetLnurlWithdrawLink({ ...authContext, ...query, ...params })
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
case 'GetLNURLChannelLink':
|
case 'GetLNURLChannelLink':
|
||||||
try {
|
try {
|
||||||
|
|
@ -163,10 +163,10 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const params = req.params
|
const params = req.params
|
||||||
const response = await methods.GetLNURLChannelLink({ ...authContext, ...query, ...params })
|
const response = await methods.GetLNURLChannelLink({ ...authContext, ...query, ...params })
|
||||||
res({ status: 'OK', ...response })
|
res({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 }
|
||||||
break
|
break
|
||||||
default: logger.error('unknown rpc call name from nostr event:' + req.rpcName)
|
default: logger.error('unknown rpc call name from nostr event:'+req.rpcName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -128,7 +128,7 @@ message NewAddressResponse{
|
||||||
message PayAddressRequest{
|
message PayAddressRequest{
|
||||||
string address = 1;
|
string address = 1;
|
||||||
int64 amoutSats = 2;
|
int64 amoutSats = 2;
|
||||||
int64 targetConf = 3;
|
int64 satsPerVByte = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PayAddressResponse{
|
message PayAddressResponse{
|
||||||
|
|
|
||||||
|
|
@ -148,9 +148,9 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async PayAddress(userId: string, req: Types.PayAddressRequest, linkedApplication?: Application): Promise<Types.PayAddressResponse> {
|
async PayAddress(userId: string, req: Types.PayAddressRequest, linkedApplication?: Application): Promise<Types.PayAddressResponse> {
|
||||||
const estimate = await this.lnd.EstimateChainFees(req.address, req.amoutSats, req.targetConf)
|
const estimate = await this.lnd.EstimateChainFees(req.address, req.amoutSats, 1)
|
||||||
const satPerVByte = Number(estimate.satPerVbyte)
|
const vBytes = Math.ceil(Number(estimate.feeSat / estimate.satPerVbyte))
|
||||||
const chainFees = Number(estimate.feeSat)
|
const chainFees = vBytes * req.satsPerVByte
|
||||||
const total = req.amoutSats + chainFees
|
const total = req.amoutSats + chainFees
|
||||||
if (!linkedApplication) {
|
if (!linkedApplication) {
|
||||||
throw new Error("only application operations are supported") // TODO - make this check obsolete
|
throw new Error("only application operations are supported") // TODO - make this check obsolete
|
||||||
|
|
@ -162,7 +162,7 @@ export default class {
|
||||||
await this.lockUserWithMinBalance(userId, total + serviceFee)
|
await this.lockUserWithMinBalance(userId, total + serviceFee)
|
||||||
let payment
|
let payment
|
||||||
try {
|
try {
|
||||||
payment = await this.lnd.PayAddress(req.address, req.amoutSats, satPerVByte)
|
payment = await this.lnd.PayAddress(req.address, req.amoutSats, req.satsPerVByte)
|
||||||
await this.storage.userStorage.UnlockUser(userId)
|
await this.storage.userStorage.UnlockUser(userId)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await this.storage.userStorage.UnlockUser(userId)
|
await this.storage.userStorage.UnlockUser(userId)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue