Skip to content

Commit

Permalink
Add already include check.
Browse files Browse the repository at this point in the history
  • Loading branch information
fassadlr committed Sep 6, 2022
1 parent 0dbf584 commit 674695f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Stratis.Bitcoin.Features.Wallet/WalletRPCController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ public UnspentCoinModel[] ListUnspent(int minConfirmations = 1, int maxConfirmat
continue;

WalletAccountReference accountReference = new WalletAccountReference(walletName, account.Name);

IEnumerable<UnspentOutputReference> spendableTransactions = this.walletManager.GetSpendableTransactionsInAccount(accountReference, minConfirmations);

foreach (var spendableTx in spendableTransactions)
Expand All @@ -783,6 +783,11 @@ public UnspentCoinModel[] ListUnspent(int minConfirmations = 1, int maxConfirmat
if (addresses.Any() && !addresses.Contains(BitcoinAddress.Create(spendableTx.Address.Address, this.FullNode.Network)))
continue;

// Check if the transaction is already in the list.
// The node operator could be using the wallet for both "actual" and watch only accounts.
if (unspentCoins.Any(u => u.Id == spendableTx.Transaction.Id))
continue;

unspentCoins.Add(new UnspentCoinModel()
{
Account = accountReference.AccountName,
Expand Down

0 comments on commit 674695f

Please sign in to comment.