Remove Default from OnChainPayment Method (#2170)

Makes more sense to do it on the Store endpoint after thinking about it.
This commit is contained in:
Andrew Camilleri 2020-12-29 09:38:31 +01:00 committed by GitHub
parent 553b1f139b
commit 5803512820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 21 deletions

View file

@ -10,11 +10,6 @@ namespace BTCPayServer.Client.Models
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// Whether the payment method is the default
/// </summary>
public bool Default { get; set; }
/// <summary>
/// Crypto code of the payment method
/// </summary>
@ -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;
}

View file

@ -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");

View file

@ -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<DerivationSchemeSettings>()
.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()

View file

@ -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"