Skip to content

Commit d6ae2b6

Browse files
authored
Merge pull request #1050 from stratisproject/fixlistunspent
RPC: Filter ListUnspent transactions for duplicates
2 parents 0dbf584 + 6cd9dd7 commit d6ae2b6

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Stratis.Bitcoin.Features.Wallet/WalletRPCController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ public UnspentCoinModel[] ListUnspent(int minConfirmations = 1, int maxConfirmat
772772
continue;
773773

774774
WalletAccountReference accountReference = new WalletAccountReference(walletName, account.Name);
775-
775+
776776
IEnumerable<UnspentOutputReference> spendableTransactions = this.walletManager.GetSpendableTransactionsInAccount(accountReference, minConfirmations);
777777

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

786+
// Check if the transaction is already in the list.
787+
// The node operator could be using the wallet for both "actual" and watch only accounts.
788+
if (unspentCoins.Any(u => u.Id == spendableTx.Transaction.Id && u.Index == spendableTx.Transaction.Index))
789+
continue;
790+
786791
unspentCoins.Add(new UnspentCoinModel()
787792
{
788793
Account = accountReference.AccountName,

0 commit comments

Comments
 (0)