mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
fix local coord log issues
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Product>Coinjoin</Product>
|
<Product>Coinjoin</Product>
|
||||||
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
||||||
<Version>1.0.89</Version>
|
<Version>1.0.90</Version>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -133,10 +133,45 @@ public class WabisabiCoordinatorClientInstanceManager:IHostedService
|
|||||||
: url + "/";
|
: url + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var coordinator = url is null ? null : new Uri(url);
|
||||||
|
|
||||||
|
|
||||||
|
IWasabiHttpClientFactory wasabiHttpClientFactory;
|
||||||
|
if (name == "local" || coordinator is null)
|
||||||
|
{
|
||||||
|
var controller = _provider.GetService<WabiSabiController>();
|
||||||
|
if(controller is null)
|
||||||
|
return;
|
||||||
|
wasabiHttpClientFactory = new LocalWabisabiClientFactory( controller);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (coordinator.Scheme == "nostr" &&
|
||||||
|
coordinator.AbsolutePath.TrimEnd('/').FromNIP19Note() is NIP19.NosteProfileNote nostrProfileNote)
|
||||||
|
{
|
||||||
|
var socks5HttpClientHandler = _provider.GetRequiredService<Socks5HttpClientHandler>();
|
||||||
|
|
||||||
|
var factory = new NostrWabisabiClientFactory(socks5HttpClientHandler, nostrProfileNote);
|
||||||
|
wasabiHttpClientFactory = factory;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var config = _provider.GetService<IConfiguration>();
|
||||||
|
var socksEndpoint = config.GetValue<string>("socksendpoint");
|
||||||
|
EndPointParser.TryParse(socksEndpoint, 9050, out var torEndpoint);
|
||||||
|
if (torEndpoint is not null && torEndpoint is DnsEndPoint dnsEndPoint)
|
||||||
|
{
|
||||||
|
torEndpoint = new IPEndPoint(Dns.GetHostAddresses(dnsEndPoint.Host).First(), dnsEndPoint.Port);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wasabiHttpClientFactory = new WasabiHttpClientFactory(torEndpoint, () => coordinator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var instance = new WabisabiCoordinatorClientInstance(
|
var instance = new WabisabiCoordinatorClientInstance(
|
||||||
displayName,
|
displayName,
|
||||||
name, url is null? null: new Uri(url), _provider.GetService<ILoggerFactory>(), _provider, UTXOLocker,
|
name, url is null? null: new Uri(url), wasabiHttpClientFactory,_provider.GetService<ILoggerFactory>(), _provider, UTXOLocker,
|
||||||
_provider.GetService<WalletProvider>(), termsConditions, description,_provider.GetRequiredService<Socks5HttpClientHandler>());
|
_provider.GetService<WalletProvider>(), termsConditions, description);
|
||||||
if (HostedServices.TryAdd(instance.CoordinatorName, instance))
|
if (HostedServices.TryAdd(instance.CoordinatorName, instance))
|
||||||
{
|
{
|
||||||
if(started)
|
if(started)
|
||||||
@@ -254,27 +289,21 @@ public class WabisabiCoordinatorClientInstance:IHostedService
|
|||||||
public WasabiCoordinatorStatusFetcher WasabiCoordinatorStatusFetcher { get; set; }
|
public WasabiCoordinatorStatusFetcher WasabiCoordinatorStatusFetcher { get; set; }
|
||||||
public CoinJoinManager CoinJoinManager { get; set; }
|
public CoinJoinManager CoinJoinManager { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
private readonly WalletWasabi.Services.HostedServices _hostedServices = new();
|
public readonly WalletWasabi.Services.HostedServices _hostedServices = new();
|
||||||
|
|
||||||
public WabisabiCoordinatorClientInstance(string coordinatorDisplayName,
|
public WabisabiCoordinatorClientInstance(
|
||||||
|
string coordinatorDisplayName,
|
||||||
string coordinatorName,
|
string coordinatorName,
|
||||||
Uri coordinator,
|
Uri coordinator,
|
||||||
|
IWasabiHttpClientFactory wasabiHttpClientFactory,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
IUTXOLocker utxoLocker,
|
IUTXOLocker utxoLocker,
|
||||||
WalletProvider walletProvider, string termsConditions, string description,
|
WalletProvider walletProvider, string termsConditions, string description, string coordinatorIdentifier = "CoinJoinCoordinatorIdentifier"
|
||||||
Socks5HttpClientHandler socks5HttpClientHandler, string coordinatorIdentifier = "CoinJoinCoordinatorIdentifier"
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
_utxoLocker = utxoLocker;
|
_utxoLocker = utxoLocker;
|
||||||
var config = serviceProvider.GetService<IConfiguration>();
|
|
||||||
var socksEndpoint = config.GetValue<string>("socksendpoint");
|
|
||||||
EndPointParser.TryParse(socksEndpoint, 9050, out var torEndpoint);
|
|
||||||
if (torEndpoint is not null && torEndpoint is DnsEndPoint dnsEndPoint)
|
|
||||||
{
|
|
||||||
torEndpoint = new IPEndPoint(Dns.GetHostAddresses(dnsEndPoint.Host).First(), dnsEndPoint.Port);
|
|
||||||
}
|
|
||||||
|
|
||||||
CoordinatorDisplayName = coordinatorDisplayName;
|
CoordinatorDisplayName = coordinatorDisplayName;
|
||||||
CoordinatorName = coordinatorName;
|
CoordinatorName = coordinatorName;
|
||||||
@@ -286,25 +315,10 @@ public class WabisabiCoordinatorClientInstance:IHostedService
|
|||||||
IWabiSabiApiRequestHandler sharedWabisabiClient = null;
|
IWabiSabiApiRequestHandler sharedWabisabiClient = null;
|
||||||
|
|
||||||
var roundStateUpdaterCircuit = new PersonCircuit();
|
var roundStateUpdaterCircuit = new PersonCircuit();
|
||||||
|
WasabiHttpClientFactory = wasabiHttpClientFactory;
|
||||||
|
if(wasabiHttpClientFactory is IHostedService hostedService)
|
||||||
|
_hostedServices.Register<IHostedService>(() => hostedService, hostedService.GetType().Name);
|
||||||
|
|
||||||
if (coordinatorName == "local")
|
|
||||||
{
|
|
||||||
WasabiHttpClientFactory = new LocalWabisabiClientFactory( serviceProvider.GetRequiredService<WabiSabiController>());
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (coordinator.Scheme == "nostr" &&
|
|
||||||
coordinator.AbsolutePath.TrimEnd('/').FromNIP19Note() is NIP19.NosteProfileNote nostrProfileNote)
|
|
||||||
{
|
|
||||||
var factory = new NostrWabisabiClientFactory(socks5HttpClientHandler, nostrProfileNote);
|
|
||||||
WasabiHttpClientFactory = factory;
|
|
||||||
_hostedServices.Register<NostrWabisabiClientFactory>(() => factory, "NostrWabisabiClientFactory");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WasabiHttpClientFactory = new WasabiHttpClientFactory(torEndpoint, () => Coordinator);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sharedWabisabiClient =
|
sharedWabisabiClient =
|
||||||
WasabiHttpClientFactory.NewWabiSabiApiRequestHandler(Mode.SingleCircuitPerLifetime,
|
WasabiHttpClientFactory.NewWabiSabiApiRequestHandler(Mode.SingleCircuitPerLifetime,
|
||||||
|
|||||||
Submodule submodules/walletwasabi updated: 8f2cf48984...10b0aab0fe
Reference in New Issue
Block a user