-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send: Add transactions list and onchain verify dialog
- Loading branch information
1 parent
057ef98
commit 42d0b66
Showing
13 changed files
with
393 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
@using BTCPayApp.UI.Models | ||
<div @attributes="InputAttributes" class="@CssClass"> | ||
@if (Loading) | ||
{ | ||
<div class="p-3 text-center"> | ||
<LoadingIndicator/> | ||
</div> | ||
} | ||
@if (Transactions is not null) | ||
{ | ||
@if (Transactions.Any()) | ||
{ | ||
@foreach (var t in Transactions) | ||
{ | ||
<div class="box"> | ||
<TransactionsListItem Transaction="@t" Unit="@Unit" OnToggleDisplayCurrency="OnToggleDisplayCurrency"/> | ||
</div> | ||
} | ||
} | ||
else if (!string.IsNullOrEmpty(Error)) | ||
{ | ||
<Alert Type="danger">@Error</Alert> | ||
} | ||
else | ||
{ | ||
<div class="box"> | ||
<p class="text-muted my-0">There are no transactions, yet.</p> | ||
</div> | ||
} | ||
} | ||
</div> | ||
|
||
@code { | ||
[Parameter] | ||
public IEnumerable<TransactionModel>? Transactions { get; set; } | ||
|
||
[Parameter, EditorRequired] | ||
public string? Unit { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback OnToggleDisplayCurrency { get; set; } | ||
|
||
[Parameter] | ||
public bool Loading { get; set; } | ||
|
||
[Parameter] | ||
public string? Error { get; set; } | ||
|
||
[Parameter(CaptureUnmatchedValues = true)] | ||
public Dictionary<string, object>? InputAttributes { get; set; } | ||
|
||
private string CssClass => $"transactions-list {(InputAttributes?.ContainsKey("class") is true ? InputAttributes["class"] : "")}".Trim(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.transactions-list .box { | ||
margin-bottom: 0 !important; | ||
} | ||
|
||
.transactions-list .box + .box { | ||
margin-top: var(--btcpay-space-xs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
@using BTCPayApp.UI.Models | ||
@using BTCPayServer.Lightning | ||
|
||
<div> | ||
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2" @onclick="() => _showDetails = !_showDetails"> | ||
<span class="flex-grow-1 text-muted"> | ||
<DateDisplay DateTimeOffset="@Transaction.Timestamp"/> | ||
</span> | ||
<AmountDisplay Value="Transaction.Value.ToDecimal(UnitLightMoney)" Unit="@Unit" OnToggleDisplayCurrency="ToggleDisplayCurrency" class="@AmountClass" /> | ||
<span class="w-100px ms-auto text-end"> | ||
<span class="@BadgeClass">@UnifyStatus(Transaction.Status)</span> | ||
</span> | ||
</div> | ||
<div class="collapse @(_showDetails ? "show" : null)"> | ||
<div class="pt-3"> | ||
<div class="form-floating"> | ||
<span class="truncate-center form-control-plaintext" style="padding-right:3px;padding-left:3px;padding-bottom:0;font-weight: var(--btcpay-font-weight-semibold);"> | ||
<DateDisplay DateTimeOffset="@Transaction.Timestamp" Format="DateDisplay.DateDisplayFormat.Localized"/> | ||
</span> | ||
<label>Date</label> | ||
</div> | ||
@if (Transaction is { PaymentMethod: TransactionPaymentMethod.Onchain, OnchainTransaction: not null }) | ||
{ | ||
<div class="form-floating"> | ||
<TruncateCenter Text="@Transaction.OnchainTransaction.TransactionId" Padding="15" Copy="true" Elastic="true" class="form-control-plaintext"/> | ||
<label>Transaction ID</label> | ||
</div> | ||
} | ||
else if (Transaction is { PaymentMethod: TransactionPaymentMethod.Lightning, LightningPayment: not null }) | ||
{ | ||
<div class="form-floating"> | ||
<TruncateCenter Text="@Transaction.LightningPayment.PaymentRequest.ToString()" Padding="15" Copy="true" Elastic="true" class="form-control-plaintext"/> | ||
<label>Payment Request</label> | ||
</div> | ||
@if (Transaction.LightningPayment.Preimage != null) | ||
{ | ||
<div class="form-floating"> | ||
<TruncateCenter Text="@Transaction.LightningPayment.Preimage" Padding="15" Copy="true" Elastic="true" class="form-control-plaintext"/> | ||
<label>Preimage</label> | ||
</div> | ||
} | ||
} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
@code { | ||
[Parameter, EditorRequired] | ||
public TransactionModel Transaction { get; set; } = null!; | ||
|
||
[Parameter, EditorRequired] | ||
public string? Unit { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback OnToggleDisplayCurrency { get; set; } | ||
|
||
private bool _showDetails; | ||
private LightMoneyUnit UnitLightMoney => Unit == "SATS" ? LightMoneyUnit.Satoshi : LightMoneyUnit.BTC; | ||
private string AmountClass => $"flex-grow-1 text-end fw-semibold text-{(Transaction.Type == TransactionType.Receive ? "success" : "danger")}"; | ||
private string BadgeClass | ||
{ | ||
get | ||
{ | ||
var clss = "badge"; | ||
var status = UnifyStatus(Transaction.Status).ToLower(); | ||
switch (Transaction.PaymentMethod) | ||
{ | ||
case TransactionPaymentMethod.Onchain: | ||
clss += $" badge-{(status == "unconfirmed" ? "pending" : "settled")}"; | ||
break; | ||
case TransactionPaymentMethod.Lightning: | ||
clss += $" badge-{status}"; | ||
break; | ||
} | ||
return clss; | ||
} | ||
} | ||
|
||
private string UnifyStatus(string original) | ||
{ | ||
return original switch | ||
{ | ||
"Confirmed" or "Complete" => "Settled", | ||
_ => original | ||
}; | ||
} | ||
|
||
private async Task ToggleDisplayCurrency() | ||
{ | ||
if (OnToggleDisplayCurrency.HasDelegate) | ||
await OnToggleDisplayCurrency.InvokeAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a { | ||
display: block; | ||
color: var(--btcpay-body-text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using BTCPayApp.Core.Data; | ||
using BTCPayServer.Client.App; | ||
using BTCPayServer.Lightning; | ||
|
||
namespace BTCPayApp.UI.Models; | ||
|
||
public enum TransactionPaymentMethod | ||
{ | ||
Onchain, | ||
Lightning | ||
} | ||
|
||
public enum TransactionType | ||
{ | ||
Send, | ||
Receive | ||
} | ||
|
||
public class TransactionModel | ||
{ | ||
public string Id { get; set; } | ||
public LightMoney Value { get; set; } | ||
public DateTimeOffset Timestamp { get; set; } | ||
public string Status { get; set; } | ||
public TransactionType Type { get; set; } | ||
public TransactionPaymentMethod PaymentMethod { get; set; } | ||
public AppLightningPayment? LightningPayment { get; set; } | ||
public TxResp? OnchainTransaction { get; set; } | ||
} |
Oops, something went wrong.