public virtual async Task<OnChainWalletTransactionData> PatchOnChainWalletTransaction( string storeId, string cryptoCode, string transactionId, PatchOnChainTransactionRequest request, 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); return await HandleResponse<OnChainWalletTransactionData>(response); }
public async Task <IActionResult> PatchOnChainWalletTransaction( string storeId, string cryptoCode, string transactionId, [FromBody] PatchOnChainTransactionRequest request ) { if (IsInvalidWalletRequest(cryptoCode, out var network, out var derivationScheme, out var actionResult)) { return(actionResult); } var wallet = _btcPayWalletProvider.GetWallet(network); var tx = await wallet.FetchTransaction(derivationScheme.AccountDerivation, uint256.Parse(transactionId)); if (tx is null) { return(this.CreateAPIError(404, "transaction-not-found", "The transaction was not found.")); } var walletId = new WalletId(storeId, cryptoCode); var walletTransactionsInfoAsync = _walletRepository.GetWalletTransactionsInfo(walletId); if (!(await walletTransactionsInfoAsync).TryGetValue(transactionId, out var walletTransactionInfo)) { walletTransactionInfo = new WalletTransactionInfo(); } if (request.Comment != null) { walletTransactionInfo.Comment = request.Comment.Trim().Truncate(WalletTransactionDataExtensions.MaxCommentSize); } if (request.Labels != null) { var walletBlobInfo = await _walletRepository.GetWalletInfo(walletId); foreach (string label in request.Labels) { var rawLabel = await _labelFactory.BuildLabel( walletBlobInfo, Request, walletTransactionInfo, walletId, transactionId, label ); walletTransactionInfo.Labels.TryAdd(rawLabel.Text, rawLabel); } } await _walletRepository.SetWalletTransactionInfo(walletId, transactionId, walletTransactionInfo); var walletTransactionsInfo = (await _walletRepository.GetWalletTransactionsInfo(walletId, new[] { transactionId })) .Values .FirstOrDefault(); return(Ok(ToModel(walletTransactionsInfo, tx, wallet))); }