private List <TransactionInformation> Filter(ICollection <RPCWalletEntry> entries, bool includeUnconf, Script scriptPubKey) { List <TransactionInformation> results = new List <TransactionInformation>(); HashSet <uint256> resultsSet = new HashSet <uint256>(); foreach (var obj in entries) { //May have duplicates if (!resultsSet.Contains(obj.TransactionId)) { var confirmations = obj.Confirmations; var tx = _Cache.GetTransaction(obj.TransactionId); if (tx == null || (!includeUnconf && confirmations == 0)) { continue; } if (tx.Outputs.Any(o => o.ScriptPubKey == scriptPubKey) || tx.Inputs.Any(o => o.ScriptSig.GetSigner().ScriptPubKey == scriptPubKey)) { resultsSet.Add(obj.TransactionId); results.Add(new TransactionInformation() { Transaction = tx, Confirmations = confirmations }); } } } return(results); }
private bool IsDoubleSpend(Transaction tx) { var spentInputs = new HashSet <OutPoint>(tx.Inputs.Select(txin => txin.PrevOut)); foreach (var entry in _Cache.GetEntries()) { if (entry.Confirmations > 0) { var walletTransaction = _Cache.GetTransaction(entry.TransactionId); foreach (var input in walletTransaction.Inputs) { if (spentInputs.Contains(input.PrevOut)) { return(true); } } } } return(false); }