update breez

This commit is contained in:
Kukks
2024-06-13 09:43:10 +02:00
parent 1d5dc4d2b5
commit b570fe0555
9 changed files with 64 additions and 68 deletions

View File

@@ -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.4</Version> <Version>1.0.5</Version>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup> </PropertyGroup>
<!-- Plugin development properties --> <!-- Plugin development properties -->

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Models.StoreViewModels @using BTCPayServer.Lightning
@using BTCPayServer.Models.StoreViewModels
@using BTCPayServer.Plugins.Breez @using BTCPayServer.Plugins.Breez
@using BTCPayServer.Security @using BTCPayServer.Security
@inject BreezService BreezService @inject BreezService BreezService
@@ -16,7 +17,7 @@
return; return;
var nodeState = sdk.NodeInfo(); var nodeState = sdk.NodeInfo();
var max = nodeState.maxReceivableMsat / 1000; var max = LightMoney.MilliSatoshis(nodeState.maxReceivableMsat);
} }
@@ -36,7 +37,7 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
<label for="amount" class="form-label">Amount (sats)</label> <label for="amount" class="form-label">Amount (sats)</label>
<input type="number"id="amount" min="0" max="@max" name="amount" class="form-control"/> <input type="number"id="amount" min="0" max="@max.ToUnit(LightMoneyUnit.Satoshi)" name="amount" class="form-control"/>
</div> </div>
</div> </div>

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Models.StoreViewModels @using BTCPayServer.Lightning
@using BTCPayServer.Models.StoreViewModels
@using BTCPayServer.Plugins.Breez @using BTCPayServer.Plugins.Breez
@using BTCPayServer.Security @using BTCPayServer.Security
@inject BreezService BreezService @inject BreezService BreezService
@@ -16,7 +17,7 @@
return; return;
var nodeState = sdk.NodeInfo(); var nodeState = sdk.NodeInfo();
var max = nodeState.maxPayableMsat / 1000; var max = LightMoney.MilliSatoshis(nodeState.maxPayableMsat).ToUnit(LightMoneyUnit.Satoshi);
} }

View File

@@ -45,20 +45,15 @@
} }
<datalist id="fees"> <datalist id="fees">
<option value="@f.fastestFee">Fastest fee</option> <option value="@f.fastestFee">Fastest fee (@f.fastestFee sat/vB)</option>
<option value="@f.halfHourFee">Half hour fee</option> <option value="@f.halfHourFee">Half hour fee (@f.halfHourFee sat/vB)</option>
<option value="@f.hourFee">Hour fee</option> <option value="@f.hourFee">Hour fee (@f.hourFee sat/vB)</option>
<option value="@f.economyFee">Economic fee</option> <option value="@f.economyFee">Economic fee (@f.economyFee sat/vB)</option>
<option value="@f.minimumFee">Minimum fee</option> <option value="@f.minimumFee">Minimum fee (@f.minimumFee sat/vB)</option>
</datalist> </datalist>
<div class="row mb-4"> <div class="row mb-4 mt-4">
<div class="col-12"> <div class="col-12">
<div class="d-flex align-items-center justify-content-between mb-3">
<h3 class="mb-0">
<span>@ViewData["Title"]</span>
</h3>
</div>
@if (inProgressSwap is not null) @if (inProgressSwap is not null)
{ {
@@ -71,7 +66,7 @@
<vc:truncate-center text="@inProgressSwap.bitcoinAddress" padding="15" elastic="true" classes="form-control-plaintext" id="Address"/> <vc:truncate-center text="@inProgressSwap.bitcoinAddress" padding="15" elastic="true" classes="form-control-plaintext" id="Address"/>
<label for="Address">Address</label> <label for="Address">Address</label>
</div> </div>
<div> <div class="w-100">
<span class="text-muted">Please send an amount between <br/> @Money.Satoshis(inProgressSwap.minAllowedDeposit).ToDecimal(MoneyUnit.BTC) and @Money.Satoshis(inProgressSwap.maxAllowedDeposit).ToDecimal(MoneyUnit.BTC)BTC </span> <span class="text-muted">Please send an amount between <br/> @Money.Satoshis(inProgressSwap.minAllowedDeposit).ToDecimal(MoneyUnit.BTC) and @Money.Satoshis(inProgressSwap.maxAllowedDeposit).ToDecimal(MoneyUnit.BTC)BTC </span>
@if (deriv is not null) @if (deriv is not null)
{ {

View File

@@ -14,11 +14,11 @@
} }
<datalist id="fees"> <datalist id="fees">
<option value="@f.fastestFee">Fastest fee</option> <option value="@f.fastestFee">Fastest fee (@f.fastestFee sat/vB)</option>
<option value="@f.halfHourFee">Half hour fee</option> <option value="@f.halfHourFee">Half hour fee (@f.halfHourFee sat/vB)</option>
<option value="@f.hourFee">Hour fee</option> <option value="@f.hourFee">Hour fee (@f.hourFee sat/vB)</option>
<option value="@f.economyFee">Economic fee</option> <option value="@f.economyFee">Economic fee (@f.economyFee sat/vB)</option>
<option value="@f.minimumFee">Minimum fee</option> <option value="@f.minimumFee">Minimum fee (@f.minimumFee sat/vB)</option>
</datalist> </datalist>

View File

@@ -24,6 +24,7 @@
{ {
storeId = Context.GetImplicitStoreId(); storeId = Context.GetImplicitStoreId();
} }
var sdk = BreezService.GetClient(storeId)?.Sdk; var sdk = BreezService.GetClient(storeId)?.Sdk;
if (sdk is null) if (sdk is null)
return; return;
@@ -34,11 +35,11 @@
} }
<datalist id="fees"> <datalist id="fees">
<option value="@f.fastestFee">Fastest fee</option> <option value="@f.fastestFee">Fastest fee (@f.fastestFee sat/vB)</option>
<option value="@f.halfHourFee">Half hour fee</option> <option value="@f.halfHourFee">Half hour fee (@f.halfHourFee sat/vB)</option>
<option value="@f.hourFee">Hour fee</option> <option value="@f.hourFee">Hour fee (@f.hourFee sat/vB)</option>
<option value="@f.economyFee">Economic fee</option> <option value="@f.economyFee">Economic fee (@f.economyFee sat/vB)</option>
<option value="@f.minimumFee">Minimum fee</option> <option value="@f.minimumFee">Minimum fee (@f.minimumFee sat/vB)</option>
</datalist> </datalist>
<datalist list="addresses"> <datalist list="addresses">
@if (deriv is not null) @if (deriv is not null)
@@ -56,7 +57,6 @@
</h3> </h3>
<div class="d-flex gap-3 mt-3 mt-sm-0"> <div class="d-flex gap-3 mt-3 mt-sm-0">
<button type="submit" class="btn btn-primary">Create</button>
</div> </div>
</div> </div>
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
@@ -71,10 +71,12 @@
<div class="form-group"> <div class="form-group">
<label for="amount" class="form-label" data-required>Amount (sats)</label> <label for="amount" class="form-label" data-required>Amount (sats)</label>
<input type="number" min="@swapOutRec.min" max="@swapOutRec.max" id="amount" name="amount" class="form-control" required/> <input type="number" min="@swapOutRec.min" max="@swapOutRec.max" id="amount" name="amount" class="form-control" required/>
<p class="text-muted">Minimum: @swapOutRec.min, Maximum: @swapOutRec.max</p>
</div> </div>
<input type="hidden" name="feesHash" value="@swapOutRec.feesHash"/> <input type="hidden" name="feesHash" value="@swapOutRec.feesHash"/>
<button type="submit" class="btn btn-primary d-none">Create</button>
@if (inProgressSwaps?.Any() is true) @if (inProgressSwaps?.Any() is true)
{ {
<table class="table"> <table class="table">

View File

@@ -1,39 +1,46 @@
@using BTCPayServer @using BTCPayServer
@using BTCPayServer.Abstractions.Extensions @using BTCPayServer.Models.StoreViewModels
@using BTCPayServer.Plugins.Breez @using BTCPayServer.Plugins.Breez
@using BTCPayServer.Security @using BTCPayServer.Security
@model string @using Microsoft.AspNetCore.Mvc.TagHelpers
@inject BreezService BreezService @inject BreezService BreezService
@inject BTCPayNetworkProvider BtcPayNetworkProvider @inject BTCPayNetworkProvider BtcPayNetworkProvider
@{ @{
var storeId = Context.GetImplicitStoreId();
Layout = "_Layout"; Layout = "_Layout";
ViewData.SetActivePage("Breez", "Sweep", "Sweep"); ViewData.SetActivePage("Breez", "Sweep", "Sweep");
string storeId = null;
if (Model is string s)
{
storeId = s;
}
else if (Model is StoreDashboardViewModel dashboardModel)
{
storeId = dashboardModel.StoreId;
}
else
{
storeId = Context.GetImplicitStoreId();
}
var sdk = BreezService.GetClient(storeId)?.Sdk; var sdk = BreezService.GetClient(storeId)?.Sdk;
var f = sdk.RecommendedFees(); if (sdk is null)
var info = sdk.NodeInfo(); return;
var deriv = Context.GetStoreData().GetDerivationSchemeSettings(BtcPayNetworkProvider, "BTC"); var deriv = Context.GetStoreData().GetDerivationSchemeSettings(BtcPayNetworkProvider, "BTC");
var f = sdk.RecommendedFees();
} }
<datalist id="fees">
<option value="@f.fastestFee">Fastest fee (@f.fastestFee sat/vB)</option>
<option value="@f.halfHourFee">Half hour fee (@f.halfHourFee sat/vB)</option>
<option value="@f.hourFee">Hour fee (@f.hourFee sat/vB)</option>
<option value="@f.economyFee">Economic fee (@f.economyFee sat/vB)</option>
<option value="@f.minimumFee">Minimum fee (@f.minimumFee sat/vB)</option>
</datalist>
<datalist list="addresses"> <datalist list="addresses">
@if (deriv is not null) @if (deriv is not null)
{ {
<option value="store"> Store wallet</option> <option value="store"> Store wallet</option>
} }
</datalist> </datalist>
<datalist id="fees">
<option value="@f.fastestFee">Fastest fee</option>
<option value="@f.halfHourFee">Half hour fee</option>
<option value="@f.hourFee">Hour fee</option>
<option value="@f.economyFee">Economic fee</option>
<option value="@f.minimumFee">Minimum fee</option>
</datalist>
<form method="post" asp-action="Sweep" asp-route-storeId="@storeId"> <form method="post" asp-action="Sweep" asp-route-storeId="@storeId">
<div class="row mb-4"> <div class="row mb-4">
<div class="col-12"> <div class="col-12">
<div class="d-flex align-items-center justify-content-between mb-3"> <div class="d-flex align-items-center justify-content-between mb-3">
@@ -48,20 +55,14 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
<label for="address" class="form-label" data-required>address</label> <label for="address" class="form-label" data-required>Address</label>
<input type="text" list="addresses" id="address" name="address" class="form-control" required/> <input type="text" id="address" list="addresses" name="address" class="form-control" required/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="satPerByte" class="form-label" data-required>Fees</label> <label for="satPerByte" class="form-label" data-required>Feerate</label>
<input type="number" min="@f.minimumFee" list="satPerByte" id="satPerByte" name="satPerByte" class="form-control" required/> <input type="number" min="@f.minimumFee" list="fees" id="satPerByte" name="satPerByte" class="form-control" required/>
</div> </div>
<button type="submit" class="btn btn-primary">Create</button>
</div> </div>
</div> </div>
</form> </form>
@section PageFootContent {
<partial name="_ValidationScriptsPartial"/>
}

View File

@@ -2,4 +2,9 @@
Layout = "../Shared/_NavLayout.cshtml"; Layout = "../Shared/_NavLayout.cshtml";
ViewData["NavPartialName"] = "_Nav"; ViewData["NavPartialName"] = "_Nav";
} }
<style>
#mainContent > section {
padding: 3rem !important;
}
</style>
@RenderBody() @RenderBody()

View File

@@ -41,7 +41,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
[HttpPost("status")] [HttpPost("status")]
public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken) public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
{ {
var before = DateTimeOffset.UtcNow;
var response = await Arena.GetStatusAsync(request, cancellationToken); var response = await Arena.GetStatusAsync(request, cancellationToken);
var medians = CoinJoinFeeRateStatStore.GetDefaultMedians(); var medians = CoinJoinFeeRateStatStore.GetDefaultMedians();
var affiliateInformation = AffiliationManager.GetAffiliateInformation(); var affiliateInformation = AffiliationManager.GetAffiliateInformation();
@@ -55,8 +54,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
{ {
using CancellationTokenSource timeoutCts = new(RequestTimeout); using CancellationTokenSource timeoutCts = new(RequestTimeout);
using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken); using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken);
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);
return ret; return ret;
@@ -68,7 +65,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
using CancellationTokenSource timeoutCts = new(RequestTimeout); using CancellationTokenSource timeoutCts = new(RequestTimeout);
using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken); using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken);
var before = DateTimeOffset.UtcNow;
InputRegistrationResponse ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, Arena.RegisterInputAsync, linkedCts.Token); InputRegistrationResponse ret = await IdempotencyRequestCache.GetCachedResponseAsync(request, Arena.RegisterInputAsync, linkedCts.Token);
return ret; return ret;
} }
@@ -79,7 +75,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
using CancellationTokenSource timeoutCts = new(RequestTimeout); using CancellationTokenSource timeoutCts = new(RequestTimeout);
using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken); using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken);
var before = DateTimeOffset.UtcNow;
await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.RegisterOutputCoreAsync, linkedCts.Token); await IdempotencyRequestCache.GetCachedResponseAsync(request, action: Arena.RegisterOutputCoreAsync, linkedCts.Token);
} }
@@ -90,7 +85,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
using CancellationTokenSource timeoutCts = new(RequestTimeout); using CancellationTokenSource timeoutCts = new(RequestTimeout);
using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken); using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken);
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);
return ret; return ret;
@@ -99,14 +93,12 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
[HttpPost("input-unregistration")] [HttpPost("input-unregistration")]
public async Task RemoveInputAsync(InputsRemovalRequest request, CancellationToken cancellableToken) public async Task RemoveInputAsync(InputsRemovalRequest request, CancellationToken cancellableToken)
{ {
var before = DateTimeOffset.UtcNow;
await Arena.RemoveInputAsync(request, cancellableToken); await Arena.RemoveInputAsync(request, cancellableToken);
} }
[HttpPost("transaction-signature")] [HttpPost("transaction-signature")]
public async Task SignTransactionAsync(TransactionSignaturesRequest request, CancellationToken cancellableToken) public async Task SignTransactionAsync(TransactionSignaturesRequest request, CancellationToken cancellableToken)
{ {
var before = DateTimeOffset.UtcNow;
await Arena.SignTransactionAsync(request, cancellableToken); await Arena.SignTransactionAsync(request, cancellableToken);
} }
@@ -114,7 +106,6 @@ public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
[HttpPost("ready-to-sign")] [HttpPost("ready-to-sign")]
public async Task ReadyToSignAsync(ReadyToSignRequestRequest request, CancellationToken cancellableToken) public async Task ReadyToSignAsync(ReadyToSignRequestRequest request, CancellationToken cancellableToken)
{ {
var before = DateTimeOffset.UtcNow;
await Arena.ReadyToSignAsync(request, cancellableToken); await Arena.ReadyToSignAsync(request, cancellableToken);
} }