btcpayserver/BTCPayServer/wwwroot/swagger/v1/swagger.template.lightning.store.json
d11n 641bdcff31
Histograms: Add Lightning data and API endpoints (#6217)
* Histograms: Add Lightning data and API endpoints

Ported over from the mobile-working-branch.

Adds histogram data for Lightning and exposes the wallet/lightning histogram data via the API. It also add a dashboard graph for the Lightning balance.

Caveat: The Lightning histogram is calculated by using the current channel balance and going backwards through as much invoices and transactions as we have. The "start" of the LN graph data might not be accurate though. That's because we don't track (and not even have) the LN onchain data. It is calculated by using the current channel balance and going backwards through as much invoices and transactions as we have. So the historic graph data for LN is basically a best effort of trying to reconstruct it with what we have: The LN channel transactions.

* More timeframes

* Refactoring: Remove redundant WalletHistogram types

* Remove store property from dashboard tile view models

* JS error fixes
2024-11-05 21:40:37 +09:00

958 lines
38 KiB
JSON

{
"paths": {
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/info": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get node information",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "View information about the lightning node",
"operationId": "StoreLightningNodeApi_GetInfo",
"responses": {
"200": {
"description": "Lightning node information such as reachable nodeinfos",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningNodeInformationData"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"security": [
{
"API_Key": [
"btcpay.store.canuselightningnode"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/balance": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get node balance",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "View balance of the lightning node",
"operationId": "StoreLightningNodeApi_GetBalance",
"responses": {
"200": {
"description": "Lightning node balance for on-chain and off-chain funds",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningNodeBalanceData"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"security": [
{
"API_Key": [
"btcpay.store.canuselightningnode"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/histogram": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get node balance histogram",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "View balance histogram of the lightning node",
"operationId": "StoreLightningNodeApi_GetHistogram",
"responses": {
"200": {
"description": "Lightning node balance histogram for off-chain funds",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HistogramData"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"security": [
{
"API_Key": [
"btcpay.store.canuselightningnode"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/connect": {
"post": {
"tags": [
"Lightning (Store)"
],
"summary": "Connect to lightning node",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "Connect to another lightning node.",
"operationId": "StoreLightningNodeApi_ConnectToNode",
"responses": {
"200": {
"description": "Successfully connected"
},
"422": {
"description": "Unable to validate the request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"400": {
"description": "Wellknown error codes are: `could-not-connect`",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ConnectToNodeRequest"
}
}
}
},
"security": [
{
"API_Key": [
"btcpay.store.cancreatelightninginvoice"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/channels": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get channels",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "View information about the current channels of the lightning node",
"operationId": "StoreLightningNodeApi_GetChannels",
"responses": {
"200": {
"description": "list of channels",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LightningChannelData"
}
}
}
}
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"security": [
{
"API_Key": [
"btcpay.store.cancreatelightninginvoice"
],
"Basic": []
}
]
},
"post": {
"tags": [
"Lightning (Store)"
],
"summary": "Open channel",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "Open a channel with another lightning node. You should connect to that node first.",
"operationId": "StoreLightningNodeApi_OpenChannel",
"responses": {
"200": {
"description": "Successfully opened"
},
"422": {
"description": "Unable to validate the request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"400": {
"description": "Wellknown error codes are: `channel-already-exists`, `cannot-afford-funding`, `need-more-confirmations`, `peer-not-connected`",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OpenLightningChannelRequest"
}
}
}
},
"security": [
{
"API_Key": [
"btcpay.store.cancreatelightninginvoice"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/address": {
"post": {
"tags": [
"Lightning (Store)"
],
"summary": "Get deposit address",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string",
"description": "A bitcoin address belonging to the lightning node"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "Get an on-chain deposit address for the lightning node ",
"operationId": "StoreLightningNodeApi_GetDepositAddress",
"responses": {
"200": {
"description": "deposit address",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"security": [
{
"API_Key": [
"btcpay.store.cancreatelightninginvoice"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/payments/{paymentHash}": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get payment",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
},
{
"name": "paymentHash",
"in": "path",
"required": true,
"description": "The payment hash of the lightning payment.",
"schema": {
"type": "string"
}
}
],
"description": "View information about the requested lightning payment",
"operationId": "StoreLightningNodeApi_GetPayment",
"responses": {
"200": {
"description": "Lightning payment data",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningPaymentData"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration or the specified invoice was not found "
}
},
"security": [
{
"API_Key": [
"btcpay.store.canuselightningnode"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/{id}": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get invoice",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
},
{
"name": "id",
"in": "path",
"required": true,
"description": "The id of the lightning invoice.",
"schema": {
"type": "string"
}
}
],
"description": "View information about the requested lightning invoice",
"operationId": "StoreLightningNodeApi_GetInvoice",
"responses": {
"200": {
"description": "Lightning invoice data",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningInvoiceData"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration or the specified invoice was not found "
}
},
"security": [
{
"API_Key": [
"btcpay.store.canviewlightninginvoice"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/pay": {
"post": {
"tags": [
"Lightning (Store)"
],
"summary": "Pay Lightning Invoice",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "Pay a lightning invoice. In case the payment response times out, the status will be reported as pending and the final status can be resolved using the [Get payment](#operation/StoreLightningNodeApi_GetPayment) endpoint. The default wait time for payment responses is 30 seconds — it might take longer if multiple routes are tried or a hold invoice is getting paid.",
"operationId": "StoreLightningNodeApi_PayInvoice",
"responses": {
"200": {
"description": "Successfully paid",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningPaymentData"
}
}
}
},
"202": {
"description": "Payment initiated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningPaymentData"
}
}
}
},
"422": {
"description": "Unable to validate the request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"400": {
"description": "Wellknown error codes are: `could-not-find-route`, `generic-error`",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PayLightningInvoiceRequest"
}
}
}
},
"security": [
{
"API_Key": [
"btcpay.store.cancreatelightninginvoice"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get invoices",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
},
{
"name": "pendingOnly",
"in": "query",
"required": false,
"description": "Limit to pending invoices only",
"schema": {
"type": "boolean",
"nullable": true,
"default": false
}
},
{
"name": "offsetIndex",
"in": "query",
"required": false,
"description": "The index of an invoice that will be used as the start of the list",
"schema": {
"type": "number",
"nullable": true,
"default": 0
}
}
],
"description": "View information about the lightning invoices",
"operationId": "StoreLightningNodeApi_GetInvoices",
"responses": {
"200": {
"description": "Lightning invoice data",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LightningInvoiceData"
}
}
}
}
},
"401": {
"description": "Missing authorization",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"default": {
"description": "Unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
},
"security": [
{
"API_Key": [
"btcpay.store.canviewlightninginvoice"
],
"Basic": []
}
]
},
"post": {
"tags": [
"Lightning (Store)"
],
"summary": "Create lightning invoice",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
}
],
"description": "Create a lightning invoice.",
"operationId": "StoreLightningNodeApi_CreateInvoice",
"responses": {
"200": {
"description": "Successfully created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LightningInvoiceData"
}
}
}
},
"400": {
"description": "Wellknown error codes are: `invoice-error`",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"404": {
"description": "The lightning node configuration was not found"
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateLightningInvoiceRequest"
}
}
}
},
"security": [
{
"API_Key": [
"btcpay.server.cancreatelightninginvoiceinternalnode"
],
"Basic": []
}
]
}
},
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/payments": {
"get": {
"tags": [
"Lightning (Store)"
],
"summary": "Get payments",
"parameters": [
{
"name": "cryptoCode",
"in": "path",
"required": true,
"description": "The cryptoCode of the lightning-node to query",
"schema": {
"type": "string"
},
"example": "BTC"
},
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
},
{
"name": "includePending",
"in": "query",
"required": false,
"description": "Also include pending payments",
"schema": {
"type": "boolean",
"nullable": true,
"default": false
}
},
{
"name": "offsetIndex",
"in": "query",
"required": false,
"description": "The index of an invoice that will be used as the start of the list",
"schema": {
"type": "number",
"nullable": true,
"default": 0
}
}
],
"description": "View information about the lightning payments",
"operationId": "StoreLightningNodeApi_GetPayments",
"responses": {
"200": {
"description": "Lightning payment data",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LightningPaymentData"
}
}
}
}
},
"401": {
"description": "Missing authorization",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"503": {
"description": "Unable to access the lightning node"
},
"default": {
"description": "Unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
},
"security": [
{
"API_Key": [
"btcpay.store.cancreatelightninginvoice"
],
"Basic": []
}
]
}
}
},
"tags": [
{
"name": "Lightning (Store)",
"description": "Lightning (Store) operations"
}
]
}