From 5803512820b625a4a2d8c90b8ca5ddbb3ec97162 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 29 Dec 2020 09:38:31 +0100 Subject: [PATCH] Remove Default from OnChainPayment Method (#2170) Makes more sense to do it on the Store endpoint after thinking about it. --- BTCPayServer.Client/Models/OnChainPaymentMethodData.cs | 9 +-------- BTCPayServer.Tests/GreenfieldAPITests.cs | 6 +++--- .../GreenField/StoreOnChainPaymentMethodsController.cs | 8 ++------ ...swagger.template.stores-payment-methods.on-chain.json | 4 ---- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs b/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs index b7f2d9ae8..bbfe20922 100644 --- a/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs +++ b/BTCPayServer.Client/Models/OnChainPaymentMethodData.cs @@ -10,11 +10,6 @@ namespace BTCPayServer.Client.Models /// public bool Enabled { get; set; } - /// - /// Whether the payment method is the default - /// - public bool Default { get; set; } - /// /// Crypto code of the payment method /// @@ -34,11 +29,9 @@ namespace BTCPayServer.Client.Models { } - public OnChainPaymentMethodData(string cryptoCode, string derivationScheme, bool enabled, - bool defaultMethod) + public OnChainPaymentMethodData(string cryptoCode, string derivationScheme, bool enabled) { Enabled = enabled; - Default = defaultMethod; CryptoCode = cryptoCode; DerivationScheme = derivationScheme; } diff --git a/BTCPayServer.Tests/GreenfieldAPITests.cs b/BTCPayServer.Tests/GreenfieldAPITests.cs index 2a26997a4..dbd135baf 100644 --- a/BTCPayServer.Tests/GreenfieldAPITests.cs +++ b/BTCPayServer.Tests/GreenfieldAPITests.cs @@ -1238,15 +1238,15 @@ namespace BTCPayServer.Tests }); Assert.Equal(firstAddress, (await viewOnlyClient.PreviewProposedStoreOnChainPaymentMethodAddresses(store.Id, "BTC", - new OnChainPaymentMethodData() {Default = true, Enabled = true, DerivationScheme = xpub})).Addresses.First().Address); + new OnChainPaymentMethodData() {Enabled = true, DerivationScheme = xpub})).Addresses.First().Address); var method = await client.UpdateStoreOnChainPaymentMethod(store.Id, "BTC", - new OnChainPaymentMethodData() {Default = true, Enabled = true, DerivationScheme = xpub}); + new OnChainPaymentMethodData() { Enabled = true, DerivationScheme = xpub}); Assert.Equal(xpub,method.DerivationScheme); method = await client.UpdateStoreOnChainPaymentMethod(store.Id, "BTC", - new OnChainPaymentMethodData() { Default = true, Enabled = true, DerivationScheme = xpub, Label = "lol", AccountKeyPath = RootedKeyPath.Parse("01020304/1/2/3") }); + new OnChainPaymentMethodData() { Enabled = true, DerivationScheme = xpub, Label = "lol", AccountKeyPath = RootedKeyPath.Parse("01020304/1/2/3") }); method = await client.GetStoreOnChainPaymentMethod(store.Id, "BTC"); diff --git a/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs b/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs index 3d3d5b7f6..99a5c9c41 100644 --- a/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs +++ b/BTCPayServer/Controllers/GreenField/StoreOnChainPaymentMethodsController.cs @@ -42,14 +42,12 @@ namespace BTCPayServer.Controllers.GreenField { var blob = Store.GetStoreBlob(); var excludedPaymentMethods = blob.GetExcludedPaymentMethods(); - var defaultPaymentId = Store.GetDefaultPaymentId(_btcPayNetworkProvider); return Ok(Store.GetSupportedPaymentMethods(_btcPayNetworkProvider) .Where((method) => method.PaymentId.PaymentType == PaymentTypes.BTCLike) .OfType() .Select(strategy => new OnChainPaymentMethodData(strategy.PaymentId.CryptoCode, - strategy.AccountDerivation.ToString(), !excludedPaymentMethods.Match(strategy.PaymentId), - defaultPaymentId == strategy.PaymentId)) + strategy.AccountDerivation.ToString(), !excludedPaymentMethods.Match(strategy.PaymentId))) .Where((result) => !enabledOnly || result.Enabled) .ToList() ); @@ -241,7 +239,6 @@ namespace BTCPayServer.Controllers.GreenField { store ??= Store; var storeBlob = store.GetStoreBlob(); - var defaultPaymentMethod = store.GetDefaultPaymentId(_btcPayNetworkProvider); var id = new PaymentMethodId(cryptoCode, PaymentTypes.BTCLike); var paymentMethod = store .GetSupportedPaymentMethods(_btcPayNetworkProvider) @@ -252,8 +249,7 @@ namespace BTCPayServer.Controllers.GreenField return paymentMethod == null ? null : new OnChainPaymentMethodData(paymentMethod.PaymentId.CryptoCode, - paymentMethod.AccountDerivation.ToString(), !excluded, - defaultPaymentMethod == paymentMethod.PaymentId) + paymentMethod.AccountDerivation.ToString(), !excluded) { Label = paymentMethod.Label, AccountKeyPath = paymentMethod.GetSigningAccountKeySettings().GetRootedKeyPath() 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 da4c3a5b7..997278c1c 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 @@ -393,10 +393,6 @@ "type": "boolean", "description": "Whether the payment method is enabled" }, - "default": { - "type": "boolean", - "description": "Whether the payment method is the default" - }, "cryptoCode": { "type": "string", "description": "Crypto code of the payment method"