fix metrics data
This commit is contained in:
parent
f94956e136
commit
ebca846740
13 changed files with 4930 additions and 5193 deletions
|
|
@ -21,11 +21,12 @@ import { LspOrder1718387847693 } from './build/src/services/storage/migrations/1
|
|||
import { LndNodeInfo1720187506189 } from './build/src/services/storage/migrations/1720187506189-lnd_node_info.js'
|
||||
import { LiquidityProvider1719335699480 } from './build/src/services/storage/migrations/1719335699480-liquidity_provider.js'
|
||||
import { CreateInviteTokenTable1721751414878 } from './build/src/services/storage/migrations/1721751414878-create_invite_token_table.js'
|
||||
import { PaymentIndex1721760297610 } from './build/src/services/storage/migrations/1721760297610-payment_index.js'
|
||||
export default new DataSource({
|
||||
type: "sqlite",
|
||||
database: "db.sqlite",
|
||||
// logging: true,
|
||||
migrations: [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, CreateInviteTokenTable1721751414878],
|
||||
migrations: [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610],
|
||||
entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment,
|
||||
UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment, LspOrder, LndNodeInfo, TrackedProvider, InviteToken],
|
||||
// synchronize: true,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
import { DataSource } from "typeorm"
|
||||
import { LspOrder } from "./build/src/services/storage/entity/LspOrder.js"
|
||||
|
||||
|
||||
import { BalanceEvent } from "./build/src/services/storage/entity/BalanceEvent.js"
|
||||
import { ChannelBalanceEvent } from "./build/src/services/storage/entity/ChannelsBalanceEvent.js"
|
||||
import { ChannelRouting } from "./build/src/services/storage/entity/ChannelRouting.js"
|
||||
import { LndMetrics1703170330183 } from './build/src/services/storage/migrations/1703170330183-lnd_metrics.js'
|
||||
import { ChannelRouting1709316653538 } from './build/src/services/storage/migrations/1709316653538-channel_routing.js'
|
||||
|
||||
export default new DataSource({
|
||||
type: "sqlite",
|
||||
database: "db.sqlite",
|
||||
entities: [LspOrder],
|
||||
database: "metrics.sqlite",
|
||||
entities: [BalanceEvent, ChannelBalanceEvent, ChannelRouting],
|
||||
migrations: [LndMetrics1703170330183, ChannelRouting1709316653538]
|
||||
});
|
||||
|
||||
//npx typeorm migration:generate ./src/services/storage/migrations/htlc_count -d ./metricsDatasource.js
|
||||
|
|
@ -185,9 +185,9 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
|
||||
- __User__:
|
||||
- expected context content
|
||||
- __user_id__: _string_
|
||||
- __app_id__: _string_
|
||||
- __app_user_id__: _string_
|
||||
- __user_id__: _string_
|
||||
|
||||
- __Admin__:
|
||||
- expected context content
|
||||
|
|
@ -203,8 +203,8 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
|
||||
- __GuestWithPub__:
|
||||
- expected context content
|
||||
- __app_id__: _string_
|
||||
- __pub__: _string_
|
||||
- __app_id__: _string_
|
||||
|
||||
## HTTP Methods
|
||||
### These are the http methods the client implements to communicate with the API
|
||||
|
|
@ -606,87 +606,110 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __to_unix__: _number_ *this field is optional
|
||||
- __include_operations__: _boolean_ *this field is optional
|
||||
|
||||
### SetMockAppBalanceRequest
|
||||
### RoutingEvent
|
||||
- __outgoing_channel_id__: _number_
|
||||
- __outgoing_htlc_id__: _number_
|
||||
- __timestamp_ns__: _number_
|
||||
- __offchain__: _boolean_
|
||||
- __settled__: _boolean_
|
||||
- __forward_fail_event__: _boolean_
|
||||
- __incoming_channel_id__: _number_
|
||||
- __incoming_htlc_id__: _number_
|
||||
- __event_type__: _string_
|
||||
- __incoming_amt_msat__: _number_
|
||||
- __outgoing_amt_msat__: _number_
|
||||
- __failure_string__: _string_
|
||||
|
||||
### SetMockInvoiceAsPaidRequest
|
||||
- __amount__: _number_
|
||||
- __invoice__: _string_
|
||||
|
||||
### BannedAppUser
|
||||
- __app_name__: _string_
|
||||
- __app_id__: _string_
|
||||
- __user_identifier__: _string_
|
||||
- __nostr_pub__: _string_
|
||||
|
||||
### GetPaymentStateRequest
|
||||
- __invoice__: _string_
|
||||
|
||||
### Product
|
||||
- __price_sats__: _number_
|
||||
- __id__: _string_
|
||||
- __name__: _string_
|
||||
|
||||
### GetProductBuyLinkResponse
|
||||
- __link__: _string_
|
||||
|
||||
### ClosureMigration
|
||||
- __closes_at_unix__: _number_
|
||||
|
||||
### DecodeInvoiceResponse
|
||||
- __amount__: _number_
|
||||
|
||||
### GetUserOperationsRequest
|
||||
- __latestIncomingUserToUserPayment__: _number_
|
||||
- __latestOutgoingUserToUserPayment__: _number_
|
||||
- __max_size__: _number_
|
||||
- __latestIncomingInvoice__: _number_
|
||||
- __latestOutgoingInvoice__: _number_
|
||||
- __latestIncomingTx__: _number_
|
||||
- __latestOutgoingTx__: _number_
|
||||
|
||||
### GraphPoint
|
||||
- __x__: _number_
|
||||
- __y__: _number_
|
||||
|
||||
### LndGetInfoResponse
|
||||
- __alias__: _string_
|
||||
|
||||
### NewAddressResponse
|
||||
- __address__: _string_
|
||||
|
||||
### PayAddressResponse
|
||||
- __txId__: _string_
|
||||
- __operation_id__: _string_
|
||||
- __service_fee__: _number_
|
||||
- __network_fee__: _number_
|
||||
- __txId__: _string_
|
||||
|
||||
### OpenChannelRequest
|
||||
- __closeAddress__: _string_
|
||||
- __destination__: _string_
|
||||
- __fundingAmount__: _number_
|
||||
- __pushAmount__: _number_
|
||||
|
||||
### OpenChannelResponse
|
||||
- __channelId__: _string_
|
||||
|
||||
### HandleLnurlPayResponse
|
||||
- __pr__: _string_
|
||||
- __routes__: ARRAY of: _[Empty](#Empty)_
|
||||
|
||||
### GetProductBuyLinkResponse
|
||||
- __link__: _string_
|
||||
### LinkNPubThroughTokenRequest
|
||||
- __token__: _string_
|
||||
|
||||
### CreateOneTimeInviteLinkRequest
|
||||
- __sats__: _number_ *this field is optional
|
||||
|
||||
### UsageMetric
|
||||
- __parsed_in_nano__: _number_
|
||||
- __validate_in_nano__: _number_
|
||||
- __handle_in_nano__: _number_
|
||||
- __rpc_name__: _string_
|
||||
- __batch__: _boolean_
|
||||
- __nostr__: _boolean_
|
||||
- __batch_size__: _number_
|
||||
- __processed_at_ms__: _number_
|
||||
- __parsed_in_nano__: _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_
|
||||
- __validate_in_nano__: _number_
|
||||
- __handle_in_nano__: _number_
|
||||
- __batch_size__: _number_
|
||||
|
||||
### LndMetrics
|
||||
- __nodes__: ARRAY of: _[LndNodeMetrics](#LndNodeMetrics)_
|
||||
|
||||
### Application
|
||||
- __balance__: _number_
|
||||
- __npub__: _string_
|
||||
- __name__: _string_
|
||||
- __id__: _string_
|
||||
### BanUserResponse
|
||||
- __balance_sats__: _number_
|
||||
- __banned_app_users__: ARRAY of: _[BannedAppUser](#BannedAppUser)_
|
||||
|
||||
### 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_
|
||||
### SetMockAppBalanceRequest
|
||||
- __amount__: _number_
|
||||
|
||||
### PayAddressRequest
|
||||
|
|
@ -694,39 +717,140 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __amoutSats__: _number_
|
||||
- __satsPerVByte__: _number_
|
||||
|
||||
### GetUserOperationsRequest
|
||||
- __max_size__: _number_
|
||||
- __latestIncomingInvoice__: _number_
|
||||
- __latestOutgoingInvoice__: _number_
|
||||
- __latestIncomingTx__: _number_
|
||||
- __latestOutgoingTx__: _number_
|
||||
- __latestIncomingUserToUserPayment__: _number_
|
||||
- __latestOutgoingUserToUserPayment__: _number_
|
||||
### HttpCreds
|
||||
- __url__: _string_
|
||||
- __token__: _string_
|
||||
|
||||
### Product
|
||||
- __id__: _string_
|
||||
### AuthAppRequest
|
||||
- __name__: _string_
|
||||
- __allow_user_creation__: _boolean_ *this field is optional
|
||||
|
||||
### AddAppInvoiceRequest
|
||||
- __payer_identifier__: _string_
|
||||
- __http_callback_url__: _string_
|
||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||
|
||||
### SendAppUserToAppUserPaymentRequest
|
||||
- __from_user_identifier__: _string_
|
||||
- __to_user_identifier__: _string_
|
||||
- __amount__: _number_
|
||||
|
||||
### LndGetInfoRequest
|
||||
- __nodeId__: _number_
|
||||
|
||||
### LnurlWithdrawInfoResponse
|
||||
- __defaultDescription__: _string_
|
||||
- __minWithdrawable__: _number_
|
||||
- __maxWithdrawable__: _number_
|
||||
- __balanceCheck__: _string_
|
||||
- __payLink__: _string_
|
||||
- __tag__: _string_
|
||||
- __callback__: _string_
|
||||
- __k1__: _string_
|
||||
|
||||
### LnurlPayInfoResponse
|
||||
- __tag__: _string_
|
||||
- __callback__: _string_
|
||||
- __maxSendable__: _number_
|
||||
- __minSendable__: _number_
|
||||
- __metadata__: _string_
|
||||
- __allowsNostr__: _boolean_
|
||||
- __nostrPubkey__: _string_
|
||||
|
||||
### Application
|
||||
- __id__: _string_
|
||||
- __balance__: _number_
|
||||
- __npub__: _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_
|
||||
|
||||
### AddAppUserInvoiceRequest
|
||||
- __receiver_identifier__: _string_
|
||||
- __payer_identifier__: _string_
|
||||
- __http_callback_url__: _string_
|
||||
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
|
||||
|
||||
### SendAppUserToAppPaymentRequest
|
||||
- __from_user_identifier__: _string_
|
||||
- __amount__: _number_
|
||||
|
||||
### NewAddressRequest
|
||||
- __addressType__: _[AddressType](#AddressType)_
|
||||
|
||||
### PaymentState
|
||||
- __paid_at_unix__: _number_
|
||||
- __amount__: _number_
|
||||
- __service_fee__: _number_
|
||||
- __network_fee__: _number_
|
||||
|
||||
### LndNodeMetrics
|
||||
- __channel_balance__: ARRAY of: _[GraphPoint](#GraphPoint)_
|
||||
- __pending_channels__: _number_
|
||||
- __closing_channels__: _number_
|
||||
- __forwarding_events__: _number_
|
||||
- __forwarding_fees__: _number_
|
||||
- __chain_balance__: ARRAY of: _[GraphPoint](#GraphPoint)_
|
||||
- __offline_channels__: _number_
|
||||
- __online_channels__: _number_
|
||||
- __open_channels__: ARRAY of: _[OpenChannel](#OpenChannel)_
|
||||
- __closed_channels__: ARRAY of: _[ClosedChannel](#ClosedChannel)_
|
||||
|
||||
### AddAppRequest
|
||||
- __name__: _string_
|
||||
- __allow_user_creation__: _boolean_
|
||||
|
||||
### GetAppUserLNURLInfoRequest
|
||||
- __user_identifier__: _string_
|
||||
- __base_url_override__: _string_
|
||||
|
||||
### NewInvoiceRequest
|
||||
- __memo__: _string_
|
||||
- __amountSats__: _number_
|
||||
|
||||
### LnurlLinkResponse
|
||||
- __lnurl__: _string_
|
||||
- __k1__: _string_
|
||||
|
||||
### RelaysMigration
|
||||
- __relays__: ARRAY of: _string_
|
||||
|
||||
### RequestNPubLinkingTokenRequest
|
||||
- __user_identifier__: _string_
|
||||
|
||||
### UsersInfo
|
||||
- __balance_median__: _number_
|
||||
- __total__: _number_
|
||||
- __no_balance__: _number_
|
||||
- __negative_balance__: _number_
|
||||
- __always_been_inactive__: _number_
|
||||
- __balance_avg__: _number_
|
||||
|
||||
### LndMetricsRequest
|
||||
- __to_unix__: _number_ *this field is optional
|
||||
- __from_unix__: _number_ *this field is optional
|
||||
|
||||
### AuthApp
|
||||
- __app__: _[Application](#Application)_
|
||||
- __auth_token__: _string_
|
||||
|
||||
### GetAppUserRequest
|
||||
- __user_identifier__: _string_
|
||||
|
||||
### Empty
|
||||
|
||||
### NewInvoiceResponse
|
||||
- __invoice__: _string_
|
||||
|
||||
### UserOperations
|
||||
- __toIndex__: _number_
|
||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||
- __fromIndex__: _number_
|
||||
|
||||
### GetUserOperationsResponse
|
||||
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
|
||||
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
|
||||
|
|
@ -735,200 +859,78 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
|
||||
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
|
||||
|
||||
### LndMetricsRequest
|
||||
- __from_unix__: _number_ *this field is optional
|
||||
- __to_unix__: _number_ *this field is optional
|
||||
|
||||
### AuthApp
|
||||
- __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
|
||||
- __user_identifier__: _string_
|
||||
- __service_fee_bps__: _number_
|
||||
- __network_max_fee_bps__: _number_
|
||||
- __network_max_fee_fixed__: _number_
|
||||
- __userId__: _string_
|
||||
- __balance__: _number_
|
||||
- __max_withdrawable__: _number_
|
||||
|
||||
### LndGetInfoRequest
|
||||
- __nodeId__: _number_
|
||||
|
||||
### 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
|
||||
- __invite_token__: _string_
|
||||
|
||||
### ChannelBalanceEvent
|
||||
- __block_height__: _number_
|
||||
- __channel_id__: _string_
|
||||
- __local_balance_sats__: _number_
|
||||
- __remote_balance_sats__: _number_
|
||||
### GetInviteTokenStateResponse
|
||||
- __used__: _boolean_
|
||||
|
||||
### OpenChannel
|
||||
- __channel_id__: _string_
|
||||
- __capacity__: _number_
|
||||
- __active__: _boolean_
|
||||
- __lifetime__: _number_
|
||||
- __local_balance__: _number_
|
||||
- __remote_balance__: _number_
|
||||
### LndSeed
|
||||
- __seed__: ARRAY of: _string_
|
||||
|
||||
### BanUserResponse
|
||||
- __balance_sats__: _number_
|
||||
- __banned_app_users__: ARRAY of: _[BannedAppUser](#BannedAppUser)_
|
||||
### AppsMetrics
|
||||
- __apps__: ARRAY of: _[AppMetrics](#AppMetrics)_
|
||||
|
||||
### AppUser
|
||||
- __identifier__: _string_
|
||||
- __info__: _[UserInfo](#UserInfo)_
|
||||
- __max_withdrawable__: _number_
|
||||
|
||||
### PaymentState
|
||||
- __amount__: _number_
|
||||
- __service_fee__: _number_
|
||||
- __network_fee__: _number_
|
||||
- __paid_at_unix__: _number_
|
||||
### AddProductRequest
|
||||
- __name__: _string_
|
||||
- __price_sats__: _number_
|
||||
|
||||
### MigrationUpdate
|
||||
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
||||
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
||||
### LiveUserOperation
|
||||
- __operation__: _[UserOperation](#UserOperation)_
|
||||
|
||||
### HttpCreds
|
||||
- __url__: _string_
|
||||
### RequestNPubLinkingTokenResponse
|
||||
- __token__: _string_
|
||||
|
||||
### ClosedChannel
|
||||
- __capacity__: _number_
|
||||
- __closed_height__: _number_
|
||||
### OpenChannel
|
||||
- __lifetime__: _number_
|
||||
- __local_balance__: _number_
|
||||
- __remote_balance__: _number_
|
||||
- __channel_id__: _string_
|
||||
- __capacity__: _number_
|
||||
- __active__: _boolean_
|
||||
|
||||
### LndGetInfoResponse
|
||||
- __alias__: _string_
|
||||
### PayAppUserInvoiceRequest
|
||||
- __user_identifier__: _string_
|
||||
- __invoice__: _string_
|
||||
- __amount__: _number_
|
||||
|
||||
### PayInvoiceRequest
|
||||
- __invoice__: _string_
|
||||
- __amount__: _number_
|
||||
|
||||
### SendAppUserToAppPaymentRequest
|
||||
- __from_user_identifier__: _string_
|
||||
- __amount__: _number_
|
||||
### UserInfo
|
||||
- __network_max_fee_fixed__: _number_
|
||||
- __userId__: _string_
|
||||
- __balance__: _number_
|
||||
- __max_withdrawable__: _number_
|
||||
- __user_identifier__: _string_
|
||||
- __service_fee_bps__: _number_
|
||||
- __network_max_fee_bps__: _number_
|
||||
|
||||
### OpenChannelRequest
|
||||
- __closeAddress__: _string_
|
||||
- __destination__: _string_
|
||||
- __fundingAmount__: _number_
|
||||
- __pushAmount__: _number_
|
||||
### UserOperation
|
||||
- __internal__: _boolean_
|
||||
- __paidAtUnix__: _number_
|
||||
- __type__: _[UserOperationType](#UserOperationType)_
|
||||
- __identifier__: _string_
|
||||
- __service_fee__: _number_
|
||||
- __network_fee__: _number_
|
||||
- __confirmed__: _boolean_
|
||||
- __inbound__: _boolean_
|
||||
- __amount__: _number_
|
||||
- __operationId__: _string_
|
||||
- __tx_hash__: _string_
|
||||
|
||||
### EnrollAdminTokenRequest
|
||||
- __admin_token__: _string_
|
||||
|
||||
### Empty
|
||||
|
||||
### NewAddressRequest
|
||||
- __addressType__: _[AddressType](#AddressType)_
|
||||
|
||||
### AddProductRequest
|
||||
- __name__: _string_
|
||||
- __price_sats__: _number_
|
||||
|
||||
### GetInviteTokenStateResponse
|
||||
- __used__: _boolean_
|
||||
|
||||
### EncryptionExchangeRequest
|
||||
- __publicKey__: _string_
|
||||
- __deviceId__: _string_
|
||||
|
|
@ -936,65 +938,44 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
### UsageMetrics
|
||||
- __metrics__: ARRAY of: _[UsageMetric](#UsageMetric)_
|
||||
|
||||
### AuthAppRequest
|
||||
- __name__: _string_
|
||||
- __allow_user_creation__: _boolean_ *this field is optional
|
||||
### AppMetrics
|
||||
- __fees__: _number_
|
||||
- __app__: _[Application](#Application)_
|
||||
- __received__: _number_
|
||||
- __available__: _number_
|
||||
- __total_fees__: _number_
|
||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||
- __users__: _[UsersInfo](#UsersInfo)_
|
||||
- __spent__: _number_
|
||||
- __invoices__: _number_
|
||||
|
||||
### ClosedChannel
|
||||
- __channel_id__: _string_
|
||||
- __capacity__: _number_
|
||||
- __closed_height__: _number_
|
||||
|
||||
### AddAppUserRequest
|
||||
- __identifier__: _string_
|
||||
- __fail_if_exists__: _boolean_
|
||||
- __balance__: _number_
|
||||
|
||||
### DecodeInvoiceResponse
|
||||
### MigrationUpdate
|
||||
- __closure__: _[ClosureMigration](#ClosureMigration)_ *this field is optional
|
||||
- __relays__: _[RelaysMigration](#RelaysMigration)_ *this field is optional
|
||||
|
||||
### SetMockAppUserBalanceRequest
|
||||
- __user_identifier__: _string_
|
||||
- __amount__: _number_
|
||||
|
||||
### RelaysMigration
|
||||
- __relays__: ARRAY of: _string_
|
||||
### DecodeInvoiceRequest
|
||||
- __invoice__: _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_
|
||||
- __to_user_identifier__: _string_
|
||||
- __amount__: _number_
|
||||
|
||||
### NewInvoiceRequest
|
||||
- __amountSats__: _number_
|
||||
- __memo__: _string_
|
||||
|
||||
### OpenChannelResponse
|
||||
- __channelId__: _string_
|
||||
|
||||
### LiveUserOperation
|
||||
- __operation__: _[UserOperation](#UserOperation)_
|
||||
|
||||
### LndSeed
|
||||
- __seed__: ARRAY of: _string_
|
||||
|
||||
### LnurlWithdrawInfoResponse
|
||||
- __maxWithdrawable__: _number_
|
||||
- __balanceCheck__: _string_
|
||||
- __payLink__: _string_
|
||||
- __tag__: _string_
|
||||
- __callback__: _string_
|
||||
- __k1__: _string_
|
||||
- __defaultDescription__: _string_
|
||||
- __minWithdrawable__: _number_
|
||||
|
||||
### UserOperations
|
||||
- __toIndex__: _number_
|
||||
- __operations__: ARRAY of: _[UserOperation](#UserOperation)_
|
||||
- __fromIndex__: _number_
|
||||
|
||||
### RequestNPubLinkingTokenRequest
|
||||
- __user_identifier__: _string_
|
||||
### PayInvoiceResponse
|
||||
- __preimage__: _string_
|
||||
- __amount_paid__: _number_
|
||||
- __operation_id__: _string_
|
||||
- __service_fee__: _number_
|
||||
- __network_fee__: _number_
|
||||
## Enums
|
||||
### The enumerators used in the messages
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -5,10 +5,10 @@ export type ResultError = { status: 'ERROR', reason: string }
|
|||
|
||||
export type NostrClientParams = {
|
||||
pubDestination: string
|
||||
retrieveNostrMetricsAuth: () => Promise<string | null>
|
||||
retrieveNostrUserAuth: () => Promise<string | null>
|
||||
retrieveNostrGuestWithPubAuth: () => Promise<string | null>
|
||||
retrieveNostrAdminAuth: () => Promise<string | null>
|
||||
retrieveNostrMetricsAuth: () => Promise<string | null>
|
||||
checkResult?: true
|
||||
}
|
||||
export default (params: NostrClientParams, send: (to:string, message: NostrRequest) => Promise<any>, subscribe: (to:string, message: NostrRequest, cb:(res:any)=> void) => void) => ({
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -87,19 +87,6 @@ message RoutingEvent {
|
|||
bool offchain = 11;
|
||||
bool forward_fail_event = 12;
|
||||
}
|
||||
message ChannelBalanceEvent {
|
||||
int64 block_height = 1;
|
||||
string channel_id = 2;
|
||||
int64 local_balance_sats = 3;
|
||||
int64 remote_balance_sats = 4;
|
||||
}
|
||||
|
||||
message ChainBalanceEvent {
|
||||
int64 block_height = 1;
|
||||
int64 confirmed_balance = 2;
|
||||
int64 unconfirmed_balance = 3;
|
||||
int64 total_balance = 4;
|
||||
}
|
||||
|
||||
message OpenChannel {
|
||||
string channel_id = 1;
|
||||
|
|
@ -115,29 +102,22 @@ message ClosedChannel {
|
|||
int64 closed_height =4;
|
||||
}
|
||||
|
||||
message ChannelRouting {
|
||||
string channel_id = 1;
|
||||
int64 send_errors = 2;
|
||||
int64 receive_errors = 3;
|
||||
int64 forward_errors_as_input = 4;
|
||||
int64 forward_errors_as_output = 5;
|
||||
int64 missed_forward_fee_as_input = 6;
|
||||
int64 missed_forward_fee_as_output = 7;
|
||||
int64 forward_fee_as_input = 8;
|
||||
int64 forward_fee_as_output = 9;
|
||||
int64 events_number = 10;
|
||||
message GraphPoint {
|
||||
int64 x = 1;
|
||||
int64 y = 2;
|
||||
}
|
||||
|
||||
message LndNodeMetrics {
|
||||
repeated ChannelBalanceEvent channels_balance_events = 1;
|
||||
repeated ChainBalanceEvent chain_balance_events = 2;
|
||||
repeated GraphPoint chain_balance = 1;
|
||||
repeated GraphPoint channel_balance = 2;
|
||||
int64 offline_channels = 4;
|
||||
int64 online_channels = 5;
|
||||
int64 pending_channels = 6;
|
||||
int64 closing_channels = 7;
|
||||
repeated OpenChannel open_channels = 8;
|
||||
repeated ClosedChannel closed_channels = 9;
|
||||
repeated ChannelRouting channel_routing = 10;
|
||||
int64 forwarding_events = 11;
|
||||
int64 forwarding_fees = 12;
|
||||
}
|
||||
|
||||
message LndMetrics {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export default class HtlcTracker {
|
|||
}
|
||||
log = getLogger({ component: 'htlcTracker' })
|
||||
onHtlcEvent = async (htlc: HtlcEvent) => {
|
||||
//getLogger({ component: 'debugHtlcs' })(htlc)
|
||||
/* //getLogger({ component: 'debugHtlcs' })(htlc)
|
||||
const htlcEvent = htlc.event
|
||||
if (htlcEvent.oneofKind === 'subscribedEvent') {
|
||||
return
|
||||
|
|
@ -45,10 +45,10 @@ export default class HtlcTracker {
|
|||
return this.handleSuccess(info)
|
||||
default:
|
||||
//this.log("unknown htlc event type")
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
handleForward = (fwe: ForwardEvent, { eventType, outgoingHtlcId, incomingHtlcId }: EventInfo) => {
|
||||
/* handleForward = (fwe: ForwardEvent, { eventType, outgoingHtlcId, incomingHtlcId }: EventInfo) => {
|
||||
const { info } = fwe
|
||||
const incomingAmtMsat = info ? Number(info.incomingAmtMsat) : 0
|
||||
const outgoingAmtMsat = info ? Number(info.outgoingAmtMsat) : 0
|
||||
|
|
@ -59,9 +59,9 @@ export default class HtlcTracker {
|
|||
} else if (eventType === HtlcEvent_EventType.FORWARD) {
|
||||
this.pendingForwardHtlcs.set(outgoingHtlcId, outgoingAmtMsat - incomingAmtMsat)
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
handleFailure = ({ eventType, outgoingHtlcId, incomingHtlcId, incomingChannelId, outgoingChannelId }: EventInfo) => {
|
||||
/* handleFailure = ({ eventType, outgoingHtlcId, incomingHtlcId, incomingChannelId, outgoingChannelId }: EventInfo) => {
|
||||
if (eventType === HtlcEvent_EventType.SEND && this.deleteMapEntry(outgoingHtlcId, this.pendingSendHtlcs) !== null) {
|
||||
return this.incrementSendFailures(outgoingChannelId)
|
||||
}
|
||||
|
|
@ -86,9 +86,9 @@ export default class HtlcTracker {
|
|||
return this.incrementReceiveFailures(incomingChannelId)
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
handleSuccess = ({ eventType, outgoingHtlcId, incomingHtlcId }: EventInfo) => {
|
||||
/* handleSuccess = ({ eventType, outgoingHtlcId, incomingHtlcId }: EventInfo) => {
|
||||
if (eventType === HtlcEvent_EventType.SEND) {
|
||||
this.deleteMapEntry(outgoingHtlcId, this.pendingSendHtlcs)
|
||||
} else if (eventType === HtlcEvent_EventType.RECEIVE) {
|
||||
|
|
@ -100,8 +100,8 @@ export default class HtlcTracker {
|
|||
if (this.deleteMapEntry(incomingHtlcId, this.pendingReceiveHtlcs) !== null) return
|
||||
if (this.deleteMapEntry(outgoingHtlcId, this.pendingForwardHtlcs) !== null) return
|
||||
}
|
||||
}
|
||||
|
||||
} */
|
||||
/*
|
||||
deleteMapEntry = (key: number, map: Map<number, number>) => {
|
||||
if (!map.has(key)) {
|
||||
return null
|
||||
|
|
@ -109,9 +109,9 @@ export default class HtlcTracker {
|
|||
const v = map.get(key)
|
||||
map.delete(key)
|
||||
return v || null
|
||||
}
|
||||
} */
|
||||
|
||||
incrementSendFailures = async (outgoingChannelId: number) => {
|
||||
/* incrementSendFailures = async (outgoingChannelId: number) => {
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(outgoingChannelId.toString(), { send_errors: 1 })
|
||||
}
|
||||
incrementReceiveFailures = async (incomingChannelId: number) => {
|
||||
|
|
@ -120,6 +120,6 @@ export default class HtlcTracker {
|
|||
incrementForwardFailures = async (incomingChannelId: number, outgoingChannelId: number, amt: number) => {
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(incomingChannelId.toString(), { forward_errors_as_input: 1, missed_forward_fee_as_input: amt })
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(outgoingChannelId.toString(), { forward_errors_as_output: 1, missed_forward_fee_as_output: amt })
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export default class Handler {
|
|||
remote_balance_sats: c.remoteBalanceSats,
|
||||
}))
|
||||
await this.storage.metricsStorage.SaveBalanceEvents(balanceEvent, channelsEvents)
|
||||
await this.FetchLatestForwardingEvents()
|
||||
}
|
||||
|
||||
async FetchLatestForwardingEvents() {
|
||||
|
|
@ -43,8 +44,8 @@ export default class Handler {
|
|||
const res = await this.lnd.GetForwardingHistory(latestIndex)
|
||||
const forwards = res.forwardingEvents.map(e => ({ fee: Number(e.fee), chanIdIn: e.chanIdIn, chanIdOut: e.chanIdOut, timestampNs: e.timestampNs.toString(), offset: res.lastOffsetIndex }))
|
||||
await Promise.all(forwards.map(async f => {
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(f.chanIdIn, { forward_fee_as_input: f.fee, latest_index_offset: f.offset })
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(f.chanIdOut, { forward_fee_as_output: f.fee, latest_index_offset: f.offset })
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(f.chanIdIn, { forward_fee_as_input: f.fee, latest_index_offset: f.offset, events_as_input: 1 })
|
||||
await this.storage.metricsStorage.IncrementChannelRouting(f.chanIdOut, { forward_fee_as_output: f.fee, latest_index_offset: f.offset, events_as_output: 1 })
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +177,7 @@ export default class Handler {
|
|||
total_fees: totalFees,
|
||||
invoices: receivingInvoices.length,
|
||||
|
||||
operations:[]
|
||||
operations: []
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,54 +208,60 @@ export default class Handler {
|
|||
const { totalPendingOpen, totalPendingClose } = await this.GetPendingChannelsInfo()
|
||||
const { channels: closedChannels } = await this.lnd.ListClosedChannels()
|
||||
const rawRouting = await this.storage.metricsStorage.GetChannelRouting({ from: req.from_unix, to: req.to_unix })
|
||||
const routingMap: Record<string, Types.ChannelRouting> = {}
|
||||
let totalEvents = 0
|
||||
let totalFees = 0
|
||||
rawRouting.forEach(r => {
|
||||
if (!routingMap[r.channel_id]) {
|
||||
routingMap[r.channel_id] = {
|
||||
channel_id: r.channel_id,
|
||||
send_errors: 0,
|
||||
receive_errors: 0,
|
||||
forward_errors_as_input: 0,
|
||||
forward_errors_as_output: 0,
|
||||
missed_forward_fee_as_input: 0,
|
||||
missed_forward_fee_as_output: 0,
|
||||
forward_fee_as_input: 0,
|
||||
forward_fee_as_output: 0,
|
||||
events_number: 0
|
||||
}
|
||||
}
|
||||
routingMap[r.channel_id].send_errors += r.send_errors
|
||||
routingMap[r.channel_id].receive_errors += r.receive_errors
|
||||
routingMap[r.channel_id].forward_errors_as_input += r.forward_errors_as_input
|
||||
routingMap[r.channel_id].forward_errors_as_output += r.forward_errors_as_output
|
||||
routingMap[r.channel_id].missed_forward_fee_as_input += r.missed_forward_fee_as_input
|
||||
routingMap[r.channel_id].missed_forward_fee_as_output += r.missed_forward_fee_as_output
|
||||
routingMap[r.channel_id].forward_fee_as_input += r.forward_fee_as_input
|
||||
routingMap[r.channel_id].forward_fee_as_output += r.forward_fee_as_output
|
||||
routingMap[r.channel_id].events_number++
|
||||
totalEvents += r.events_as_input
|
||||
totalFees += r.forward_fee_as_input
|
||||
})
|
||||
const { channelsBalanceEvents, chainBalanceEvents } = await this.storage.metricsStorage.GetBalanceEvents({ from: req.from_unix, to: req.to_unix })
|
||||
const chainBalance: Types.GraphPoint[] = []
|
||||
chainBalanceEvents.forEach(e => {
|
||||
if (chainBalance.length === 0) {
|
||||
chainBalance.push({ x: e.block_height, y: e.total_chain_balance })
|
||||
return
|
||||
}
|
||||
const last = chainBalance[chainBalance.length - 1]
|
||||
if (last.y !== e.total_chain_balance) {
|
||||
chainBalance.push({ x: e.block_height, y: e.total_chain_balance })
|
||||
}
|
||||
})
|
||||
const chansPerBlock = new Map()
|
||||
channelsBalanceEvents.forEach(e => {
|
||||
const height = e.balance_event.block_height
|
||||
const local = e.local_balance_sats
|
||||
const v = chansPerBlock.get(height)
|
||||
if (!v) {
|
||||
chansPerBlock.set(height, local)
|
||||
return
|
||||
}
|
||||
chansPerBlock.set(height, local + v)
|
||||
})
|
||||
|
||||
const chansBalance: Types.GraphPoint[] = []
|
||||
chansPerBlock.forEach((v, k) => {
|
||||
if (chansBalance.length === 0) {
|
||||
chansBalance.push({ x: k, y: v })
|
||||
return
|
||||
}
|
||||
const last = chansBalance[chansBalance.length - 1]
|
||||
if (last.y !== v) {
|
||||
chansBalance.push({ x: k, y: v })
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
nodes: [{
|
||||
chain_balance_events: []/*chainBalanceEvents.map(e => ({
|
||||
block_height: e.block_height,
|
||||
confirmed_balance: e.confirmed_chain_balance,
|
||||
unconfirmed_balance: e.unconfirmed_chain_balance,
|
||||
total_balance: e.total_chain_balance
|
||||
}))*/,
|
||||
channels_balance_events: []/*channelsBalanceEvents.map(e => ({
|
||||
block_height: e.balance_event.block_height,
|
||||
channel_id: e.channel_id,
|
||||
local_balance_sats: e.local_balance_sats,
|
||||
remote_balance_sats: e.remote_balance_sats
|
||||
}))*/,
|
||||
chain_balance: chainBalance,
|
||||
channel_balance: chansBalance,
|
||||
closing_channels: totalPendingClose,
|
||||
pending_channels: totalPendingOpen,
|
||||
offline_channels: totalInactive,
|
||||
online_channels: totalActive,
|
||||
closed_channels: closedChannels.map(c => ({ capacity: Number(c.capacity), channel_id: c.chanId, closed_height: c.closeHeight })),
|
||||
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)
|
||||
forwarding_events: totalEvents,
|
||||
forwarding_fees: totalFees
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ export class ChannelRouting {
|
|||
@Column({ default: 0 })
|
||||
forward_fee_as_output: number
|
||||
|
||||
@Column({ default: 0 })
|
||||
events_as_output: number
|
||||
|
||||
@Column({ default: 0 })
|
||||
events_as_input: number
|
||||
|
||||
@Column({ default: 0 })
|
||||
latest_index_offset: number
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Between, DataSource, EntityManager, FindOperator, LessThanOrEqual, MoreThanOrEqual } from "typeorm"
|
||||
import { Between, DataSource, EntityManager, FindManyOptions, FindOperator, LessThanOrEqual, MoreThanOrEqual } from "typeorm"
|
||||
import { BalanceEvent } from "./entity/BalanceEvent.js"
|
||||
import { ChannelBalanceEvent } from "./entity/ChannelsBalanceEvent.js"
|
||||
import TransactionsQueue, { TX } from "./transactionsQueue.js";
|
||||
|
|
@ -89,21 +89,25 @@ export default class {
|
|||
if (event.forward_fee_as_output) {
|
||||
await repo.increment({ day_unix: dayUnix, channel_id: channelId }, "forward_fee_as_output", event.forward_fee_as_output)
|
||||
}
|
||||
if (event.events_as_input) {
|
||||
await repo.increment({ day_unix: dayUnix, channel_id: channelId }, "events_as_input", event.events_as_input)
|
||||
}
|
||||
if (event.events_as_output) {
|
||||
await repo.increment({ day_unix: dayUnix, channel_id: channelId }, "events_as_output", event.events_as_output)
|
||||
}
|
||||
if (event.latest_index_offset) {
|
||||
await repo.update(existing.serial_id, { latest_index_offset: event.latest_index_offset })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const getTimeQuery = ({ from, to }: { from?: number, to?: number }) => {
|
||||
const getTimeQuery = ({ from, to }: { from?: number, to?: number }): FindManyOptions<{ created_at: Date }> => {
|
||||
if (!!from && !!to) {
|
||||
return { where: { created_at: Between<Date>(new Date(from * 1000), new Date(to * 1000)) } }
|
||||
return { where: { created_at: Between<Date>(new Date(from * 1000), new Date(to * 1000)) }, order: { created_at: 'ASC' } }
|
||||
} else if (!!from) {
|
||||
return { where: { created_at: MoreThanOrEqual<Date>(new Date(from * 1000)) } }
|
||||
return { where: { created_at: MoreThanOrEqual<Date>(new Date(from * 1000)) }, order: { created_at: 'ASC' } }
|
||||
} else if (!!to) {
|
||||
return { where: { created_at: LessThanOrEqual<Date>(new Date(to * 1000)) } }
|
||||
return { where: { created_at: LessThanOrEqual<Date>(new Date(to * 1000)) }, order: { created_at: 'ASC' } }
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
|
|
|||
20
src/services/storage/migrations/1724266887195-htlc_count.ts
Normal file
20
src/services/storage/migrations/1724266887195-htlc_count.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class HtlcCount1724266887195 implements MigrationInterface {
|
||||
name = 'HtlcCount1724266887195'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE "temporary_channel_routing" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "day_unix" integer NOT NULL, "channel_id" varchar NOT NULL, "send_errors" integer NOT NULL DEFAULT (0), "receive_errors" integer NOT NULL DEFAULT (0), "forward_errors_as_input" integer NOT NULL DEFAULT (0), "forward_errors_as_output" integer NOT NULL DEFAULT (0), "missed_forward_fee_as_input" integer NOT NULL DEFAULT (0), "missed_forward_fee_as_output" integer NOT NULL DEFAULT (0), "forward_fee_as_input" integer NOT NULL DEFAULT (0), "forward_fee_as_output" integer NOT NULL DEFAULT (0), "latest_index_offset" integer NOT NULL DEFAULT (0), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "events_as_output" integer NOT NULL DEFAULT (0), "events_as_input" integer NOT NULL DEFAULT (0))`);
|
||||
await queryRunner.query(`INSERT INTO "temporary_channel_routing"("serial_id", "day_unix", "channel_id", "send_errors", "receive_errors", "forward_errors_as_input", "forward_errors_as_output", "missed_forward_fee_as_input", "missed_forward_fee_as_output", "forward_fee_as_input", "forward_fee_as_output", "latest_index_offset", "created_at", "updated_at") SELECT "serial_id", "day_unix", "channel_id", "send_errors", "receive_errors", "forward_errors_as_input", "forward_errors_as_output", "missed_forward_fee_as_input", "missed_forward_fee_as_output", "forward_fee_as_input", "forward_fee_as_output", "latest_index_offset", "created_at", "updated_at" FROM "channel_routing"`);
|
||||
await queryRunner.query(`DROP TABLE "channel_routing"`);
|
||||
await queryRunner.query(`ALTER TABLE "temporary_channel_routing" RENAME TO "channel_routing"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "channel_routing" RENAME TO "temporary_channel_routing"`);
|
||||
await queryRunner.query(`CREATE TABLE "channel_routing" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "day_unix" integer NOT NULL, "channel_id" varchar NOT NULL, "send_errors" integer NOT NULL DEFAULT (0), "receive_errors" integer NOT NULL DEFAULT (0), "forward_errors_as_input" integer NOT NULL DEFAULT (0), "forward_errors_as_output" integer NOT NULL DEFAULT (0), "missed_forward_fee_as_input" integer NOT NULL DEFAULT (0), "missed_forward_fee_as_output" integer NOT NULL DEFAULT (0), "forward_fee_as_input" integer NOT NULL DEFAULT (0), "forward_fee_as_output" integer NOT NULL DEFAULT (0), "latest_index_offset" integer NOT NULL DEFAULT (0), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
||||
await queryRunner.query(`INSERT INTO "channel_routing"("serial_id", "day_unix", "channel_id", "send_errors", "receive_errors", "forward_errors_as_input", "forward_errors_as_output", "missed_forward_fee_as_input", "missed_forward_fee_as_output", "forward_fee_as_input", "forward_fee_as_output", "latest_index_offset", "created_at", "updated_at") SELECT "serial_id", "day_unix", "channel_id", "send_errors", "receive_errors", "forward_errors_as_input", "forward_errors_as_output", "missed_forward_fee_as_input", "missed_forward_fee_as_output", "forward_fee_as_input", "forward_fee_as_output", "latest_index_offset", "created_at", "updated_at" FROM "temporary_channel_routing"`);
|
||||
await queryRunner.query(`DROP TABLE "temporary_channel_routing"`);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,8 +10,9 @@ import { LndNodeInfo1720187506189 } from './1720187506189-lnd_node_info.js'
|
|||
import { TrackedProvider1720814323679 } from './1720814323679-tracked_provider.js'
|
||||
import { CreateInviteTokenTable1721751414878 } from "./1721751414878-create_invite_token_table.js"
|
||||
import { PaymentIndex1721760297610 } from './1721760297610-payment_index.js'
|
||||
import { HtlcCount1724266887195 } from './1724266887195-htlc_count.js'
|
||||
const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610]
|
||||
const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538]
|
||||
const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195]
|
||||
export const TypeOrmMigrationRunner = async (log: PubLogger, storageManager: Storage, settings: DbSettings, arg: string | undefined): Promise<boolean> => {
|
||||
if (arg === 'fake_initial_migration') {
|
||||
runFakeMigration(settings.databaseFile, [Initial1703170309875])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue