mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-31 20:04:31 +01:00
Add UpdateOnChainPaymentMethodRequest
This commit is contained in:
committed by
Andrew Camilleri
parent
2f4e610900
commit
748423dfe8
@@ -0,0 +1,25 @@
|
||||
using NBitcoin;
|
||||
|
||||
namespace BTCPayServer.Client.Models
|
||||
{
|
||||
public class UpdateOnChainPaymentMethodRequest : OnChainPaymentMethodBaseData
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the payment method is enabled
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public UpdateOnChainPaymentMethodRequest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UpdateOnChainPaymentMethodRequest(bool enabled, string derivationScheme, string label, RootedKeyPath accountKeyPath)
|
||||
{
|
||||
Enabled = enabled;
|
||||
Label = label;
|
||||
AccountKeyPath = accountKeyPath;
|
||||
DerivationScheme = derivationScheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,12 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
CancellationToken token = default)
|
||||
{
|
||||
return GetFromActionResult<OnChainPaymentMethodData>(
|
||||
await _chainPaymentMethodsController.UpdateOnChainPaymentMethod(storeId, cryptoCode, paymentMethod));
|
||||
await _chainPaymentMethodsController.UpdateOnChainPaymentMethod(storeId, cryptoCode, new UpdateOnChainPaymentMethodRequest(
|
||||
enabled: paymentMethod.Enabled,
|
||||
label: paymentMethod.Label,
|
||||
accountKeyPath: paymentMethod.AccountKeyPath,
|
||||
derivationScheme: paymentMethod.DerivationScheme
|
||||
)));
|
||||
}
|
||||
|
||||
public override Task<OnChainPaymentMethodPreviewResultData> PreviewProposedStoreOnChainPaymentMethodAddresses(
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
public async Task<IActionResult> UpdateOnChainPaymentMethod(
|
||||
string storeId,
|
||||
string cryptoCode,
|
||||
[FromBody] OnChainPaymentMethodData paymentMethodData)
|
||||
[FromBody] UpdateOnChainPaymentMethodRequest request)
|
||||
{
|
||||
var id = new PaymentMethodId(cryptoCode, PaymentTypes.BTCLike);
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(paymentMethodData?.DerivationScheme))
|
||||
if (string.IsNullOrEmpty(request?.DerivationScheme))
|
||||
{
|
||||
ModelState.AddModelError(nameof(OnChainPaymentMethodData.DerivationScheme),
|
||||
"Missing derivationScheme");
|
||||
@@ -239,12 +239,12 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
{
|
||||
var store = Store;
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
var strategy = DerivationSchemeSettings.Parse(paymentMethodData.DerivationScheme, network);
|
||||
var strategy = DerivationSchemeSettings.Parse(request.DerivationScheme, network);
|
||||
if (strategy != null)
|
||||
await wallet.TrackAsync(strategy.AccountDerivation);
|
||||
strategy.Label = paymentMethodData.Label;
|
||||
strategy.Label = request.Label;
|
||||
var signing = strategy.GetSigningAccountKeySettings();
|
||||
if (paymentMethodData.AccountKeyPath is RootedKeyPath r)
|
||||
if (request.AccountKeyPath is RootedKeyPath r)
|
||||
{
|
||||
signing.AccountKeyPath = r.KeyPath;
|
||||
signing.RootFingerprint = r.MasterFingerprint;
|
||||
@@ -256,7 +256,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
}
|
||||
|
||||
store.SetSupportedPaymentMethod(id, strategy);
|
||||
storeBlob.SetExcluded(id, !paymentMethodData.Enabled);
|
||||
storeBlob.SetExcluded(id, !request.Enabled);
|
||||
store.SetStoreBlob(storeBlob);
|
||||
await _storeRepository.UpdateStore(store);
|
||||
return Ok(GetExistingBtcLikePaymentMethod(cryptoCode, store));
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/stores/{storeId}/payment-methods/OnChain/{cryptoCode}": {
|
||||
"/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Store Payment Methods (On Chain)"
|
||||
@@ -136,7 +136,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OnChainPaymentMethodData"
|
||||
"$ref": "#/components/schemas/UpdateOnChainPaymentMethodRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -442,6 +442,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"UpdateOnChainPaymentMethodRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/OnChainPaymentMethodBaseData"
|
||||
},
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the payment method is enabled"
|
||||
}
|
||||
}
|
||||
},
|
||||
"OnChainPaymentMethodData": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
|
||||
Reference in New Issue
Block a user