diff --git a/BTCPayServer.Client/BTCPayServerClient.OnChainWallet.cs b/BTCPayServer.Client/BTCPayServerClient.OnChainWallet.cs index e58371464..c93753da4 100644 --- a/BTCPayServer.Client/BTCPayServerClient.OnChainWallet.cs +++ b/BTCPayServer.Client/BTCPayServerClient.OnChainWallet.cs @@ -85,11 +85,14 @@ namespace BTCPayServer.Client public virtual async Task 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() + { + {"force", force} + }, bodyPayload: request, HttpMethod.Patch), token); return await HandleResponse(response); } diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs index 087c4cfb3..e769134a4 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs @@ -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."); } diff --git a/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs b/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs index 84f51a657..5648e3277 100644 --- a/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs +++ b/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs @@ -990,11 +990,11 @@ namespace BTCPayServer.Controllers.Greenfield public override async Task PatchOnChainWalletTransaction(string storeId, string cryptoCode, string transactionId, - PatchOnChainTransactionRequest request, CancellationToken token = default) + PatchOnChainTransactionRequest request, bool force = false,CancellationToken token = default) { return GetFromActionResult( await GetController().PatchOnChainWalletTransaction(storeId, cryptoCode, transactionId, - request)); + request, force)); } public override async Task GetLightningPayment(string cryptoCode, string paymentHash, diff --git a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-wallet.on-chain.json b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-wallet.on-chain.json index 0c44beed3..efceb506f 100644 --- a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-wallet.on-chain.json +++ b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-wallet.on-chain.json @@ -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": {