GreenField: Handle status codes, error models consistently

This commit is contained in:
Kukks
2020-06-03 11:58:49 +02:00
parent b9ef5af5d7
commit f313a5f221
7 changed files with 316 additions and 194 deletions

View File

@@ -0,0 +1,26 @@
using System;
using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Controllers.GreenField
{
public static class GreenFieldUtils
{
public static IActionResult GetValidationResponse(this ControllerBase controller)
{
return controller.UnprocessableEntity( new ValidationProblemDetails(controller.ModelState));
}
public static IActionResult GetExceptionResponse(this ControllerBase controller, Exception e)
{
return GetGeneralErrorResponse(controller, e.Message);
}
public static IActionResult GetGeneralErrorResponse(this ControllerBase controller, string error)
{
return controller.BadRequest( new ProblemDetails()
{
Detail = error
});
}
}
}

View File

@@ -44,8 +44,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
catch (Exception e) catch (Exception e)
{ {
ModelState.AddModelError(string.Empty, e.Message); return this.GetExceptionResponse(e);
return BadRequest(new ValidationProblemDetails(ModelState));
} }
} }
@@ -73,8 +72,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
catch (Exception e) catch (Exception e)
{ {
ModelState.AddModelError(string.Empty, e.Message); return this.GetExceptionResponse(e);
return BadRequest(new ValidationProblemDetails(ModelState));
} }
return Ok(); return Ok();
@@ -103,8 +101,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
catch (Exception e) catch (Exception e)
{ {
ModelState.AddModelError(string.Empty, e.Message); return this.GetExceptionResponse(e);
return BadRequest(new ValidationProblemDetails(ModelState));
} }
} }
@@ -157,13 +154,11 @@ namespace BTCPayServer.Controllers.GreenField
return Ok(); return Ok();
} }
ModelState.AddModelError(string.Empty, response.Result.ToString()); return this.GetGeneralErrorResponse(response.Result.ToString());
return BadRequest(new ValidationProblemDetails(ModelState));
} }
catch (Exception e) catch (Exception e)
{ {
ModelState.AddModelError(string.Empty, e.Message); return this.GetExceptionResponse(e);
return BadRequest(new ValidationProblemDetails(ModelState));
} }
} }
@@ -193,7 +188,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
catch (Exception) catch (Exception)
{ {
ModelState.AddModelError(nameof(lightningInvoice), "The BOLT11 invoice was invalid."); ModelState.AddModelError(nameof(lightningInvoice.Invoice), "The BOLT11 invoice was invalid.");
} }
if (CheckValidation(out var errorActionResult)) if (CheckValidation(out var errorActionResult))
@@ -204,17 +199,13 @@ namespace BTCPayServer.Controllers.GreenField
var result = await lightningClient.Pay(lightningInvoice.Invoice); var result = await lightningClient.Pay(lightningInvoice.Invoice);
switch (result.Result) switch (result.Result)
{ {
case PayResult.Ok:
return Ok();
case PayResult.CouldNotFindRoute: case PayResult.CouldNotFindRoute:
ModelState.AddModelError(nameof(lightningInvoice.Invoice), "Could not find route"); return this.GetGeneralErrorResponse("Could not find route");
break;
case PayResult.Error: case PayResult.Error:
ModelState.AddModelError(nameof(lightningInvoice.Invoice), result.ErrorDetail); return this.GetGeneralErrorResponse(result.ErrorDetail);
break;
} }
return BadRequest(new ValidationProblemDetails(ModelState)); return Ok();
} }
public virtual async Task<IActionResult> GetInvoice(string cryptoCode, string id) public virtual async Task<IActionResult> GetInvoice(string cryptoCode, string id)
@@ -237,8 +228,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
catch (Exception e) catch (Exception e)
{ {
ModelState.AddModelError(string.Empty, e.Message); return this.GetExceptionResponse(e);
return BadRequest(new ValidationProblemDetails(ModelState));
} }
} }
@@ -269,8 +259,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
catch (Exception e) catch (Exception e)
{ {
ModelState.AddModelError(string.Empty, e.Message); return this.GetExceptionResponse(e);
return BadRequest(new ValidationProblemDetails(ModelState));
} }
} }
@@ -292,7 +281,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
{ {
result = BadRequest(new ValidationProblemDetails(ModelState)); result = this.GetValidationResponse();
return true; return true;
} }

View File

@@ -137,7 +137,7 @@ namespace BTCPayServer.Controllers.GreenField
if (!string.IsNullOrEmpty(data.CustomCSSLink) && data.CustomCSSLink.Length > 500) if (!string.IsNullOrEmpty(data.CustomCSSLink) && data.CustomCSSLink.Length > 500)
ModelState.AddModelError(nameof(data.CustomCSSLink), "CustomCSSLink is 500 chars max"); ModelState.AddModelError(nameof(data.CustomCSSLink), "CustomCSSLink is 500 chars max");
return !ModelState.IsValid ? BadRequest(new ValidationProblemDetails(ModelState)) : null; return !ModelState.IsValid ? this.GetValidationResponse() :null;
} }
private static Client.Models.PaymentRequestData FromModel(PaymentRequestData data) private static Client.Models.PaymentRequestData FromModel(PaymentRequestData data)

View File

@@ -47,7 +47,7 @@ namespace BTCPayServer.Controllers.GreenField
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpDelete("~/api/v1/stores/{storeId}")] [HttpDelete("~/api/v1/stores/{storeId}")]
public async Task<ActionResult> RemoveStore(string storeId) public async Task<IActionResult> RemoveStore(string storeId)
{ {
var store = HttpContext.GetStoreData(); var store = HttpContext.GetStoreData();
if (store == null) if (store == null)
@@ -57,8 +57,8 @@ namespace BTCPayServer.Controllers.GreenField
if (!_storeRepository.CanDeleteStores()) if (!_storeRepository.CanDeleteStores())
{ {
ModelState.AddModelError(string.Empty, "BTCPay Server is using a database server that does not allow you to remove stores."); return this.GetGeneralErrorResponse(
return BadRequest(new ValidationProblemDetails(ModelState)); "BTCPay Server is using a database server that does not allow you to remove stores.");
} }
await _storeRepository.RemoveStore(storeId, _userManager.GetUserId(User)); await _storeRepository.RemoveStore(storeId, _userManager.GetUserId(User));
return Ok(); return Ok();
@@ -194,8 +194,8 @@ namespace BTCPayServer.Controllers.GreenField
ModelState.AddModelError(nameof(request.MonitoringExpiration), "InvoiceExpiration can only be between 10 and 34560 mins"); ModelState.AddModelError(nameof(request.MonitoringExpiration), "InvoiceExpiration can only be between 10 and 34560 mins");
if(request.PaymentTolerance < 0 && request.PaymentTolerance > 100) if(request.PaymentTolerance < 0 && request.PaymentTolerance > 100)
ModelState.AddModelError(nameof(request.PaymentTolerance), "PaymentTolerance can only be between 0 and 100 percent"); ModelState.AddModelError(nameof(request.PaymentTolerance), "PaymentTolerance can only be between 0 and 100 percent");
return !ModelState.IsValid ? BadRequest(new ValidationProblemDetails(ModelState)) : null; return !ModelState.IsValid ? this.GetValidationResponse() : null;
} }
} }
} }

View File

@@ -62,16 +62,21 @@ namespace BTCPayServer.Controllers.GreenField
[AllowAnonymous] [AllowAnonymous]
[HttpPost("~/api/v1/users")] [HttpPost("~/api/v1/users")]
public async Task<ActionResult<ApplicationUserData>> CreateUser(CreateApplicationUserRequest request, CancellationToken cancellationToken = default) public async Task<IActionResult> CreateUser(CreateApplicationUserRequest request, CancellationToken cancellationToken = default)
{ {
if (request?.Email is null) if (request?.Email is null)
return BadRequest(CreateValidationProblem(nameof(request.Email), "Email is missing")); ModelState.AddModelError(nameof(request.Email), "Email is missing");
if (!Validation.EmailValidator.IsEmail(request.Email)) if (!string.IsNullOrEmpty(request?.Email) && !Validation.EmailValidator.IsEmail(request.Email))
{ {
return BadRequest(CreateValidationProblem(nameof(request.Email), "Invalid email")); ModelState.AddModelError(nameof(request.Email), "Invalid email");
} }
if (request?.Password is null) if (request?.Password is null)
return BadRequest(CreateValidationProblem(nameof(request.Password), "Password is missing")); ModelState.AddModelError(nameof(request.Password), "Password is missing");
if (!ModelState.IsValid)
{
return this.GetValidationResponse();
}
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any(); var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
var policies = await _settingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings(); var policies = await _settingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
var isAuth = User.Identity.AuthenticationType == GreenFieldConstants.AuthenticationType; var isAuth = User.Identity.AuthenticationType == GreenFieldConstants.AuthenticationType;
@@ -113,7 +118,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
ModelState.AddModelError(nameof(request.Password), error.Description); ModelState.AddModelError(nameof(request.Password), error.Description);
} }
return BadRequest(new ValidationProblemDetails(ModelState)); return this.GetValidationResponse();
} }
if (!isAdmin) if (!isAdmin)
{ {
@@ -127,7 +132,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
ModelState.AddModelError(string.Empty, error.Description); ModelState.AddModelError(string.Empty, error.Description);
} }
return BadRequest(new ValidationProblemDetails(ModelState)); return this.GetValidationResponse();
} }
if (request.IsAdministrator is true) if (request.IsAdministrator is true)
@@ -152,13 +157,6 @@ namespace BTCPayServer.Controllers.GreenField
return CreatedAtAction(string.Empty, user); return CreatedAtAction(string.Empty, user);
} }
private ValidationProblemDetails CreateValidationProblem(string propertyName, string errorMessage)
{
var modelState = new ModelStateDictionary();
modelState.AddModelError(propertyName, errorMessage);
return new ValidationProblemDetails(modelState);
}
private static ApplicationUserData FromModel(ApplicationUser data) private static ApplicationUserData FromModel(ApplicationUser data)
{ {
return new ApplicationUserData() return new ApplicationUserData()

View File

@@ -30,7 +30,7 @@
} }
} }
}, },
"400": { "422": {
"description": "A list of errors that occurred", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
@@ -40,8 +40,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"security": [ "security": [
@@ -77,8 +90,8 @@
"200": { "200": {
"description": "Successfully connected" "description": "Successfully connected"
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to connect to the lightning node", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -87,8 +100,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -145,17 +171,20 @@
} }
}, },
"400": { "400": {
"description": "A list of errors that occurred", "description": "An error occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/ValidationProblemDetails" "$ref": "#/components/schemas/ProblemDetails"
} }
} }
} }
}, },
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"security": [ "security": [
@@ -189,8 +218,8 @@
"200": { "200": {
"description": "Successfully opened" "description": "Successfully opened"
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to connect to the lightning node", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -199,8 +228,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -253,18 +295,11 @@
} }
} }
}, },
"400": {
"description": "A list of errors that occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"security": [ "security": [
@@ -316,18 +351,11 @@
} }
} }
}, },
"400": {
"description": "A list of errors that occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration or the specified invoice was not found "
} }
}, },
"security": [ "security": [
@@ -363,8 +391,8 @@
"200": { "200": {
"description": "Successfully paid" "description": "Successfully paid"
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to pay the lightning invoice", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -373,8 +401,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -427,8 +468,8 @@
} }
} }
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to create the lightning invoice", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -437,8 +478,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {

View File

@@ -3,19 +3,10 @@
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/info": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/info": {
"get": { "get": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Get node information", "summary": "Get node information",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -24,6 +15,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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", "description": "View information about the lightning node",
@@ -39,7 +39,7 @@
} }
} }
}, },
"400": { "422": {
"description": "A list of errors that occurred", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
@@ -49,14 +49,27 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
@@ -66,19 +79,10 @@
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/connect": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/connect": {
"post": { "post": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Connect to lightning node", "summary": "Connect to lightning node",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -87,6 +91,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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.", "description": "Connect to another lightning node.",
@@ -95,8 +108,8 @@
"200": { "200": {
"description": "Successfully connected" "description": "Successfully connected"
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to connect to the lightning node", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -105,8 +118,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -122,7 +148,7 @@
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
@@ -132,19 +158,10 @@
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/channels": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/channels": {
"get": { "get": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Get channels", "summary": "Get channels",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -153,6 +170,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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", "description": "View information about the current channels of the lightning node",
@@ -172,23 +198,26 @@
} }
}, },
"400": { "400": {
"description": "A list of errors that occurred", "description": "An error occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/ValidationProblemDetails" "$ref": "#/components/schemas/ProblemDetails"
} }
} }
} }
}, },
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
@@ -196,19 +225,10 @@
}, },
"post": { "post": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Open channel", "summary": "Open channel",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -217,6 +237,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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.", "description": "Open a channel with another lightning node. You should connect to that node first.",
@@ -225,8 +254,8 @@
"200": { "200": {
"description": "Successfully opened" "description": "Successfully opened"
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to connect to the lightning node", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -235,8 +264,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -252,7 +294,7 @@
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
@@ -262,19 +304,10 @@
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/address": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/address": {
"get": { "get": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Get deposit address", "summary": "Get deposit address",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -283,6 +316,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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 ", "description": "Get an on-chain deposit address for the lightning node ",
@@ -298,46 +340,31 @@
} }
} }
}, },
"400": {
"description": "A list of errors that occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
] ]
} }
}, },
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/{id}": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/{id}": {
"get": { "get": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Get invoice", "summary": "Get invoice",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -347,6 +374,15 @@
"type": "string" "type": "string"
} }
}, },
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning-node configuration to query",
"schema": {
"type": "string"
}
},
{ {
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -370,24 +406,17 @@
} }
} }
}, },
"400": {
"description": "A list of errors that occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration or the specified invoice was not found "
} }
}, },
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
@@ -397,19 +426,10 @@
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/pay": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/pay": {
"post": { "post": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Pay Lightning Invoice", "summary": "Pay Lightning Invoice",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -418,6 +438,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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.", "description": "Pay a lightning invoice.",
@@ -426,8 +455,8 @@
"200": { "200": {
"description": "Successfully paid" "description": "Successfully paid"
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to pay the lightning invoice", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -436,8 +465,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -453,7 +495,7 @@
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.canuselightningnode" "btcpay.server.canuseinternallightningnode"
], ],
"Basic": [] "Basic": []
} }
@@ -463,19 +505,10 @@
"/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices": { "/api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices": {
"post": { "post": {
"tags": [ "tags": [
"Lightning (Store)" "Lightning (Internal Node)"
], ],
"summary": "Create lightning invoice", "summary": "Create lightning invoice",
"parameters": [ "parameters": [
{
"name": "storeId",
"in": "path",
"required": true,
"description": "The store id with the lightning node configuration you wish to use",
"schema": {
"type": "string"
}
},
{ {
"name": "cryptoCode", "name": "cryptoCode",
"in": "path", "in": "path",
@@ -484,6 +517,15 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"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.", "description": "Create a lightning invoice.",
@@ -499,8 +541,8 @@
} }
} }
}, },
"400": { "422": {
"description": "A list of errors that occurred when attempting to create the lightning invoice", "description": "A list of errors that occurred",
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
@@ -509,8 +551,21 @@
} }
} }
}, },
"400": {
"description": "An error occurred",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"403": { "403": {
"description": "If you are authenticated but forbidden" "description": "If you are authenticated but forbidden"
},
"404": {
"description": "The lightning node configuration was not found"
} }
}, },
"requestBody": { "requestBody": {
@@ -526,7 +581,7 @@
"security": [ "security": [
{ {
"API Key": [ "API Key": [
"btcpay.store.cancreatelightninginvoice" "btcpay.server.cancreatelightninginvoiceinternalnode"
], ],
"Basic": [] "Basic": []
} }
@@ -536,7 +591,7 @@
}, },
"tags": [ "tags": [
{ {
"name": "Lightning (Store)" "name": "Lightning (Internal Node)"
} }
] ]
} }