using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Stores; using BTCPayServer.Services.Wallets; using NBitcoin; using Newtonsoft.Json.Linq; using WalletWasabi.WabiSabi.Backend; namespace BTCPayServer.Plugins.Wabisabi.Coordinator; public class WabisabiScriptResolver: WabiSabiConfig.CoordinatorScriptResolver { private readonly IHttpClientFactory _httpClientFactory; private readonly StoreRepository _storeRepository; private readonly PaymentMethodHandlerDictionary _paymentMethodHandlerDictionary; private readonly BTCPayNetworkProvider _networkProvider; private readonly BTCPayWalletProvider _walletProvider; public WabisabiScriptResolver(IHttpClientFactory httpClientFactory, StoreRepository storeRepository, PaymentMethodHandlerDictionary paymentMethodHandlerDictionary, BTCPayNetworkProvider networkProvider, BTCPayWalletProvider walletProvider) { _httpClientFactory = httpClientFactory; _storeRepository = storeRepository; _paymentMethodHandlerDictionary = paymentMethodHandlerDictionary; _networkProvider = networkProvider; _walletProvider = walletProvider; } private static async Task GetRedirectedUrl(HttpClient client, string url, CancellationToken cancellationToken) { var redirectedUrl = url; using var response = await client.PostAsync(url, new FormUrlEncodedContent(Array.Empty>()), cancellationToken).ConfigureAwait(false); using var content = response.Content; // ... Read the response to see if we have the redirected url if (response.StatusCode == System.Net.HttpStatusCode.Found) { var headers = response.Headers; if (headers.Location != null) { redirectedUrl = new Uri(new Uri(url), headers.Location.ToString()).ToString(); } } return redirectedUrl; } public override async Task