Skip to content

Commit

Permalink
Fix coin control (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangershony committed Jan 25, 2024
1 parent 2fd0e09 commit 5bd356c
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/Angor/Client/Pages/Wallet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@
<div class="address-container-wrapper">
<div class="address-container">
<div class="d-flex align-items-center">
<p id="receive-address" class="card-text mb-0">@accountBalanceInfo.AccountInfo.GetNextReceiveAddress()</p>
<p class="card-text mb-0">@accountBalanceInfo.AccountInfo.GetNextReceiveAddress()</p>
<button class="btn btn-outline-secondary btn-sm address-copy-button ml-2" @onclick="CopyNextReceiveAddress">
<i class="oi oi-file"></i>
Copy <i class="oi oi-file"></i>
</button>
</div>
</div>
Expand Down Expand Up @@ -213,7 +213,12 @@
<input type="text" class="form-control" id="sendAmount" @bind="_sendInfo.SendAmount" placeholder="Enter amount">
</div>

<button type="button" class="btn btn-primary mb-3" @onclick="() => coinControlModal = true">Coin Control</button>
<button type="button" class="btn btn-primary mb-3" @onclick="() => coinControlModal = true">Coin Control
@if (_sendInfo.SendUtxos.Any())
{
<span class="badge text-bg-warning">@_sendInfo.SendUtxos.Count</span>
}
</button>

<!-- New Send button that triggers a confirmation dialog -->
<button type="button" class="btn btn-primary mb-3" onclick="@BuildSend">Send</button>
Expand Down Expand Up @@ -243,7 +248,7 @@
bool isTicked = _sendInfo.SendUtxos.ContainsKey(addressUtxoItem.outpoint.ToString());

<div class="form-check">
<input class="form-check-input" type="checkbox" value="@isTicked" id="@addressUtxoItem" @onclick="() => HandleCheckboxChange(addressUtxoItem, addressInfo.HdPath)">
<input class="form-check-input" type="checkbox" @bind="@isTicked" @onclick="() => HandleCheckboxChange(addressUtxoItem, addressInfo.HdPath)">
<label class="form-check-label" style="font-size: 0.7em;" for="@addressUtxoItem">
@($"{addressUtxoItem.outpoint} - {Money.Satoshis(@addressUtxoItem.value).ToUnit(MoneyUnit.BTC)} {@network.CoinTicker}")
</label>
Expand Down Expand Up @@ -293,7 +298,6 @@

@foreach (var infoSendUtxo in _sendInfo.SendUtxos)
{
<br />
<p style="font-size: 0.7em;">@Money.Satoshis(infoSendUtxo.Value.UtxoData.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker - @infoSendUtxo.Key</p>
}

Expand Down Expand Up @@ -606,6 +610,16 @@
{
var operationResult = await notificationComponent.LongOperation(async () =>
{
if (string.IsNullOrEmpty(_sendInfo.SendToAddress))
{
return new OperationResult { Success = false, Message = "Specify a send to address" };
}

if (_sendInfo.SendAmount == 0)
{
return new OperationResult { Success = false, Message = "Specify an amount" };
}

var accountInfo = storage.GetAccountInfo(network.Name);

await _walletOperations.UpdateAccountInfoWithNewAddressesAsync(accountInfo);
Expand Down

0 comments on commit 5bd356c

Please sign in to comment.