From d39ec97b9a6aa1de21a5bcfdb9a84679771f96f7 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Sun, 29 Aug 2021 19:07:12 -0700 Subject: [PATCH] Remove "enabled" option from address preview endpoint --- .../Models/OnChainPaymentMethodData.cs | 31 +++++++++++++------ .../StoreOnChainPaymentMethodsController.cs | 2 +- ...plate.stores-payment-methods.on-chain.json | 14 +++++++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs b/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs index bbea7642b..4224287c4 100644 --- a/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs +++ b/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs @@ -2,30 +2,43 @@ using NBitcoin; namespace BTCPayServer.Client.Models { - public class OnChainPaymentMethodData : OnChainPaymentMethodBaseData + public class OnChainPaymentMethodDataPreview : OnChainPaymentMethodBaseData { - /// - /// Whether the payment method is enabled - /// - public bool Enabled { get; set; } - /// /// Crypto code of the payment method /// public string CryptoCode { get; set; } - public OnChainPaymentMethodData() + public OnChainPaymentMethodDataPreview() { } - public OnChainPaymentMethodData(string cryptoCode, string derivationScheme, bool enabled, string label, RootedKeyPath accountKeyPath) + public OnChainPaymentMethodDataPreview(string cryptoCode, string derivationScheme, string label, RootedKeyPath accountKeyPath) { - Enabled = enabled; Label = label; AccountKeyPath = accountKeyPath; CryptoCode = cryptoCode; DerivationScheme = derivationScheme; } } + + public class OnChainPaymentMethodData : OnChainPaymentMethodDataPreview + { + /// + /// Whether the payment method is enabled + /// + public bool Enabled { get; set; } + + public OnChainPaymentMethodData() + { + + } + + public OnChainPaymentMethodData(string cryptoCode, string derivationScheme, bool enabled, string label, RootedKeyPath accountKeyPath) : + base(cryptoCode, derivationScheme, label, accountKeyPath) + { + Enabled = enabled; + } + } } diff --git a/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs b/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs index a231b0f6c..65a709f45 100644 --- a/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs +++ b/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs @@ -144,7 +144,7 @@ namespace BTCPayServer.Controllers.GreenField public IActionResult GetProposedOnChainPaymentMethodPreview( string storeId, string cryptoCode, - [FromBody] OnChainPaymentMethodData paymentMethodData, + [FromBody] OnChainPaymentMethodDataPreview paymentMethodData, int offset = 0, int amount = 10) { if (!GetCryptoCodeWallet(cryptoCode, out var network, out BTCPayWallet _)) diff --git a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-payment-methods.on-chain.json b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-payment-methods.on-chain.json index 612435de1..ac4f75b6a 100644 --- a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-payment-methods.on-chain.json +++ b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-payment-methods.on-chain.json @@ -361,7 +361,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OnChainPaymentMethodData" + "$ref": "#/components/schemas/OnChainPaymentMethodDataPreview" } } }, @@ -445,13 +445,21 @@ "OnChainPaymentMethodData": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/OnChainPaymentMethodBaseData" + "$ref": "#/components/schemas/OnChainPaymentMethodDataPreview" }, "properties": { "enabled": { "type": "boolean", "description": "Whether the payment method is enabled" - }, + } + } + }, + "OnChainPaymentMethodDataPreview": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/OnChainPaymentMethodBaseData" + }, + "properties": { "cryptoCode": { "type": "string", "description": "Crypto code of the payment method"