migrations and logs
This commit is contained in:
parent
db08370d5c
commit
03f803c4f4
11 changed files with 2353 additions and 2121 deletions
|
|
@ -85,6 +85,11 @@ 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: [LiveUserOperation](#LiveUserOperation)
|
- output: [LiveUserOperation](#LiveUserOperation)
|
||||||
|
|
||||||
|
- GetMigrationUpdate
|
||||||
|
- auth type: __User__
|
||||||
|
- This methods has an __empty__ __request__ body
|
||||||
|
- output: [MigrationUpdate](#MigrationUpdate)
|
||||||
|
|
||||||
# HTTP API DEFINITION
|
# HTTP API DEFINITION
|
||||||
|
|
||||||
## Supported HTTP Auths
|
## Supported HTTP Auths
|
||||||
|
|
@ -95,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
|
||||||
- __app_user_id__: _string_
|
|
||||||
- __user_id__: _string_
|
- __user_id__: _string_
|
||||||
- __app_id__: _string_
|
- __app_id__: _string_
|
||||||
|
- __app_user_id__: _string_
|
||||||
|
|
||||||
- __Admin__:
|
- __Admin__:
|
||||||
- expected context content
|
- expected context content
|
||||||
|
|
@ -369,33 +374,48 @@ 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: [LiveUserOperation](#LiveUserOperation)
|
- output: [LiveUserOperation](#LiveUserOperation)
|
||||||
|
|
||||||
|
- GetMigrationUpdate
|
||||||
|
- auth type: __User__
|
||||||
|
- http method: __post__
|
||||||
|
- http route: __/api/user/migrations/sub__
|
||||||
|
- This methods has an __empty__ __request__ body
|
||||||
|
- output: [MigrationUpdate](#MigrationUpdate)
|
||||||
|
|
||||||
# INPUTS AND OUTPUTS
|
# INPUTS AND OUTPUTS
|
||||||
|
|
||||||
## Messages
|
## Messages
|
||||||
### The content of requests and response from the methods
|
### The content of requests and response from the methods
|
||||||
|
|
||||||
### AddAppUserRequest
|
### Empty
|
||||||
- __identifier__: _string_
|
|
||||||
- __fail_if_exists__: _boolean_
|
|
||||||
- __balance__: _number_
|
|
||||||
|
|
||||||
### NewAddressResponse
|
### AddAppRequest
|
||||||
- __address__: _string_
|
|
||||||
|
|
||||||
### HandleLnurlPayResponse
|
|
||||||
- __pr__: _string_
|
|
||||||
- __routes__: ARRAY of: _[Empty](#Empty)_
|
|
||||||
|
|
||||||
### Application
|
|
||||||
- __name__: _string_
|
- __name__: _string_
|
||||||
- __id__: _string_
|
- __allow_user_creation__: _boolean_
|
||||||
- __balance__: _number_
|
|
||||||
- __npub__: _string_
|
|
||||||
|
|
||||||
### AppUser
|
### GetAppUserLNURLInfoRequest
|
||||||
- __identifier__: _string_
|
- __user_identifier__: _string_
|
||||||
- __info__: _[UserInfo](#UserInfo)_
|
- __base_url_override__: _string_
|
||||||
- __max_withdrawable__: _number_
|
|
||||||
|
### PayAddressRequest
|
||||||
|
- __address__: _string_
|
||||||
|
- __amoutSats__: _number_
|
||||||
|
- __satsPerVByte__: _number_
|
||||||
|
|
||||||
|
### OpenChannelResponse
|
||||||
|
- __channelId__: _string_
|
||||||
|
|
||||||
|
### MigrationUpdate
|
||||||
|
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
||||||
|
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
||||||
|
|
||||||
|
### AuthApp
|
||||||
|
- __app__: _[Application](#Application)_
|
||||||
|
- __auth_token__: _string_
|
||||||
|
|
||||||
|
### AddAppInvoiceRequest
|
||||||
|
- __payer_identifier__: _string_
|
||||||
|
- __http_callback_url__: _string_
|
||||||
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
### AddAppUserInvoiceRequest
|
### AddAppUserInvoiceRequest
|
||||||
- __receiver_identifier__: _string_
|
- __receiver_identifier__: _string_
|
||||||
|
|
@ -403,22 +423,39 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __http_callback_url__: _string_
|
- __http_callback_url__: _string_
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
### PayAddressResponse
|
### PayAppUserInvoiceRequest
|
||||||
- __txId__: _string_
|
- __user_identifier__: _string_
|
||||||
- __operation_id__: _string_
|
|
||||||
- __service_fee__: _number_
|
|
||||||
- __network_fee__: _number_
|
|
||||||
|
|
||||||
### AddAppRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __allow_user_creation__: _boolean_
|
|
||||||
|
|
||||||
### SetMockInvoiceAsPaidRequest
|
|
||||||
- __invoice__: _string_
|
- __invoice__: _string_
|
||||||
- __amount__: _number_
|
- __amount__: _number_
|
||||||
|
|
||||||
### GetAppUserRequest
|
### DecodeInvoiceRequest
|
||||||
- __user_identifier__: _string_
|
- __invoice__: _string_
|
||||||
|
|
||||||
|
### HandleLnurlPayResponse
|
||||||
|
- __pr__: _string_
|
||||||
|
- __routes__: ARRAY of: _[Empty](#Empty)_
|
||||||
|
|
||||||
|
### ClosureMigration
|
||||||
|
- __closes_at_unix__: _number_
|
||||||
|
|
||||||
|
### SendAppUserToAppUserPaymentRequest
|
||||||
|
- __from_user_identifier__: _string_
|
||||||
|
- __to_user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### SendAppUserToAppPaymentRequest
|
||||||
|
- __from_user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### SetMockAppBalanceRequest
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### NewAddressRequest
|
||||||
|
- __addressType__: _[AddressType](#AddressType)_
|
||||||
|
|
||||||
|
### NewInvoiceRequest
|
||||||
|
- __amountSats__: _number_
|
||||||
|
- __memo__: _string_
|
||||||
|
|
||||||
### DecodeInvoiceResponse
|
### DecodeInvoiceResponse
|
||||||
- __amount__: _number_
|
- __amount__: _number_
|
||||||
|
|
@ -430,44 +467,13 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __service_fee__: _number_
|
- __service_fee__: _number_
|
||||||
- __network_fee__: _number_
|
- __network_fee__: _number_
|
||||||
|
|
||||||
### OpenChannelRequest
|
### GetUserOperationsRequest
|
||||||
- __destination__: _string_
|
- __latestIncomingInvoice__: _number_
|
||||||
- __fundingAmount__: _number_
|
- __latestOutgoingInvoice__: _number_
|
||||||
- __pushAmount__: _number_
|
- __latestIncomingTx__: _number_
|
||||||
- __closeAddress__: _string_
|
- __latestOutgoingTx__: _number_
|
||||||
|
- __latestIncomingUserToUserPayment__: _number_
|
||||||
### LnurlWithdrawInfoResponse
|
- __latestOutgoingUserToUserPayment__: _number_
|
||||||
- __tag__: _string_
|
|
||||||
- __callback__: _string_
|
|
||||||
- __k1__: _string_
|
|
||||||
- __defaultDescription__: _string_
|
|
||||||
- __minWithdrawable__: _number_
|
|
||||||
- __maxWithdrawable__: _number_
|
|
||||||
- __balanceCheck__: _string_
|
|
||||||
- __payLink__: _string_
|
|
||||||
|
|
||||||
### GetUserOperationsResponse
|
|
||||||
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
|
||||||
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
|
||||||
|
|
||||||
### EncryptionExchangeRequest
|
|
||||||
- __publicKey__: _string_
|
|
||||||
- __deviceId__: _string_
|
|
||||||
|
|
||||||
### GetProductBuyLinkResponse
|
|
||||||
- __link__: _string_
|
|
||||||
|
|
||||||
### Product
|
|
||||||
- __id__: _string_
|
|
||||||
- __name__: _string_
|
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### DecodeInvoiceRequest
|
|
||||||
- __invoice__: _string_
|
|
||||||
|
|
||||||
### UserOperation
|
### UserOperation
|
||||||
- __paidAtUnix__: _number_
|
- __paidAtUnix__: _number_
|
||||||
|
|
@ -480,45 +486,48 @@ 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_
|
||||||
|
|
||||||
### AddProductRequest
|
### GetUserOperationsResponse
|
||||||
|
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
||||||
|
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
||||||
|
|
||||||
|
### RelaysMigration
|
||||||
|
- __relays__: ARRAY of: _string_
|
||||||
|
|
||||||
|
### EncryptionExchangeRequest
|
||||||
|
- __publicKey__: _string_
|
||||||
|
- __deviceId__: _string_
|
||||||
|
|
||||||
|
### AuthAppRequest
|
||||||
- __name__: _string_
|
- __name__: _string_
|
||||||
- __price_sats__: _number_
|
- __allow_user_creation__: _boolean_ *this field is optional
|
||||||
|
|
||||||
### SetMockAppUserBalanceRequest
|
### GetAppUserRequest
|
||||||
- __user_identifier__: _string_
|
- __user_identifier__: _string_
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### SendAppUserToAppUserPaymentRequest
|
|
||||||
- __from_user_identifier__: _string_
|
|
||||||
- __to_user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### LndGetInfoRequest
|
|
||||||
- __nodeId__: _number_
|
|
||||||
|
|
||||||
### NewInvoiceRequest
|
|
||||||
- __amountSats__: _number_
|
|
||||||
- __memo__: _string_
|
|
||||||
|
|
||||||
### PayInvoiceRequest
|
### PayInvoiceRequest
|
||||||
- __invoice__: _string_
|
- __invoice__: _string_
|
||||||
- __amount__: _number_
|
- __amount__: _number_
|
||||||
|
|
||||||
### OpenChannelResponse
|
|
||||||
- __channelId__: _string_
|
|
||||||
|
|
||||||
### LnurlLinkResponse
|
### LnurlLinkResponse
|
||||||
- __lnurl__: _string_
|
- __lnurl__: _string_
|
||||||
- __k1__: _string_
|
- __k1__: _string_
|
||||||
|
|
||||||
### LnurlPayInfoResponse
|
### AddProductRequest
|
||||||
- __tag__: _string_
|
- __name__: _string_
|
||||||
- __callback__: _string_
|
- __price_sats__: _number_
|
||||||
- __maxSendable__: _number_
|
|
||||||
- __minSendable__: _number_
|
### LndGetInfoRequest
|
||||||
- __metadata__: _string_
|
- __nodeId__: _number_
|
||||||
- __allowsNostr__: _boolean_
|
|
||||||
- __nostrPubkey__: _string_
|
### OpenChannelRequest
|
||||||
|
- __destination__: _string_
|
||||||
|
- __fundingAmount__: _number_
|
||||||
|
- __pushAmount__: _number_
|
||||||
|
- __closeAddress__: _string_
|
||||||
|
|
||||||
### UserInfo
|
### UserInfo
|
||||||
- __userId__: _string_
|
- __userId__: _string_
|
||||||
|
|
@ -530,61 +539,74 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __toIndex__: _number_
|
- __toIndex__: _number_
|
||||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||||
|
|
||||||
### Empty
|
### SetMockInvoiceAsPaidRequest
|
||||||
|
- __invoice__: _string_
|
||||||
### LiveUserOperation
|
|
||||||
- __operation__: _[UserOperation](#UserOperation)_
|
|
||||||
|
|
||||||
### SendAppUserToAppPaymentRequest
|
|
||||||
- __from_user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
- __amount__: _number_
|
||||||
|
|
||||||
### GetAppUserLNURLInfoRequest
|
### AppUser
|
||||||
- __user_identifier__: _string_
|
- __identifier__: _string_
|
||||||
- __base_url_override__: _string_
|
- __info__: _[UserInfo](#UserInfo)_
|
||||||
|
- __max_withdrawable__: _number_
|
||||||
|
|
||||||
### PayAddressRequest
|
### NewAddressResponse
|
||||||
- __address__: _string_
|
- __address__: _string_
|
||||||
- __amoutSats__: _number_
|
|
||||||
- __satsPerVByte__: _number_
|
### PayAddressResponse
|
||||||
|
- __txId__: _string_
|
||||||
|
- __operation_id__: _string_
|
||||||
|
- __service_fee__: _number_
|
||||||
|
- __network_fee__: _number_
|
||||||
|
|
||||||
### NewInvoiceResponse
|
### NewInvoiceResponse
|
||||||
- __invoice__: _string_
|
- __invoice__: _string_
|
||||||
|
|
||||||
### PayAppUserInvoiceRequest
|
### LnurlWithdrawInfoResponse
|
||||||
- __user_identifier__: _string_
|
- __tag__: _string_
|
||||||
- __invoice__: _string_
|
- __callback__: _string_
|
||||||
- __amount__: _number_
|
- __k1__: _string_
|
||||||
|
- __defaultDescription__: _string_
|
||||||
### AuthAppRequest
|
- __minWithdrawable__: _number_
|
||||||
- __name__: _string_
|
- __maxWithdrawable__: _number_
|
||||||
- __allow_user_creation__: _boolean_ *this field is optional
|
- __balanceCheck__: _string_
|
||||||
|
- __payLink__: _string_
|
||||||
### AuthApp
|
|
||||||
- __app__: _[Application](#Application)_
|
|
||||||
- __auth_token__: _string_
|
|
||||||
|
|
||||||
### AddAppInvoiceRequest
|
|
||||||
- __payer_identifier__: _string_
|
|
||||||
- __http_callback_url__: _string_
|
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
|
||||||
|
|
||||||
### SetMockAppBalanceRequest
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### NewAddressRequest
|
|
||||||
- __addressType__: _[AddressType](#AddressType)_
|
|
||||||
|
|
||||||
### GetUserOperationsRequest
|
|
||||||
- __latestIncomingInvoice__: _number_
|
|
||||||
- __latestOutgoingInvoice__: _number_
|
|
||||||
- __latestIncomingTx__: _number_
|
|
||||||
- __latestOutgoingTx__: _number_
|
|
||||||
- __latestIncomingUserToUserPayment__: _number_
|
|
||||||
- __latestOutgoingUserToUserPayment__: _number_
|
|
||||||
|
|
||||||
### LndGetInfoResponse
|
### LndGetInfoResponse
|
||||||
- __alias__: _string_
|
- __alias__: _string_
|
||||||
|
|
||||||
|
### AddAppUserRequest
|
||||||
|
- __identifier__: _string_
|
||||||
|
- __fail_if_exists__: _boolean_
|
||||||
|
- __balance__: _number_
|
||||||
|
|
||||||
|
### LnurlPayInfoResponse
|
||||||
|
- __tag__: _string_
|
||||||
|
- __callback__: _string_
|
||||||
|
- __maxSendable__: _number_
|
||||||
|
- __minSendable__: _number_
|
||||||
|
- __metadata__: _string_
|
||||||
|
- __allowsNostr__: _boolean_
|
||||||
|
- __nostrPubkey__: _string_
|
||||||
|
|
||||||
|
### Product
|
||||||
|
- __id__: _string_
|
||||||
|
- __name__: _string_
|
||||||
|
- __price_sats__: _number_
|
||||||
|
|
||||||
|
### Application
|
||||||
|
- __name__: _string_
|
||||||
|
- __id__: _string_
|
||||||
|
- __balance__: _number_
|
||||||
|
- __npub__: _string_
|
||||||
|
|
||||||
|
### SetMockAppUserBalanceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### GetProductBuyLinkResponse
|
||||||
|
- __link__: _string_
|
||||||
|
|
||||||
|
### 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
|
|
@ -520,4 +520,5 @@ export type MethodsOverride = {
|
||||||
GetLnurlPayLink_Override?: (httpRes:Response, handlerRes:Types.LnurlLinkResponse) => Promise<void>
|
GetLnurlPayLink_Override?: (httpRes:Response, handlerRes:Types.LnurlLinkResponse) => Promise<void>
|
||||||
GetLNURLChannelLink_Override?: (httpRes:Response, handlerRes:Types.LnurlLinkResponse) => Promise<void>
|
GetLNURLChannelLink_Override?: (httpRes:Response, handlerRes:Types.LnurlLinkResponse) => Promise<void>
|
||||||
GetLiveUserOperations_Override?: (httpRes:Response, handlerRes:Types.LiveUserOperation) => Promise<void>
|
GetLiveUserOperations_Override?: (httpRes:Response, handlerRes:Types.LiveUserOperation) => Promise<void>
|
||||||
|
GetMigrationUpdate_Override?: (httpRes:Response, handlerRes:Types.MigrationUpdate) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -478,4 +478,5 @@ export default (params: ClientParams) => ({
|
||||||
return { status: 'ERROR', reason: 'invalid response' }
|
return { status: 'ERROR', reason: 'invalid response' }
|
||||||
},
|
},
|
||||||
GetLiveUserOperations: async (cb: (v:ResultError | ({ status: 'OK' }& Types.LiveUserOperation)) => void): Promise<void> => { throw new Error('http streams are not supported')}
|
GetLiveUserOperations: async (cb: (v:ResultError | ({ status: 'OK' }& Types.LiveUserOperation)) => void): Promise<void> => { throw new Error('http streams are not supported')}
|
||||||
|
GetMigrationUpdate: async (cb: (v:ResultError | ({ status: 'OK' }& Types.MigrationUpdate)) => void): Promise<void> => { throw new Error('http streams are not supported')}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -215,4 +215,19 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
|
||||||
return cb({ status: 'ERROR', reason: 'invalid response' })
|
return cb({ status: 'ERROR', reason: 'invalid response' })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
GetMigrationUpdate: async (cb: (res:ResultError | ({ status: 'OK' }& Types.MigrationUpdate)) => void): Promise<void> => {
|
||||||
|
const auth = await params.retrieveNostrUserAuth()
|
||||||
|
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')
|
||||||
|
const nostrRequest: NostrRequest = {}
|
||||||
|
subscribe(params.pubDestination, {rpcName:'GetMigrationUpdate',authIdentifier:auth, ...nostrRequest }, (data) => {
|
||||||
|
if (data.status === 'ERROR' && typeof data.reason === 'string') return cb(data)
|
||||||
|
if (data.status === 'OK') {
|
||||||
|
const result = data
|
||||||
|
if(!params.checkResult) return cb({ status: 'OK', ...result })
|
||||||
|
const error = Types.MigrationUpdateValidate(result)
|
||||||
|
if (error === null) { return cb({ status: 'OK', ...result }) } else return cb({ status: 'ERROR', reason: error.message })
|
||||||
|
}
|
||||||
|
return cb({ status: 'ERROR', reason: 'invalid response' })
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,17 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
})
|
})
|
||||||
}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 'GetMigrationUpdate':
|
||||||
|
try {
|
||||||
|
if (!methods.GetMigrationUpdate) throw new Error('method: GetMigrationUpdate is not implemented')
|
||||||
|
const authContext = await opts.NostrUserAuthGuard(req.appId, req.authIdentifier)
|
||||||
|
const query = req.query
|
||||||
|
const params = req.params
|
||||||
|
methods.GetMigrationUpdate({ ...authContext, ...query, ...params }, (response, err) => {
|
||||||
|
if (err) { logErrorAndReturnResponse(err, err.message, res, logger)} else { res({status: 'OK', ...response})}
|
||||||
|
})
|
||||||
|
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
|
||||||
|
break
|
||||||
default: logger.error('unknown rpc call name from nostr event:'+req.rpcName)
|
default: logger.error('unknown rpc call name from nostr event:'+req.rpcName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -304,5 +304,11 @@ service LightningPub {
|
||||||
option (http_route) = "/api/user/operations/sub";
|
option (http_route) = "/api/user/operations/sub";
|
||||||
option (nostr) = true;
|
option (nostr) = true;
|
||||||
}
|
}
|
||||||
|
rpc GetMigrationUpdate(structs.Empty) returns (stream structs.MigrationUpdate){
|
||||||
|
option (auth_type) = "User";
|
||||||
|
option (http_method) = "post";
|
||||||
|
option (http_route) = "/api/user/migrations/sub";
|
||||||
|
option (nostr) = true;
|
||||||
|
}
|
||||||
// </User>
|
// </User>
|
||||||
}
|
}
|
||||||
|
|
@ -264,4 +264,16 @@ message GetProductBuyLinkResponse {
|
||||||
|
|
||||||
message LiveUserOperation {
|
message LiveUserOperation {
|
||||||
UserOperation operation = 1;
|
UserOperation operation = 1;
|
||||||
|
}
|
||||||
|
message MigrationUpdate {
|
||||||
|
optional ClosureMigration closure = 1;
|
||||||
|
optional RelaysMigration relays = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClosureMigration {
|
||||||
|
int64 closes_at_unix = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RelaysMigration {
|
||||||
|
repeated string relays = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -94,11 +94,12 @@ export default class {
|
||||||
const { blockHeight } = await this.lnd.GetInfo()
|
const { blockHeight } = await this.lnd.GetInfo()
|
||||||
const userAddress = await this.storage.paymentStorage.GetAddressOwner(address, tx)
|
const userAddress = await this.storage.paymentStorage.GetAddressOwner(address, tx)
|
||||||
if (!userAddress) { return }
|
if (!userAddress) { return }
|
||||||
const log = getLogger({})
|
let log = getLogger({})
|
||||||
if (!userAddress.linkedApplication) {
|
if (!userAddress.linkedApplication) {
|
||||||
log("ERROR", "an address was paid, that has no linked application")
|
log("ERROR", "an address was paid, that has no linked application")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log = getLogger({ appName: userAddress.linkedApplication.name })
|
||||||
const isAppUserPayment = userAddress.user.user_id !== userAddress.linkedApplication.owner.user_id
|
const isAppUserPayment = userAddress.user.user_id !== userAddress.linkedApplication.owner.user_id
|
||||||
let fee = this.paymentManager.getServiceFee(Types.UserOperationType.INCOMING_TX, amount, isAppUserPayment)
|
let fee = this.paymentManager.getServiceFee(Types.UserOperationType.INCOMING_TX, amount, isAppUserPayment)
|
||||||
if (userAddress.linkedApplication && userAddress.linkedApplication.owner.user_id === userAddress.user.user_id) {
|
if (userAddress.linkedApplication && userAddress.linkedApplication.owner.user_id === userAddress.user.user_id) {
|
||||||
|
|
@ -119,7 +120,7 @@ export default class {
|
||||||
|
|
||||||
invoicePaidCb: InvoicePaidCb = (paymentRequest, amount, internal) => {
|
invoicePaidCb: InvoicePaidCb = (paymentRequest, amount, internal) => {
|
||||||
this.storage.StartTransaction(async tx => {
|
this.storage.StartTransaction(async tx => {
|
||||||
const log = getLogger({})
|
let log = getLogger({})
|
||||||
const userInvoice = await this.storage.paymentStorage.GetInvoiceOwner(paymentRequest, tx)
|
const userInvoice = await this.storage.paymentStorage.GetInvoiceOwner(paymentRequest, tx)
|
||||||
if (!userInvoice) { return }
|
if (!userInvoice) { return }
|
||||||
if (userInvoice.paid_at_unix > 0 && internal) { log("cannot pay internally, invoice already paid"); return }
|
if (userInvoice.paid_at_unix > 0 && internal) { log("cannot pay internally, invoice already paid"); return }
|
||||||
|
|
@ -128,6 +129,7 @@ export default class {
|
||||||
log("ERROR", "an invoice was paid, that has no linked application")
|
log("ERROR", "an invoice was paid, that has no linked application")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log = getLogger({ appName: userInvoice.linkedApplication.name })
|
||||||
const isAppUserPayment = userInvoice.user.user_id !== userInvoice.linkedApplication.owner.user_id
|
const isAppUserPayment = userInvoice.user.user_id !== userInvoice.linkedApplication.owner.user_id
|
||||||
let fee = this.paymentManager.getServiceFee(Types.UserOperationType.INCOMING_INVOICE, amount, isAppUserPayment)
|
let fee = this.paymentManager.getServiceFee(Types.UserOperationType.INCOMING_INVOICE, amount, isAppUserPayment)
|
||||||
if (userInvoice.linkedApplication && userInvoice.linkedApplication.owner.user_id === userInvoice.user.user_id) {
|
if (userInvoice.linkedApplication && userInvoice.linkedApplication.owner.user_id === userInvoice.user.user_id) {
|
||||||
|
|
@ -167,7 +169,7 @@ export default class {
|
||||||
async sendOperationToNostr(app: Application, userId: string, op: Types.UserOperation) {
|
async sendOperationToNostr(app: Application, userId: string, op: Types.UserOperation) {
|
||||||
const user = await this.storage.applicationStorage.GetAppUserFromUser(app, userId)
|
const user = await this.storage.applicationStorage.GetAppUserFromUser(app, userId)
|
||||||
if (!user || !user.nostr_public_key) {
|
if (!user || !user.nostr_public_key) {
|
||||||
getLogger({})("cannot notify user, not a nostr user")
|
getLogger({ appName: app.name })("cannot notify user, not a nostr user")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const message: Types.LiveUserOperation & { requestId: string } = { operation: op, requestId: "GetLiveUserOperations" }
|
const message: Types.LiveUserOperation & { requestId: string } = { operation: op, requestId: "GetLiveUserOperations" }
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,8 @@ export default (mainHandler: Main): Types.ServerMethods => {
|
||||||
await mainHandler.applicationManager.SetMockAppBalance(ctx.app_id, req)
|
await mainHandler.applicationManager.SetMockAppBalance(ctx.app_id, req)
|
||||||
},
|
},
|
||||||
GetLiveUserOperations: async (ctx, cb) => {
|
GetLiveUserOperations: async (ctx, cb) => {
|
||||||
|
},
|
||||||
|
GetMigrationUpdate: async (ctx, cb) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue