mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
upd breez and wabi
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<PropertyGroup>
|
||||
<Product>Breez / Greenlight</Product>
|
||||
<Description>Lightweight lightning baby!</Description>
|
||||
<Version>1.0.1</Version>
|
||||
<Version>1.0.2</Version>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
<!-- Plugin development properties -->
|
||||
@@ -34,7 +34,7 @@
|
||||
<ProjectReference Include="..\..\submodules\btcpayserver\BTCPayServer\BTCPayServer.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Breez.Sdk" Version="0.4.0" />
|
||||
<PackageReference Include="Breez.Sdk" Version="0.4.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<PropertyGroup>
|
||||
<Product>Coinjoin</Product>
|
||||
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
||||
<Version>1.0.84</Version>
|
||||
<Version>1.0.85</Version>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -46,9 +46,7 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
var medians = CoinJoinFeeRateStatStore.GetDefaultMedians();
|
||||
var affiliateInformation = AffiliationManager.GetAffiliateInformation();
|
||||
var ret = new RoundStateResponse(response.RoundStates, medians, affiliateInformation);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("status", duration);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -61,8 +59,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
var ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.ConfirmConnectionAsync, linkedCts.Token);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("connection-confirmation", duration);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -74,9 +70,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
InputRegistrationResponse ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, Arena.RegisterInputAsync, linkedCts.Token);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("input-registration", duration);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -89,8 +82,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.RegisterOutputCoreAsync, linkedCts.Token);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("output-registration", duration);
|
||||
}
|
||||
|
||||
[HttpPost("credential-issuance")]
|
||||
@@ -102,8 +93,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
var ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.ReissuanceAsync, linkedCts.Token);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("credential-issuance", duration);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -112,9 +101,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
{
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
await Arena.RemoveInputAsync(request, cancellableToken);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("input-unregistration", duration);
|
||||
}
|
||||
|
||||
[HttpPost("transaction-signature")]
|
||||
@@ -123,8 +109,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
await Arena.SignTransactionAsync(request, cancellableToken);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("transaction-signature", duration);
|
||||
}
|
||||
|
||||
[HttpPost("ready-to-sign")]
|
||||
@@ -132,9 +116,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
||||
{
|
||||
var before = DateTimeOffset.UtcNow;
|
||||
await Arena.ReadyToSignAsync(request, cancellableToken);
|
||||
|
||||
var duration = DateTimeOffset.UtcNow - before;
|
||||
RequestTimeStatista.Instance.Add("ready-to-sign", duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -222,7 +222,7 @@ public class NostrWabiSabiApiClient : IWabiSabiApiRequestHandler, IHostedService
|
||||
|
||||
public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _lastRoundStateTask.Task.WithAwaitCancellationAsync(cancellationToken);
|
||||
await _lastRoundStateTask.Task.WithCancellation(cancellationToken);
|
||||
return _lastRoundState;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,29 +34,6 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin
|
||||
public override void Execute(IServiceCollection applicationBuilder)
|
||||
{
|
||||
var utxoLocker = new LocalisedUTXOLocker();
|
||||
applicationBuilder.AddSingleton(
|
||||
provider =>
|
||||
{
|
||||
var res = ActivatorUtilities.CreateInstance<WabisabiCoordinatorClientInstanceManager>(provider);
|
||||
res.UTXOLocker = utxoLocker;
|
||||
res.AddCoordinator("zkSNACKS Coordinator", "zksnacks", provider =>
|
||||
{
|
||||
var chain = provider.GetService<IExplorerClientProvider>().GetExplorerClient("BTC").Network
|
||||
.NBitcoinNetwork.ChainName;
|
||||
if (chain == ChainName.Mainnet)
|
||||
{
|
||||
return new Uri("https://wasabiwallet.io/");
|
||||
}
|
||||
|
||||
if (chain == ChainName.Testnet)
|
||||
{
|
||||
return new Uri("https://wasabiwallet.co/");
|
||||
}
|
||||
|
||||
return new Uri("http://localhost:37127");
|
||||
});
|
||||
return res;
|
||||
});
|
||||
applicationBuilder.AddHostedService(provider =>
|
||||
provider.GetRequiredService<WabisabiCoordinatorClientInstanceManager>());
|
||||
applicationBuilder.AddSingleton<WabisabiService>();
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace BTCPayServer.Plugins.Wabisabi
|
||||
{
|
||||
if (spendViewModel.SelectedCoins?.Any() is true)
|
||||
{
|
||||
coins = (CoinsView) coins.FilterBy(coin =>
|
||||
coins = (CoinsView) coins.Where(coin =>
|
||||
spendViewModel.SelectedCoins.Contains(coin.Outpoint.ToString()));
|
||||
}
|
||||
}
|
||||
@@ -422,11 +422,12 @@ namespace BTCPayServer.Plugins.Wabisabi
|
||||
if (labels?.Any() is true)
|
||||
{
|
||||
|
||||
var directLinkCoins = coins.FilterBy(coin => coin.HdPubKey.Labels.Any(labels.Contains)).Available();
|
||||
var directLinkCoins =
|
||||
coins.Where(coin => coin.HdPubKey.Labels.Any(labels.Contains) && coin.IsAvailable());
|
||||
|
||||
selectedCoins.AddRange(directLinkCoins.Select(coin => coin.Coin));
|
||||
|
||||
if (directLinkCoins.TotalAmount().ToDecimal(MoneyUnit.BTC) > amount)
|
||||
if (directLinkCoins.Sum(coin => coin.Amount.ToDecimal(MoneyUnit.BTC)) > amount)
|
||||
{
|
||||
//select enough to be able to spend the amount requested
|
||||
var result = directLinkCoins.ToShuffled(new InsecureRandom()).Aggregate(
|
||||
@@ -451,7 +452,7 @@ namespace BTCPayServer.Plugins.Wabisabi
|
||||
coinSelect:
|
||||
var selectedCoinSum = selectedCoins.Sum(coin => ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC));
|
||||
var remaining = amount - selectedCoinSum;
|
||||
var remainingCoins = coins.FilterBy(coin => !selectedCoins.Contains(coin.Coin)).Available().ToList();
|
||||
var remainingCoins = coins.Where(coin => !selectedCoins.Contains(coin.Coin) && coin.IsAvailable()).ToList();
|
||||
if (remaining > 0 && remainingCoins.Any())
|
||||
{
|
||||
//try to select the closest coin to the remaining amount while also prioritizing privacy
|
||||
|
||||
Reference in New Issue
Block a user