Make tx label endpoint not error

This commit is contained in:
Kukks 2022-07-28 15:33:28 +02:00
parent 5ef31a96ea
commit 4be5eb39ff
No known key found for this signature in database
GPG Key ID: 8E5530D9D1C93097
4 changed files with 19 additions and 6 deletions

View File

@ -85,11 +85,14 @@ namespace BTCPayServer.Client
public virtual async Task<OnChainWalletTransactionData> PatchOnChainWalletTransaction(
string storeId, string cryptoCode, string transactionId,
PatchOnChainTransactionRequest request,
CancellationToken token = default)
bool force = false, CancellationToken token = default)
{
var response =
await _httpClient.SendAsync(
CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/transactions/{transactionId}", queryPayload: null, bodyPayload: request, HttpMethod.Patch), token);
CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/transactions/{transactionId}", queryPayload: new Dictionary<string, object>()
{
{"force", force}
}, bodyPayload: request, HttpMethod.Patch), token);
return await HandleResponse<OnChainWalletTransactionData>(response);
}

View File

@ -254,7 +254,8 @@ namespace BTCPayServer.Controllers.Greenfield
string storeId,
string cryptoCode,
string transactionId,
[FromBody] PatchOnChainTransactionRequest request
[FromBody] PatchOnChainTransactionRequest request,
bool force = false
)
{
if (IsInvalidWalletRequest(cryptoCode, out var network,
@ -263,7 +264,7 @@ namespace BTCPayServer.Controllers.Greenfield
var wallet = _btcPayWalletProvider.GetWallet(network);
var tx = await wallet.FetchTransaction(derivationScheme.AccountDerivation, uint256.Parse(transactionId));
if (tx is null)
if (!force && tx is null)
{
return this.CreateAPIError(404, "transaction-not-found", "The transaction was not found.");
}

View File

@ -990,11 +990,11 @@ namespace BTCPayServer.Controllers.Greenfield
public override async Task<OnChainWalletTransactionData> PatchOnChainWalletTransaction(string storeId,
string cryptoCode, string transactionId,
PatchOnChainTransactionRequest request, CancellationToken token = default)
PatchOnChainTransactionRequest request, bool force = false,CancellationToken token = default)
{
return GetFromActionResult<OnChainWalletTransactionData>(
await GetController<GreenfieldStoreOnChainWalletsController>().PatchOnChainWalletTransaction(storeId, cryptoCode, transactionId,
request));
request, force));
}
public override async Task<LightningPaymentData> GetLightningPayment(string cryptoCode, string paymentHash,

View File

@ -513,6 +513,15 @@
"schema": {
"type": "string"
}
},
{
"name": "force",
"in": "query",
"required": false,
"description": "Whether to update the label/comments even if the transaction does not yet exist",
"schema": {
"type": "string"
}
}
],
"requestBody": {