get seed endpoint
This commit is contained in:
parent
2badf5f468
commit
91c330a8bb
16 changed files with 4812 additions and 4631 deletions
|
|
@ -33,6 +33,11 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- input: [BanUserRequest](#BanUserRequest)
|
- input: [BanUserRequest](#BanUserRequest)
|
||||||
- output: [BanUserResponse](#BanUserResponse)
|
- output: [BanUserResponse](#BanUserResponse)
|
||||||
|
|
||||||
|
- GetSeed
|
||||||
|
- auth type: __Admin__
|
||||||
|
- This methods has an __empty__ __request__ body
|
||||||
|
- output: [LndSeed](#LndSeed)
|
||||||
|
|
||||||
- GetUsageMetrics
|
- GetUsageMetrics
|
||||||
- auth type: __Metrics__
|
- auth type: __Metrics__
|
||||||
- This methods has an __empty__ __request__ body
|
- This methods has an __empty__ __request__ body
|
||||||
|
|
@ -180,9 +185,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
|
||||||
|
|
@ -198,8 +203,8 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
|
|
||||||
- __GuestWithPub__:
|
- __GuestWithPub__:
|
||||||
- expected context content
|
- expected context content
|
||||||
- __pub__: _string_
|
|
||||||
- __app_id__: _string_
|
- __app_id__: _string_
|
||||||
|
- __pub__: _string_
|
||||||
|
|
||||||
## HTTP Methods
|
## HTTP Methods
|
||||||
### These are the http methods the client implements to communicate with the API
|
### These are the http methods the client implements to communicate with the API
|
||||||
|
|
@ -232,6 +237,13 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- input: [BanUserRequest](#BanUserRequest)
|
- input: [BanUserRequest](#BanUserRequest)
|
||||||
- output: [BanUserResponse](#BanUserResponse)
|
- output: [BanUserResponse](#BanUserResponse)
|
||||||
|
|
||||||
|
- GetSeed
|
||||||
|
- auth type: __Admin__
|
||||||
|
- http method: __get__
|
||||||
|
- http route: __/api/admin/seed__
|
||||||
|
- This methods has an __empty__ __request__ body
|
||||||
|
- output: [LndSeed](#LndSeed)
|
||||||
|
|
||||||
- GetUsageMetrics
|
- GetUsageMetrics
|
||||||
- auth type: __Metrics__
|
- auth type: __Metrics__
|
||||||
- http method: __post__
|
- http method: __post__
|
||||||
|
|
@ -589,14 +601,131 @@ 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
|
### AppsMetricsRequest
|
||||||
- __allowsNostr__: _boolean_
|
- __from_unix__: _number_ *this field is optional
|
||||||
- __nostrPubkey__: _string_
|
- __to_unix__: _number_ *this field is optional
|
||||||
- __tag__: _string_
|
- __include_operations__: _boolean_ *this field is optional
|
||||||
- __callback__: _string_
|
|
||||||
- __maxSendable__: _number_
|
### SetMockAppBalanceRequest
|
||||||
- __minSendable__: _number_
|
- __amount__: _number_
|
||||||
- __metadata__: _string_
|
|
||||||
|
### NewAddressResponse
|
||||||
|
- __address__: _string_
|
||||||
|
|
||||||
|
### PayAddressResponse
|
||||||
|
- __txId__: _string_
|
||||||
|
- __operation_id__: _string_
|
||||||
|
- __service_fee__: _number_
|
||||||
|
- __network_fee__: _number_
|
||||||
|
|
||||||
|
### HandleLnurlPayResponse
|
||||||
|
- __pr__: _string_
|
||||||
|
- __routes__: ARRAY of: _[Empty](#Empty)_
|
||||||
|
|
||||||
|
### GetProductBuyLinkResponse
|
||||||
|
- __link__: _string_
|
||||||
|
|
||||||
|
### UsageMetric
|
||||||
|
- __parsed_in_nano__: _number_
|
||||||
|
- __validate_in_nano__: _number_
|
||||||
|
- __handle_in_nano__: _number_
|
||||||
|
- __batch__: _boolean_
|
||||||
|
- __nostr__: _boolean_
|
||||||
|
- __batch_size__: _number_
|
||||||
|
- __processed_at_ms__: _number_
|
||||||
|
- __auth_in_nano__: _number_
|
||||||
|
- __rpc_name__: _string_
|
||||||
|
|
||||||
|
### AppMetrics
|
||||||
|
- __app__: _[Application](#Application)_
|
||||||
|
- __users__: _[UsersInfo](#UsersInfo)_
|
||||||
|
- __received__: _number_
|
||||||
|
- __total_fees__: _number_
|
||||||
|
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||||
|
- __spent__: _number_
|
||||||
|
- __available__: _number_
|
||||||
|
- __fees__: _number_
|
||||||
|
- __invoices__: _number_
|
||||||
|
|
||||||
|
### LndMetrics
|
||||||
|
- __nodes__: ARRAY of: _[LndNodeMetrics](#LndNodeMetrics)_
|
||||||
|
|
||||||
|
### Application
|
||||||
|
- __balance__: _number_
|
||||||
|
- __npub__: _string_
|
||||||
|
- __name__: _string_
|
||||||
|
- __id__: _string_
|
||||||
|
|
||||||
|
### AddAppInvoiceRequest
|
||||||
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
- __payer_identifier__: _string_
|
||||||
|
- __http_callback_url__: _string_
|
||||||
|
|
||||||
|
### GetAppUserLNURLInfoRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __base_url_override__: _string_
|
||||||
|
|
||||||
|
### GetPaymentStateRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
|
||||||
|
### ChannelRouting
|
||||||
|
- __forward_fee_as_output__: _number_
|
||||||
|
- __events_number__: _number_
|
||||||
|
- __send_errors__: _number_
|
||||||
|
- __forward_errors_as_output__: _number_
|
||||||
|
- __forward_fee_as_input__: _number_
|
||||||
|
- __missed_forward_fee_as_input__: _number_
|
||||||
|
- __missed_forward_fee_as_output__: _number_
|
||||||
|
- __channel_id__: _string_
|
||||||
|
- __receive_errors__: _number_
|
||||||
|
- __forward_errors_as_input__: _number_
|
||||||
|
|
||||||
|
### PayAppUserInvoiceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### SetMockAppUserBalanceRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### PayAddressRequest
|
||||||
|
- __address__: _string_
|
||||||
|
- __amoutSats__: _number_
|
||||||
|
- __satsPerVByte__: _number_
|
||||||
|
|
||||||
|
### GetUserOperationsRequest
|
||||||
|
- __max_size__: _number_
|
||||||
|
- __latestIncomingInvoice__: _number_
|
||||||
|
- __latestOutgoingInvoice__: _number_
|
||||||
|
- __latestIncomingTx__: _number_
|
||||||
|
- __latestOutgoingTx__: _number_
|
||||||
|
- __latestIncomingUserToUserPayment__: _number_
|
||||||
|
- __latestOutgoingUserToUserPayment__: _number_
|
||||||
|
|
||||||
|
### Product
|
||||||
|
- __id__: _string_
|
||||||
|
- __name__: _string_
|
||||||
|
- __price_sats__: _number_
|
||||||
|
|
||||||
|
### UseInviteLinkRequest
|
||||||
|
- __invite_token__: _string_
|
||||||
|
|
||||||
|
### AppsMetrics
|
||||||
|
- __apps__: ARRAY of: _[AppMetrics](#AppMetrics)_
|
||||||
|
|
||||||
|
### SetMockInvoiceAsPaidRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### BanUserRequest
|
||||||
|
- __user_id__: _string_
|
||||||
|
|
||||||
|
### GetAppUserRequest
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
|
||||||
|
### NewInvoiceResponse
|
||||||
|
- __invoice__: _string_
|
||||||
|
|
||||||
### GetUserOperationsResponse
|
### GetUserOperationsResponse
|
||||||
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
|
@ -606,81 +735,48 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
||||||
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
||||||
|
|
||||||
### RequestNPubLinkingTokenResponse
|
|
||||||
- __token__: _string_
|
|
||||||
|
|
||||||
### LndGetInfoResponse
|
|
||||||
- __alias__: _string_
|
|
||||||
|
|
||||||
### NewAddressResponse
|
|
||||||
- __address__: _string_
|
|
||||||
|
|
||||||
### PayInvoiceRequest
|
|
||||||
- __amount__: _number_
|
|
||||||
- __invoice__: _string_
|
|
||||||
|
|
||||||
### RoutingEvent
|
|
||||||
- __failure_string__: _string_
|
|
||||||
- __settled__: _boolean_
|
|
||||||
- __offchain__: _boolean_
|
|
||||||
- __timestamp_ns__: _number_
|
|
||||||
- __incoming_amt_msat__: _number_
|
|
||||||
- __outgoing_amt_msat__: _number_
|
|
||||||
- __outgoing_htlc_id__: _number_
|
|
||||||
- __event_type__: _string_
|
|
||||||
- __forward_fail_event__: _boolean_
|
|
||||||
- __incoming_channel_id__: _number_
|
|
||||||
- __incoming_htlc_id__: _number_
|
|
||||||
- __outgoing_channel_id__: _number_
|
|
||||||
|
|
||||||
### ChannelBalanceEvent
|
|
||||||
- __block_height__: _number_
|
|
||||||
- __channel_id__: _string_
|
|
||||||
- __local_balance_sats__: _number_
|
|
||||||
- __remote_balance_sats__: _number_
|
|
||||||
|
|
||||||
### AddAppRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __allow_user_creation__: _boolean_
|
|
||||||
|
|
||||||
### LndGetInfoRequest
|
|
||||||
- __nodeId__: _number_
|
|
||||||
|
|
||||||
### AddAppUserRequest
|
|
||||||
- __identifier__: _string_
|
|
||||||
- __fail_if_exists__: _boolean_
|
|
||||||
- __balance__: _number_
|
|
||||||
|
|
||||||
### SetMockAppBalanceRequest
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### GetPaymentStateRequest
|
|
||||||
- __invoice__: _string_
|
|
||||||
|
|
||||||
### HttpCreds
|
|
||||||
- __token__: _string_
|
|
||||||
- __url__: _string_
|
|
||||||
|
|
||||||
### UsageMetrics
|
|
||||||
- __metrics__: ARRAY of: _[UsageMetric](#UsageMetric)_
|
|
||||||
|
|
||||||
### AppMetrics
|
|
||||||
- __app__: _[Application](#Application)_
|
|
||||||
- __spent__: _number_
|
|
||||||
- __available__: _number_
|
|
||||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
|
||||||
- __users__: _[UsersInfo](#UsersInfo)_
|
|
||||||
- __received__: _number_
|
|
||||||
- __fees__: _number_
|
|
||||||
- __invoices__: _number_
|
|
||||||
- __total_fees__: _number_
|
|
||||||
|
|
||||||
### LndMetricsRequest
|
### LndMetricsRequest
|
||||||
- __from_unix__: _number_ *this field is optional
|
- __from_unix__: _number_ *this field is optional
|
||||||
- __to_unix__: _number_ *this field is optional
|
- __to_unix__: _number_ *this field is optional
|
||||||
|
|
||||||
### UseInviteLinkRequest
|
### AuthApp
|
||||||
- __invite_token__: _string_
|
- __app__: _[Application](#Application)_
|
||||||
|
- __auth_token__: _string_
|
||||||
|
|
||||||
|
### DecodeInvoiceRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
|
||||||
|
### LnurlLinkResponse
|
||||||
|
- __lnurl__: _string_
|
||||||
|
- __k1__: _string_
|
||||||
|
|
||||||
|
### RequestNPubLinkingTokenResponse
|
||||||
|
- __token__: _string_
|
||||||
|
|
||||||
|
### CreateOneTimeInviteLinkResponse
|
||||||
|
- __invitation_link__: _string_
|
||||||
|
|
||||||
|
### UsersInfo
|
||||||
|
- __total__: _number_
|
||||||
|
- __no_balance__: _number_
|
||||||
|
- __negative_balance__: _number_
|
||||||
|
- __always_been_inactive__: _number_
|
||||||
|
- __balance_avg__: _number_
|
||||||
|
- __balance_median__: _number_
|
||||||
|
|
||||||
|
### RoutingEvent
|
||||||
|
- __outgoing_channel_id__: _number_
|
||||||
|
- __incoming_amt_msat__: _number_
|
||||||
|
- __settled__: _boolean_
|
||||||
|
- __outgoing_amt_msat__: _number_
|
||||||
|
- __failure_string__: _string_
|
||||||
|
- __offchain__: _boolean_
|
||||||
|
- __incoming_channel_id__: _number_
|
||||||
|
- __incoming_htlc_id__: _number_
|
||||||
|
- __outgoing_htlc_id__: _number_
|
||||||
|
- __timestamp_ns__: _number_
|
||||||
|
- __event_type__: _string_
|
||||||
|
- __forward_fail_event__: _boolean_
|
||||||
|
|
||||||
### UserInfo
|
### UserInfo
|
||||||
- __user_identifier__: _string_
|
- __user_identifier__: _string_
|
||||||
|
|
@ -691,43 +787,196 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __balance__: _number_
|
- __balance__: _number_
|
||||||
- __max_withdrawable__: _number_
|
- __max_withdrawable__: _number_
|
||||||
|
|
||||||
### UserOperations
|
### LndGetInfoRequest
|
||||||
- __fromIndex__: _number_
|
- __nodeId__: _number_
|
||||||
- __toIndex__: _number_
|
|
||||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
### AddAppRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __allow_user_creation__: _boolean_
|
||||||
|
|
||||||
|
### AddAppUserInvoiceRequest
|
||||||
|
- __receiver_identifier__: _string_
|
||||||
|
- __payer_identifier__: _string_
|
||||||
|
- __http_callback_url__: _string_
|
||||||
|
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||||
|
|
||||||
|
### LinkNPubThroughTokenRequest
|
||||||
|
- __token__: _string_
|
||||||
|
|
||||||
|
### PayInvoiceResponse
|
||||||
|
- __network_fee__: _number_
|
||||||
|
- __preimage__: _string_
|
||||||
|
- __amount_paid__: _number_
|
||||||
|
- __operation_id__: _string_
|
||||||
|
- __service_fee__: _number_
|
||||||
|
|
||||||
|
### LnurlPayInfoResponse
|
||||||
|
- __allowsNostr__: _boolean_
|
||||||
|
- __nostrPubkey__: _string_
|
||||||
|
- __tag__: _string_
|
||||||
|
- __callback__: _string_
|
||||||
|
- __maxSendable__: _number_
|
||||||
|
- __minSendable__: _number_
|
||||||
|
- __metadata__: _string_
|
||||||
|
|
||||||
|
### ClosureMigration
|
||||||
|
- __closes_at_unix__: _number_
|
||||||
|
|
||||||
|
### ChainBalanceEvent
|
||||||
|
- __block_height__: _number_
|
||||||
|
- __confirmed_balance__: _number_
|
||||||
|
- __unconfirmed_balance__: _number_
|
||||||
|
- __total_balance__: _number_
|
||||||
|
|
||||||
|
### LndNodeMetrics
|
||||||
|
- __channels_balance_events__: ARRAY of: _[ChannelBalanceEvent](#ChannelBalanceEvent)_
|
||||||
|
- __channel_routing__: ARRAY of: _[ChannelRouting](#ChannelRouting)_
|
||||||
|
- __closing_channels__: _number_
|
||||||
|
- __open_channels__: ARRAY of: _[OpenChannel](#OpenChannel)_
|
||||||
|
- __closed_channels__: ARRAY of: _[ClosedChannel](#ClosedChannel)_
|
||||||
|
- __chain_balance_events__: ARRAY of: _[ChainBalanceEvent](#ChainBalanceEvent)_
|
||||||
|
- __offline_channels__: _number_
|
||||||
|
- __online_channels__: _number_
|
||||||
|
- __pending_channels__: _number_
|
||||||
|
|
||||||
|
### UserOperation
|
||||||
|
- __network_fee__: _number_
|
||||||
|
- __type__: _[UserOperationType](#UserOperationType)_
|
||||||
|
- __identifier__: _string_
|
||||||
|
- __service_fee__: _number_
|
||||||
|
- __operationId__: _string_
|
||||||
|
- __confirmed__: _boolean_
|
||||||
|
- __tx_hash__: _string_
|
||||||
|
- __internal__: _boolean_
|
||||||
|
- __paidAtUnix__: _number_
|
||||||
|
- __inbound__: _boolean_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
### GetInviteTokenStateRequest
|
### GetInviteTokenStateRequest
|
||||||
- __invite_token__: _string_
|
- __invite_token__: _string_
|
||||||
|
|
||||||
### UsageMetric
|
### ChannelBalanceEvent
|
||||||
- __parsed_in_nano__: _number_
|
- __block_height__: _number_
|
||||||
- __handle_in_nano__: _number_
|
- __channel_id__: _string_
|
||||||
- __batch__: _boolean_
|
- __local_balance_sats__: _number_
|
||||||
- __nostr__: _boolean_
|
- __remote_balance_sats__: _number_
|
||||||
- __processed_at_ms__: _number_
|
|
||||||
- __auth_in_nano__: _number_
|
### OpenChannel
|
||||||
- __validate_in_nano__: _number_
|
- __channel_id__: _string_
|
||||||
- __rpc_name__: _string_
|
- __capacity__: _number_
|
||||||
- __batch_size__: _number_
|
- __active__: _boolean_
|
||||||
|
- __lifetime__: _number_
|
||||||
|
- __local_balance__: _number_
|
||||||
|
- __remote_balance__: _number_
|
||||||
|
|
||||||
|
### BanUserResponse
|
||||||
|
- __balance_sats__: _number_
|
||||||
|
- __banned_app_users__: ARRAY of: _[BannedAppUser](#BannedAppUser)_
|
||||||
|
|
||||||
### AppUser
|
### AppUser
|
||||||
- __identifier__: _string_
|
- __identifier__: _string_
|
||||||
- __info__: _[UserInfo](#UserInfo)_
|
- __info__: _[UserInfo](#UserInfo)_
|
||||||
- __max_withdrawable__: _number_
|
- __max_withdrawable__: _number_
|
||||||
|
|
||||||
### SendAppUserToAppUserPaymentRequest
|
### PaymentState
|
||||||
- __amount__: _number_
|
- __amount__: _number_
|
||||||
|
- __service_fee__: _number_
|
||||||
|
- __network_fee__: _number_
|
||||||
|
- __paid_at_unix__: _number_
|
||||||
|
|
||||||
|
### MigrationUpdate
|
||||||
|
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
||||||
|
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
||||||
|
|
||||||
|
### HttpCreds
|
||||||
|
- __url__: _string_
|
||||||
|
- __token__: _string_
|
||||||
|
|
||||||
|
### ClosedChannel
|
||||||
|
- __capacity__: _number_
|
||||||
|
- __closed_height__: _number_
|
||||||
|
- __channel_id__: _string_
|
||||||
|
|
||||||
|
### LndGetInfoResponse
|
||||||
|
- __alias__: _string_
|
||||||
|
|
||||||
|
### PayInvoiceRequest
|
||||||
|
- __invoice__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### SendAppUserToAppPaymentRequest
|
||||||
|
- __from_user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### OpenChannelRequest
|
||||||
|
- __closeAddress__: _string_
|
||||||
|
- __destination__: _string_
|
||||||
|
- __fundingAmount__: _number_
|
||||||
|
- __pushAmount__: _number_
|
||||||
|
|
||||||
|
### EnrollAdminTokenRequest
|
||||||
|
- __admin_token__: _string_
|
||||||
|
|
||||||
|
### Empty
|
||||||
|
|
||||||
|
### NewAddressRequest
|
||||||
|
- __addressType__: _[AddressType](#AddressType)_
|
||||||
|
|
||||||
|
### AddProductRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __price_sats__: _number_
|
||||||
|
|
||||||
|
### GetInviteTokenStateResponse
|
||||||
|
- __used__: _boolean_
|
||||||
|
|
||||||
|
### EncryptionExchangeRequest
|
||||||
|
- __publicKey__: _string_
|
||||||
|
- __deviceId__: _string_
|
||||||
|
|
||||||
|
### UsageMetrics
|
||||||
|
- __metrics__: ARRAY of: _[UsageMetric](#UsageMetric)_
|
||||||
|
|
||||||
|
### AuthAppRequest
|
||||||
|
- __name__: _string_
|
||||||
|
- __allow_user_creation__: _boolean_ *this field is optional
|
||||||
|
|
||||||
|
### AddAppUserRequest
|
||||||
|
- __identifier__: _string_
|
||||||
|
- __fail_if_exists__: _boolean_
|
||||||
|
- __balance__: _number_
|
||||||
|
|
||||||
|
### DecodeInvoiceResponse
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
|
### RelaysMigration
|
||||||
|
- __relays__: ARRAY of: _string_
|
||||||
|
|
||||||
|
### CreateOneTimeInviteLinkRequest
|
||||||
|
- __sats__: _number_ *this field is optional
|
||||||
|
|
||||||
|
### BannedAppUser
|
||||||
|
- __app_name__: _string_
|
||||||
|
- __app_id__: _string_
|
||||||
|
- __user_identifier__: _string_
|
||||||
|
- __nostr_pub__: _string_
|
||||||
|
|
||||||
|
### SendAppUserToAppUserPaymentRequest
|
||||||
- __from_user_identifier__: _string_
|
- __from_user_identifier__: _string_
|
||||||
- __to_user_identifier__: _string_
|
- __to_user_identifier__: _string_
|
||||||
|
- __amount__: _number_
|
||||||
|
|
||||||
### Application
|
### NewInvoiceRequest
|
||||||
- __id__: _string_
|
- __amountSats__: _number_
|
||||||
- __balance__: _number_
|
- __memo__: _string_
|
||||||
- __npub__: _string_
|
|
||||||
- __name__: _string_
|
|
||||||
|
|
||||||
### DecodeInvoiceRequest
|
### OpenChannelResponse
|
||||||
- __invoice__: _string_
|
- __channelId__: _string_
|
||||||
|
|
||||||
|
### LiveUserOperation
|
||||||
|
- __operation__: _[UserOperation](#UserOperation)_
|
||||||
|
|
||||||
|
### LndSeed
|
||||||
|
- __seed__: ARRAY of: _string_
|
||||||
|
|
||||||
### LnurlWithdrawInfoResponse
|
### LnurlWithdrawInfoResponse
|
||||||
- __maxWithdrawable__: _number_
|
- __maxWithdrawable__: _number_
|
||||||
|
|
@ -739,247 +988,13 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __defaultDescription__: _string_
|
- __defaultDescription__: _string_
|
||||||
- __minWithdrawable__: _number_
|
- __minWithdrawable__: _number_
|
||||||
|
|
||||||
### GetUserOperationsRequest
|
### UserOperations
|
||||||
- __latestIncomingTx__: _number_
|
- __toIndex__: _number_
|
||||||
- __latestOutgoingTx__: _number_
|
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||||
- __latestIncomingUserToUserPayment__: _number_
|
- __fromIndex__: _number_
|
||||||
- __latestOutgoingUserToUserPayment__: _number_
|
|
||||||
- __max_size__: _number_
|
|
||||||
- __latestIncomingInvoice__: _number_
|
|
||||||
- __latestOutgoingInvoice__: _number_
|
|
||||||
|
|
||||||
### EncryptionExchangeRequest
|
|
||||||
- __publicKey__: _string_
|
|
||||||
- __deviceId__: _string_
|
|
||||||
|
|
||||||
### AppsMetrics
|
|
||||||
- __apps__: ARRAY of: _[AppMetrics](#AppMetrics)_
|
|
||||||
|
|
||||||
### AuthAppRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __allow_user_creation__: _boolean_ *this field is optional
|
|
||||||
|
|
||||||
### PayAppUserInvoiceRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### SendAppUserToAppPaymentRequest
|
|
||||||
- __from_user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### GetAppUserLNURLInfoRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __base_url_override__: _string_
|
|
||||||
|
|
||||||
### RequestNPubLinkingTokenRequest
|
### RequestNPubLinkingTokenRequest
|
||||||
- __user_identifier__: _string_
|
- __user_identifier__: _string_
|
||||||
|
|
||||||
### LinkNPubThroughTokenRequest
|
|
||||||
- __token__: _string_
|
|
||||||
|
|
||||||
### OpenChannel
|
|
||||||
- __channel_id__: _string_
|
|
||||||
- __capacity__: _number_
|
|
||||||
- __active__: _boolean_
|
|
||||||
- __lifetime__: _number_
|
|
||||||
- __local_balance__: _number_
|
|
||||||
- __remote_balance__: _number_
|
|
||||||
|
|
||||||
### BanUserResponse
|
|
||||||
- __banned_app_users__: ARRAY of: _[BannedAppUser](#BannedAppUser)_
|
|
||||||
- __balance_sats__: _number_
|
|
||||||
|
|
||||||
### AuthApp
|
|
||||||
- __app__: _[Application](#Application)_
|
|
||||||
- __auth_token__: _string_
|
|
||||||
|
|
||||||
### EnrollAdminTokenRequest
|
|
||||||
- __admin_token__: _string_
|
|
||||||
|
|
||||||
### PayAddressResponse
|
|
||||||
- __txId__: _string_
|
|
||||||
- __operation_id__: _string_
|
|
||||||
- __service_fee__: _number_
|
|
||||||
- __network_fee__: _number_
|
|
||||||
|
|
||||||
### OpenChannelResponse
|
|
||||||
- __channelId__: _string_
|
|
||||||
|
|
||||||
### AddAppUserInvoiceRequest
|
|
||||||
- __payer_identifier__: _string_
|
|
||||||
- __http_callback_url__: _string_
|
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
|
||||||
- __receiver_identifier__: _string_
|
|
||||||
|
|
||||||
### DecodeInvoiceResponse
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### HandleLnurlPayResponse
|
|
||||||
- __pr__: _string_
|
|
||||||
- __routes__: ARRAY of: _[Empty](#Empty)_
|
|
||||||
|
|
||||||
### GetProductBuyLinkResponse
|
|
||||||
- __link__: _string_
|
|
||||||
|
|
||||||
### AppsMetricsRequest
|
|
||||||
- __to_unix__: _number_ *this field is optional
|
|
||||||
- __include_operations__: _boolean_ *this field is optional
|
|
||||||
- __from_unix__: _number_ *this field is optional
|
|
||||||
|
|
||||||
### ChannelRouting
|
|
||||||
- __send_errors__: _number_
|
|
||||||
- __receive_errors__: _number_
|
|
||||||
- __forward_errors_as_input__: _number_
|
|
||||||
- __missed_forward_fee_as_input__: _number_
|
|
||||||
- __forward_fee_as_input__: _number_
|
|
||||||
- __forward_fee_as_output__: _number_
|
|
||||||
- __channel_id__: _string_
|
|
||||||
- __forward_errors_as_output__: _number_
|
|
||||||
- __missed_forward_fee_as_output__: _number_
|
|
||||||
- __events_number__: _number_
|
|
||||||
|
|
||||||
### LndMetrics
|
|
||||||
- __nodes__: ARRAY of: _[LndNodeMetrics](#LndNodeMetrics)_
|
|
||||||
|
|
||||||
### NewAddressRequest
|
|
||||||
- __addressType__: _[AddressType](#AddressType)_
|
|
||||||
|
|
||||||
### PayAddressRequest
|
|
||||||
- __satsPerVByte__: _number_
|
|
||||||
- __address__: _string_
|
|
||||||
- __amoutSats__: _number_
|
|
||||||
|
|
||||||
### PaymentState
|
|
||||||
- __service_fee__: _number_
|
|
||||||
- __network_fee__: _number_
|
|
||||||
- __paid_at_unix__: _number_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### OpenChannelRequest
|
|
||||||
- __closeAddress__: _string_
|
|
||||||
- __destination__: _string_
|
|
||||||
- __fundingAmount__: _number_
|
|
||||||
- __pushAmount__: _number_
|
|
||||||
|
|
||||||
### CreateOneTimeInviteLinkRequest
|
|
||||||
- __sats__: _number_ *this field is optional
|
|
||||||
|
|
||||||
### GetInviteTokenStateResponse
|
|
||||||
- __used__: _boolean_
|
|
||||||
|
|
||||||
### BannedAppUser
|
|
||||||
- __app_name__: _string_
|
|
||||||
- __app_id__: _string_
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __nostr_pub__: _string_
|
|
||||||
|
|
||||||
### AddAppInvoiceRequest
|
|
||||||
- __payer_identifier__: _string_
|
|
||||||
- __http_callback_url__: _string_
|
|
||||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
|
||||||
|
|
||||||
### SetMockAppUserBalanceRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### ClosureMigration
|
|
||||||
- __closes_at_unix__: _number_
|
|
||||||
|
|
||||||
### RelaysMigration
|
|
||||||
- __relays__: ARRAY of: _string_
|
|
||||||
|
|
||||||
### NewInvoiceRequest
|
|
||||||
- __amountSats__: _number_
|
|
||||||
- __memo__: _string_
|
|
||||||
|
|
||||||
### UserOperation
|
|
||||||
- __internal__: _boolean_
|
|
||||||
- __type__: _[UserOperationType](#UserOperationType)_
|
|
||||||
- __amount__: _number_
|
|
||||||
- __identifier__: _string_
|
|
||||||
- __service_fee__: _number_
|
|
||||||
- __confirmed__: _boolean_
|
|
||||||
- __paidAtUnix__: _number_
|
|
||||||
- __inbound__: _boolean_
|
|
||||||
- __operationId__: _string_
|
|
||||||
- __network_fee__: _number_
|
|
||||||
- __tx_hash__: _string_
|
|
||||||
|
|
||||||
### Product
|
|
||||||
- __id__: _string_
|
|
||||||
- __name__: _string_
|
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### GetAppUserRequest
|
|
||||||
- __user_identifier__: _string_
|
|
||||||
|
|
||||||
### MigrationUpdate
|
|
||||||
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
|
||||||
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
|
||||||
|
|
||||||
### CreateOneTimeInviteLinkResponse
|
|
||||||
- __invitation_link__: _string_
|
|
||||||
|
|
||||||
### Empty
|
|
||||||
|
|
||||||
### ClosedChannel
|
|
||||||
- __channel_id__: _string_
|
|
||||||
- __capacity__: _number_
|
|
||||||
- __closed_height__: _number_
|
|
||||||
|
|
||||||
### BanUserRequest
|
|
||||||
- __user_id__: _string_
|
|
||||||
|
|
||||||
### LiveUserOperation
|
|
||||||
- __operation__: _[UserOperation](#UserOperation)_
|
|
||||||
|
|
||||||
### ChainBalanceEvent
|
|
||||||
- __block_height__: _number_
|
|
||||||
- __confirmed_balance__: _number_
|
|
||||||
- __unconfirmed_balance__: _number_
|
|
||||||
- __total_balance__: _number_
|
|
||||||
|
|
||||||
### LndNodeMetrics
|
|
||||||
- __online_channels__: _number_
|
|
||||||
- __closing_channels__: _number_
|
|
||||||
- __open_channels__: ARRAY of: _[OpenChannel](#OpenChannel)_
|
|
||||||
- __closed_channels__: ARRAY of: _[ClosedChannel](#ClosedChannel)_
|
|
||||||
- __channel_routing__: ARRAY of: _[ChannelRouting](#ChannelRouting)_
|
|
||||||
- __channels_balance_events__: ARRAY of: _[ChannelBalanceEvent](#ChannelBalanceEvent)_
|
|
||||||
- __offline_channels__: _number_
|
|
||||||
- __chain_balance_events__: ARRAY of: _[ChainBalanceEvent](#ChainBalanceEvent)_
|
|
||||||
- __pending_channels__: _number_
|
|
||||||
|
|
||||||
### AddProductRequest
|
|
||||||
- __name__: _string_
|
|
||||||
- __price_sats__: _number_
|
|
||||||
|
|
||||||
### PayInvoiceResponse
|
|
||||||
- __preimage__: _string_
|
|
||||||
- __amount_paid__: _number_
|
|
||||||
- __operation_id__: _string_
|
|
||||||
- __service_fee__: _number_
|
|
||||||
- __network_fee__: _number_
|
|
||||||
|
|
||||||
### LnurlLinkResponse
|
|
||||||
- __lnurl__: _string_
|
|
||||||
- __k1__: _string_
|
|
||||||
|
|
||||||
### UsersInfo
|
|
||||||
- __always_been_inactive__: _number_
|
|
||||||
- __balance_avg__: _number_
|
|
||||||
- __balance_median__: _number_
|
|
||||||
- __total__: _number_
|
|
||||||
- __no_balance__: _number_
|
|
||||||
- __negative_balance__: _number_
|
|
||||||
|
|
||||||
### SetMockInvoiceAsPaidRequest
|
|
||||||
- __invoice__: _string_
|
|
||||||
- __amount__: _number_
|
|
||||||
|
|
||||||
### NewInvoiceResponse
|
|
||||||
- __invoice__: _string_
|
|
||||||
## Enums
|
## Enums
|
||||||
### The enumerators used in the messages
|
### The enumerators used in the messages
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -122,6 +122,25 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
|
||||||
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
|
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
|
||||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
||||||
})
|
})
|
||||||
|
if (!opts.allowNotImplementedMethods && !methods.GetSeed) throw new Error('method: GetSeed is not implemented')
|
||||||
|
app.get('/api/admin/seed', async (req, res) => {
|
||||||
|
const info: Types.RequestInfo = { rpcName: 'GetSeed', batch: false, nostr: false, batchSize: 0}
|
||||||
|
const stats: Types.RequestStats = { startMs:req.startTimeMs || 0, start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n }
|
||||||
|
let authCtx: Types.AuthContext = {}
|
||||||
|
try {
|
||||||
|
if (!methods.GetSeed) throw new Error('method: GetSeed is not implemented')
|
||||||
|
const authContext = await opts.AdminAuthGuard(req.headers['authorization'])
|
||||||
|
authCtx = authContext
|
||||||
|
stats.guard = process.hrtime.bigint()
|
||||||
|
stats.validate = stats.guard
|
||||||
|
const query = req.query
|
||||||
|
const params = req.params
|
||||||
|
const response = await methods.GetSeed({rpcName:'GetSeed', ctx:authContext })
|
||||||
|
stats.handle = process.hrtime.bigint()
|
||||||
|
res.json({status: 'OK', ...response})
|
||||||
|
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
|
||||||
|
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
||||||
|
})
|
||||||
if (!opts.allowNotImplementedMethods && !methods.GetUsageMetrics) throw new Error('method: GetUsageMetrics is not implemented')
|
if (!opts.allowNotImplementedMethods && !methods.GetUsageMetrics) throw new Error('method: GetUsageMetrics is not implemented')
|
||||||
app.post('/api/reports/usage', async (req, res) => {
|
app.post('/api/reports/usage', async (req, res) => {
|
||||||
const info: Types.RequestInfo = { rpcName: 'GetUsageMetrics', batch: false, nostr: false, batchSize: 0}
|
const info: Types.RequestInfo = { rpcName: 'GetUsageMetrics', batch: false, nostr: false, batchSize: 0}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,20 @@ export default (params: ClientParams) => ({
|
||||||
}
|
}
|
||||||
return { status: 'ERROR', reason: 'invalid response' }
|
return { status: 'ERROR', reason: 'invalid response' }
|
||||||
},
|
},
|
||||||
|
GetSeed: async (): Promise<ResultError | ({ status: 'OK' }& Types.LndSeed)> => {
|
||||||
|
const auth = await params.retrieveAdminAuth()
|
||||||
|
if (auth === null) throw new Error('retrieveAdminAuth() returned null')
|
||||||
|
let finalRoute = '/api/admin/seed'
|
||||||
|
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.LndSeedValidate(result)
|
||||||
|
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
|
||||||
|
}
|
||||||
|
return { status: 'ERROR', reason: 'invalid response' }
|
||||||
|
},
|
||||||
GetUsageMetrics: async (): Promise<ResultError | ({ status: 'OK' }& Types.UsageMetrics)> => {
|
GetUsageMetrics: async (): Promise<ResultError | ({ status: 'OK' }& Types.UsageMetrics)> => {
|
||||||
const auth = await params.retrieveMetricsAuth()
|
const auth = await params.retrieveMetricsAuth()
|
||||||
if (auth === null) throw new Error('retrieveMetricsAuth() returned null')
|
if (auth === null) throw new Error('retrieveMetricsAuth() returned null')
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ export type ResultError = { status: 'ERROR', reason: string }
|
||||||
|
|
||||||
export type NostrClientParams = {
|
export type NostrClientParams = {
|
||||||
pubDestination: string
|
pubDestination: string
|
||||||
retrieveNostrAdminAuth: () => Promise<string | null>
|
|
||||||
retrieveNostrMetricsAuth: () => Promise<string | null>
|
retrieveNostrMetricsAuth: () => Promise<string | null>
|
||||||
retrieveNostrUserAuth: () => Promise<string | null>
|
retrieveNostrUserAuth: () => Promise<string | null>
|
||||||
retrieveNostrGuestWithPubAuth: () => Promise<string | null>
|
retrieveNostrGuestWithPubAuth: () => Promise<string | null>
|
||||||
|
retrieveNostrAdminAuth: () => Promise<string | null>
|
||||||
checkResult?: true
|
checkResult?: true
|
||||||
}
|
}
|
||||||
export default (params: NostrClientParams, send: (to:string, message: NostrRequest) => Promise<any>, subscribe: (to:string, message: NostrRequest, cb:(res:any)=> void) => void) => ({
|
export default (params: NostrClientParams, send: (to:string, message: NostrRequest) => Promise<any>, subscribe: (to:string, message: NostrRequest, cb:(res:any)=> void) => void) => ({
|
||||||
|
|
@ -72,6 +72,20 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
|
||||||
}
|
}
|
||||||
return { status: 'ERROR', reason: 'invalid response' }
|
return { status: 'ERROR', reason: 'invalid response' }
|
||||||
},
|
},
|
||||||
|
GetSeed: async (): Promise<ResultError | ({ status: 'OK' }& Types.LndSeed)> => {
|
||||||
|
const auth = await params.retrieveNostrAdminAuth()
|
||||||
|
if (auth === null) throw new Error('retrieveNostrAdminAuth() returned null')
|
||||||
|
const nostrRequest: NostrRequest = {}
|
||||||
|
const data = await send(params.pubDestination, {rpcName:'GetSeed',authIdentifier:auth, ...nostrRequest })
|
||||||
|
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.LndSeedValidate(result)
|
||||||
|
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
|
||||||
|
}
|
||||||
|
return { status: 'ERROR', reason: 'invalid response' }
|
||||||
|
},
|
||||||
GetUsageMetrics: async (): Promise<ResultError | ({ status: 'OK' }& Types.UsageMetrics)> => {
|
GetUsageMetrics: async (): Promise<ResultError | ({ status: 'OK' }& Types.UsageMetrics)> => {
|
||||||
const auth = await params.retrieveNostrMetricsAuth()
|
const auth = await params.retrieveNostrMetricsAuth()
|
||||||
if (auth === null) throw new Error('retrieveNostrMetricsAuth() returned null')
|
if (auth === null) throw new Error('retrieveNostrMetricsAuth() returned null')
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,19 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
|
||||||
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
|
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
|
||||||
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
||||||
break
|
break
|
||||||
|
case 'GetSeed':
|
||||||
|
try {
|
||||||
|
if (!methods.GetSeed) throw new Error('method: GetSeed is not implemented')
|
||||||
|
const authContext = await opts.NostrAdminAuthGuard(req.appId, req.authIdentifier)
|
||||||
|
stats.guard = process.hrtime.bigint()
|
||||||
|
authCtx = authContext
|
||||||
|
stats.validate = stats.guard
|
||||||
|
const response = await methods.GetSeed({rpcName:'GetSeed', ctx:authContext })
|
||||||
|
stats.handle = process.hrtime.bigint()
|
||||||
|
res({status: 'OK', ...response})
|
||||||
|
opts.metricsCallback([{ ...info, ...stats, ...authContext }])
|
||||||
|
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
||||||
|
break
|
||||||
case 'GetUsageMetrics':
|
case 'GetUsageMetrics':
|
||||||
try {
|
try {
|
||||||
if (!methods.GetUsageMetrics) throw new Error('method: GetUsageMetrics is not implemented')
|
if (!methods.GetUsageMetrics) throw new Error('method: GetUsageMetrics is not implemented')
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -130,6 +130,13 @@ service LightningPub {
|
||||||
option (nostr) = true;
|
option (nostr) = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpc GetSeed(structs.Empty) returns (structs.LndSeed) {
|
||||||
|
option (auth_type) = "Admin";
|
||||||
|
option (http_method) = "get";
|
||||||
|
option (http_route) = "/api/admin/seed";
|
||||||
|
option (nostr) = true;
|
||||||
|
}
|
||||||
|
|
||||||
rpc GetUsageMetrics(structs.Empty) returns (structs.UsageMetrics) {
|
rpc GetUsageMetrics(structs.Empty) returns (structs.UsageMetrics) {
|
||||||
option (auth_type) = "Metrics";
|
option (auth_type) = "Metrics";
|
||||||
option (http_method) = "post";
|
option (http_method) = "post";
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ option go_package = "github.com/shocknet/lightning.pub";
|
||||||
|
|
||||||
message Empty {}
|
message Empty {}
|
||||||
|
|
||||||
|
message LndSeed {
|
||||||
|
repeated string seed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message EncryptionExchangeRequest {
|
message EncryptionExchangeRequest {
|
||||||
string publicKey = 1;
|
string publicKey = 1;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { MainSettings, getDataPath } from "./settings.js";
|
||||||
import Storage from "../storage/index.js";
|
import Storage from "../storage/index.js";
|
||||||
import * as Types from '../../../proto/autogenerated/ts/types.js'
|
import * as Types from '../../../proto/autogenerated/ts/types.js'
|
||||||
export class AdminManager {
|
export class AdminManager {
|
||||||
|
|
||||||
storage: Storage
|
storage: Storage
|
||||||
log = getLogger({ component: "adminManager" })
|
log = getLogger({ component: "adminManager" })
|
||||||
adminNpub = ""
|
adminNpub = ""
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import { LiquidityManager } from "./liquidityManager.js"
|
||||||
import { Utils } from "../helpers/utilsWrapper.js"
|
import { Utils } from "../helpers/utilsWrapper.js"
|
||||||
import { RugPullTracker } from "./rugPullTracker.js"
|
import { RugPullTracker } from "./rugPullTracker.js"
|
||||||
import { AdminManager } from "./adminManager.js"
|
import { AdminManager } from "./adminManager.js"
|
||||||
|
import { Unlocker } from "./unlocker.js"
|
||||||
|
|
||||||
type UserOperationsSub = {
|
type UserOperationsSub = {
|
||||||
id: string
|
id: string
|
||||||
|
|
@ -45,8 +46,9 @@ export default class {
|
||||||
liquidityProvider: LiquidityProvider
|
liquidityProvider: LiquidityProvider
|
||||||
utils: Utils
|
utils: Utils
|
||||||
rugPullTracker: RugPullTracker
|
rugPullTracker: RugPullTracker
|
||||||
|
unlocker:Unlocker
|
||||||
nostrSend: NostrSend = () => { getLogger({})("nostr send not initialized yet") }
|
nostrSend: NostrSend = () => { getLogger({})("nostr send not initialized yet") }
|
||||||
constructor(settings: MainSettings, storage: Storage, adminManager: AdminManager, utils: Utils) {
|
constructor(settings: MainSettings, storage: Storage, adminManager: AdminManager, utils: Utils,unlocker:Unlocker) {
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
this.storage = storage
|
this.storage = storage
|
||||||
this.utils = utils
|
this.utils = utils
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ export const initMainHandler = async (log: PubLogger, mainSettings: MainSettings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainHandler = new Main(reloadedSettings, storageManager, adminManager, utils)
|
const mainHandler = new Main(reloadedSettings, storageManager, adminManager, utils,unlocker)
|
||||||
await mainHandler.lnd.Warmup()
|
await mainHandler.lnd.Warmup()
|
||||||
if (!reloadedSettings.skipSanityCheck) {
|
if (!reloadedSettings.skipSanityCheck) {
|
||||||
const sanityChecker = new SanityChecker(storageManager, mainHandler.lnd)
|
const sanityChecker = new SanityChecker(storageManager, mainHandler.lnd)
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,17 @@ import { MainSettings } from '../main/settings.js';
|
||||||
import { InitWalletReq } from '../lnd/initWalletReq.js';
|
import { InitWalletReq } from '../lnd/initWalletReq.js';
|
||||||
import Storage from '../storage/index.js'
|
import Storage from '../storage/index.js'
|
||||||
import { LightningClient } from '../../../proto/lnd/lightning.client.js';
|
import { LightningClient } from '../../../proto/lnd/lightning.client.js';
|
||||||
|
import * as Types from '../../../proto/autogenerated/ts/types.js'
|
||||||
const DeadLineMetadata = (deadline = 10 * 1000) => ({ deadline: Date.now() + deadline })
|
const DeadLineMetadata = (deadline = 10 * 1000) => ({ deadline: Date.now() + deadline })
|
||||||
type EncryptedData = { iv: string, encrypted: string }
|
type EncryptedData = { iv: string, encrypted: string }
|
||||||
type Seed = { plaintextSeed: string[], encryptedSeed: EncryptedData }
|
type Seed = { plaintextSeed: string[], encryptedSeed: EncryptedData }
|
||||||
export class Unlocker {
|
export class Unlocker {
|
||||||
|
|
||||||
settings: MainSettings
|
settings: MainSettings
|
||||||
storage: Storage
|
storage: Storage
|
||||||
abortController = new AbortController()
|
abortController = new AbortController()
|
||||||
subbedToBackups = false
|
subbedToBackups = false
|
||||||
|
nodePub: string|null =null
|
||||||
log = getLogger({ component: "unlocker" })
|
log = getLogger({ component: "unlocker" })
|
||||||
constructor(settings: MainSettings, storage: Storage) {
|
constructor(settings: MainSettings, storage: Storage) {
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
|
|
@ -68,6 +71,7 @@ export class Unlocker {
|
||||||
const info = await this.GetLndInfo(ln)
|
const info = await this.GetLndInfo(ln)
|
||||||
if (info.ok) {
|
if (info.ok) {
|
||||||
this.log("the wallet is already unlocked with pub:", info.pub)
|
this.log("the wallet is already unlocked with pub:", info.pub)
|
||||||
|
this.nodePub = info.pub
|
||||||
return { ln, pub: info.pub, action: 'noaction' }
|
return { ln, pub: info.pub, action: 'noaction' }
|
||||||
}
|
}
|
||||||
if (info.failure !== 'locked') {
|
if (info.failure !== 'locked') {
|
||||||
|
|
@ -82,6 +86,7 @@ export class Unlocker {
|
||||||
throw new Error("failed to unlock lnd wallet " + infoAfter.failure)
|
throw new Error("failed to unlock lnd wallet " + infoAfter.failure)
|
||||||
}
|
}
|
||||||
this.log("unlocked wallet with pub:", infoAfter.pub)
|
this.log("unlocked wallet with pub:", infoAfter.pub)
|
||||||
|
this.nodePub = infoAfter.pub
|
||||||
return { ln, pub: infoAfter.pub, action: 'unlocked' }
|
return { ln, pub: infoAfter.pub, action: 'unlocked' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,12 +127,24 @@ export class Unlocker {
|
||||||
if (!info || !info.ok) {
|
if (!info || !info.ok) {
|
||||||
throw new Error("failed to init lnd wallet " + (info ? info.failure : "unknown error"))
|
throw new Error("failed to init lnd wallet " + (info ? info.failure : "unknown error"))
|
||||||
}
|
}
|
||||||
|
this.nodePub = info.pub
|
||||||
await this.storage.liquidityStorage.SaveNodeSeed(info.pub, JSON.stringify(seed.encryptedSeed))
|
await this.storage.liquidityStorage.SaveNodeSeed(info.pub, JSON.stringify(seed.encryptedSeed))
|
||||||
this.log("created wallet with pub:", info.pub)
|
this.log("created wallet with pub:", info.pub)
|
||||||
return { ln, pub: info.pub }
|
return { ln, pub: info.pub }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetSeed = async (): Promise<Types.LndSeed> => {
|
||||||
|
if (!this.nodePub) {
|
||||||
|
throw new Error("node pub not found")
|
||||||
|
}
|
||||||
|
const encrypted = await this.storage.liquidityStorage.GetNoodeSeed(this.nodePub)
|
||||||
|
if (!encrypted || !encrypted.seed) {
|
||||||
|
throw new Error("seed not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
const decrypted = this.DecryptWalletSeed(JSON.parse(encrypted.seed))
|
||||||
|
return { seed: decrypted }
|
||||||
|
}
|
||||||
|
|
||||||
GetLndInfo = async (ln: LightningClient): Promise<{ ok: false, failure: 'locked' | 'unknown' } | { ok: true, pub: string }> => {
|
GetLndInfo = async (ln: LightningClient): Promise<{ ok: false, failure: 'locked' | 'unknown' } | { ok: true, pub: string }> => {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,6 @@ export default class Handler {
|
||||||
open_channels: openChannels.map(c => ({ active: c.active, capacity: Number(c.capacity), channel_id: c.chanId, lifetime: Number(c.lifetime), local_balance: Number(c.localBalance), remote_balance: Number(c.remoteBalance) })),
|
open_channels: openChannels.map(c => ({ active: c.active, capacity: Number(c.capacity), channel_id: c.chanId, lifetime: Number(c.lifetime), local_balance: Number(c.localBalance), remote_balance: Number(c.remoteBalance) })),
|
||||||
channel_routing: Object.values(routingMap)
|
channel_routing: Object.values(routingMap)
|
||||||
}],
|
}],
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,6 +26,9 @@ export default (mainHandler: Main): Types.ServerMethods => {
|
||||||
if (err != null) throw new Error(err.message)
|
if (err != null) throw new Error(err.message)
|
||||||
return mainHandler.appUserManager.BanUser(req.user_id)
|
return mainHandler.appUserManager.BanUser(req.user_id)
|
||||||
},
|
},
|
||||||
|
GetSeed: async ({ ctx }) => {
|
||||||
|
return mainHandler.unlocker.GetSeed()
|
||||||
|
},
|
||||||
SetMockInvoiceAsPaid: async ({ ctx, req }) => {
|
SetMockInvoiceAsPaid: async ({ ctx, req }) => {
|
||||||
const err = Types.SetMockInvoiceAsPaidRequestValidate(req, {
|
const err = Types.SetMockInvoiceAsPaidRequestValidate(req, {
|
||||||
invoice_CustomCheck: invoice => invoice !== '',
|
invoice_CustomCheck: invoice => invoice !== '',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { DataSource, EntityManager, MoreThan } from "typeorm"
|
import { DataSource, EntityManager, IsNull, MoreThan, Not } from "typeorm"
|
||||||
import { LspOrder } from "./entity/LspOrder.js";
|
import { LspOrder } from "./entity/LspOrder.js";
|
||||||
import TransactionsQueue, { TX } from "./transactionsQueue.js";
|
import TransactionsQueue, { TX } from "./transactionsQueue.js";
|
||||||
import { LndNodeInfo } from "./entity/LndNodeInfo.js";
|
import { LndNodeInfo } from "./entity/LndNodeInfo.js";
|
||||||
|
|
@ -20,6 +20,10 @@ export class LiquidityStorage {
|
||||||
return this.txQueue.PushToQueue<LspOrder>({ exec: async db => db.getRepository(LspOrder).save(entry), dbTx: false })
|
return this.txQueue.PushToQueue<LspOrder>({ exec: async db => db.getRepository(LspOrder).save(entry), dbTx: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async GetNoodeSeed(pubkey: string) {
|
||||||
|
return this.DB.getRepository(LndNodeInfo).findOne({ where: { pubkey, seed:Not(IsNull()) } })
|
||||||
|
}
|
||||||
|
|
||||||
async SaveNodeSeed(pubkey: string, seed: string) {
|
async SaveNodeSeed(pubkey: string, seed: string) {
|
||||||
const existing = await this.DB.getRepository(LndNodeInfo).findOne({ where: { pubkey } })
|
const existing = await this.DB.getRepository(LndNodeInfo).findOne({ where: { pubkey } })
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue