mirror of
https://github.com/aljazceru/btcpayserver-breez-nodeless-plugin.git
synced 2025-12-17 00:24:22 +01:00
64 lines
2.3 KiB
Plaintext
64 lines
2.3 KiB
Plaintext
@using BTCPayServer.Lightning
|
|
@using BTCPayServer.Models.StoreViewModels
|
|
@using BTCPayServer.Plugins.BreezSpark
|
|
@using BTCPayServer.Security
|
|
@inject BreezSparkService BreezService
|
|
|
|
@{
|
|
ViewData.SetActivePage("Breez", "Receive", "Receive");
|
|
var storeId = Model switch
|
|
{
|
|
string s => s,
|
|
StoreDashboardViewModel dashboardModel => dashboardModel.StoreId,
|
|
_ => Context.GetImplicitStoreId()
|
|
};
|
|
var sdk = BreezService.GetClient(storeId)?.Sdk;
|
|
if (sdk is null)
|
|
return;
|
|
|
|
var nodeInfo = new Breez.Sdk.Spark.GetInfoRequest(ensureSynced: false);
|
|
Breez.Sdk.Spark.GetInfoResponse? infoResponse = null;
|
|
try
|
|
{
|
|
infoResponse = await sdk.GetInfo(nodeInfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
<div class="alert alert-danger" role="alert">
|
|
<h5 class="alert-heading">Error</h5>
|
|
<p class="mb-0">Unable to fetch node information: @ex.Message</p>
|
|
</div>
|
|
return;
|
|
}
|
|
|
|
var max = LightMoney.Satoshis((long)(infoResponse?.balanceSats ?? 0));
|
|
|
|
}
|
|
|
|
|
|
<form method="post" asp-action="Receive" asp-route-storeId="@storeId">
|
|
<div class="row mb-4">
|
|
<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 class="d-flex gap-3 mt-3 mt-sm-0">
|
|
|
|
<button type="submit" class="btn btn-primary">Create Invoice</button>
|
|
</div>
|
|
</div>
|
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
|
<div class="form-group">
|
|
<label for="amount" class="form-label">Amount (sats)</label>
|
|
<input type="number" id="amount" min="1" max="@max.ToUnit(LightMoneyUnit.Satoshi)" name="amount" class="form-control" placeholder="Optional: leave empty for amountless invoice"/>
|
|
<small class="form-text text-muted">Maximum receivable: @max.ToUnit(LightMoneyUnit.Satoshi) sats</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="description" class="form-label">Description</label>
|
|
<input type="text" id="description" name="description" class="form-control" placeholder="Payment description"/>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</form> |