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>
|
<PropertyGroup>
|
||||||
<Product>Breez / Greenlight</Product>
|
<Product>Breez / Greenlight</Product>
|
||||||
<Description>Lightweight lightning baby!</Description>
|
<Description>Lightweight lightning baby!</Description>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.0.2</Version>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- Plugin development properties -->
|
<!-- Plugin development properties -->
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<ProjectReference Include="..\..\submodules\btcpayserver\BTCPayServer\BTCPayServer.csproj" />
|
<ProjectReference Include="..\..\submodules\btcpayserver\BTCPayServer\BTCPayServer.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Breez.Sdk" Version="0.4.0" />
|
<PackageReference Include="Breez.Sdk" Version="0.4.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
|||||||
@@ -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.84</Version>
|
<Version>1.0.85</Version>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
var affiliateInformation = AffiliationManager.GetAffiliateInformation();
|
var affiliateInformation = AffiliationManager.GetAffiliateInformation();
|
||||||
var ret = new RoundStateResponse(response.RoundStates, medians, affiliateInformation);
|
var ret = new RoundStateResponse(response.RoundStates, medians, affiliateInformation);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("status", duration);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +59,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
var ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.ConfirmConnectionAsync, linkedCts.Token);
|
var ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.ConfirmConnectionAsync, linkedCts.Token);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("connection-confirmation", duration);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,9 +70,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
|
|
||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
InputRegistrationResponse ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, Arena.RegisterInputAsync, linkedCts.Token);
|
InputRegistrationResponse ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, Arena.RegisterInputAsync, linkedCts.Token);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("input-registration", duration);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,8 +82,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.RegisterOutputCoreAsync, linkedCts.Token);
|
await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.RegisterOutputCoreAsync, linkedCts.Token);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("output-registration", duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("credential-issuance")]
|
[HttpPost("credential-issuance")]
|
||||||
@@ -102,8 +93,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
var ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.ReissuanceAsync, linkedCts.Token);
|
var ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.ReissuanceAsync, linkedCts.Token);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("credential-issuance", duration);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +101,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
{
|
{
|
||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
await Arena.RemoveInputAsync(request, cancellableToken);
|
await Arena.RemoveInputAsync(request, cancellableToken);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("input-unregistration", duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("transaction-signature")]
|
[HttpPost("transaction-signature")]
|
||||||
@@ -123,8 +109,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
await Arena.SignTransactionAsync(request, cancellableToken);
|
await Arena.SignTransactionAsync(request, cancellableToken);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("transaction-signature", duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("ready-to-sign")]
|
[HttpPost("ready-to-sign")]
|
||||||
@@ -132,9 +116,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
|
|||||||
{
|
{
|
||||||
var before = DateTimeOffset.UtcNow;
|
var before = DateTimeOffset.UtcNow;
|
||||||
await Arena.ReadyToSignAsync(request, cancellableToken);
|
await Arena.ReadyToSignAsync(request, cancellableToken);
|
||||||
|
|
||||||
var duration = DateTimeOffset.UtcNow - before;
|
|
||||||
RequestTimeStatista.Instance.Add("ready-to-sign", duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ public class NostrWabiSabiApiClient : IWabiSabiApiRequestHandler, IHostedService
|
|||||||
|
|
||||||
public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
|
public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _lastRoundStateTask.Task.WithAwaitCancellationAsync(cancellationToken);
|
await _lastRoundStateTask.Task.WithCancellation(cancellationToken);
|
||||||
return _lastRoundState;
|
return _lastRoundState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,29 +34,6 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin
|
|||||||
public override void Execute(IServiceCollection applicationBuilder)
|
public override void Execute(IServiceCollection applicationBuilder)
|
||||||
{
|
{
|
||||||
var utxoLocker = new LocalisedUTXOLocker();
|
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 =>
|
applicationBuilder.AddHostedService(provider =>
|
||||||
provider.GetRequiredService<WabisabiCoordinatorClientInstanceManager>());
|
provider.GetRequiredService<WabisabiCoordinatorClientInstanceManager>());
|
||||||
applicationBuilder.AddSingleton<WabisabiService>();
|
applicationBuilder.AddSingleton<WabisabiService>();
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ namespace BTCPayServer.Plugins.Wabisabi
|
|||||||
{
|
{
|
||||||
if (spendViewModel.SelectedCoins?.Any() is true)
|
if (spendViewModel.SelectedCoins?.Any() is true)
|
||||||
{
|
{
|
||||||
coins = (CoinsView) coins.FilterBy(coin =>
|
coins = (CoinsView) coins.Where(coin =>
|
||||||
spendViewModel.SelectedCoins.Contains(coin.Outpoint.ToString()));
|
spendViewModel.SelectedCoins.Contains(coin.Outpoint.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -422,11 +422,12 @@ namespace BTCPayServer.Plugins.Wabisabi
|
|||||||
if (labels?.Any() is true)
|
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));
|
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
|
//select enough to be able to spend the amount requested
|
||||||
var result = directLinkCoins.ToShuffled(new InsecureRandom()).Aggregate(
|
var result = directLinkCoins.ToShuffled(new InsecureRandom()).Aggregate(
|
||||||
@@ -451,7 +452,7 @@ namespace BTCPayServer.Plugins.Wabisabi
|
|||||||
coinSelect:
|
coinSelect:
|
||||||
var selectedCoinSum = selectedCoins.Sum(coin => ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC));
|
var selectedCoinSum = selectedCoins.Sum(coin => ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC));
|
||||||
var remaining = amount - selectedCoinSum;
|
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())
|
if (remaining > 0 && remainingCoins.Any())
|
||||||
{
|
{
|
||||||
//try to select the closest coin to the remaining amount while also prioritizing privacy
|
//try to select the closest coin to the remaining amount while also prioritizing privacy
|
||||||
|
|||||||
Submodule submodules/btcpayserver updated: 3fbc717cd4...a026d244fe
Reference in New Issue
Block a user