Example #1
0
 public IEnumerable <WalletRule> GetMatchedRules(OutPoint outPoint)
 {
     if (outPoint.Hash == TransactionId)
     {
         return(GetMatchedRules((int)outPoint.N, MatchLocation.Output));
     }
     else
     {
         var index = SpentOutpoints.IndexOf(outPoint);
         if (index == -1)
         {
             return(new WalletRule[0]);
         }
         return(GetMatchedRules((int)SpentIndices[index], MatchLocation.Input));
     }
 }
Example #2
0
        internal void Merge(OrderedBalanceChange other, WalletRule walletRule)
        {
            if (other.ReceivedCoins.Count != 0)
            {
                ReceivedCoins.AddRange(other.ReceivedCoins);
                ReceivedCoins = new CoinCollection(ReceivedCoins.Distinct <ICoin, OutPoint>(c => c.Outpoint));
                if (walletRule != null)
                {
                    foreach (var c in other.ReceivedCoins)
                    {
                        this.MatchedRules.Add(new MatchedRule()
                        {
                            Index     = c.Outpoint.N,
                            Rule      = walletRule,
                            MatchType = MatchLocation.Output
                        });
                    }
                }
            }

            if (other.SpentIndices.Count != 0)
            {
                SpentIndices.AddRange(other.SpentIndices);
                SpentIndices = SpentIndices.Distinct().ToList();

                SpentOutpoints.AddRange(other.SpentOutpoints);
                SpentOutpoints = SpentOutpoints.Distinct().ToList();

                //Remove cached value, no longer correct
                UpdateToUncoloredCoins();
                SpentCoins = null;

                if (walletRule != null)
                {
                    foreach (var c in other.SpentIndices)
                    {
                        this.MatchedRules.Add(new MatchedRule()
                        {
                            Index     = c,
                            Rule      = walletRule,
                            MatchType = MatchLocation.Input
                        });
                    }
                }
            }
        }
Example #3
0
        internal void KnownKeyPathMappingUpdated()
        {
            if (Transaction == null)
            {
                return;
            }
            var scriptPubKey = (TrackedSource as IDestination)?.ScriptPubKey;

            for (int i = 0; i < Transaction.Outputs.Count; i++)
            {
                var output = Transaction.Outputs[i];
                if (KnownKeyPathMapping.ContainsKey(output.ScriptPubKey) || scriptPubKey == output.ScriptPubKey)
                {
                    ReceivedCoins.Add(new Coin(new OutPoint(Key.TxId, i), output));
                }
            }
            SpentOutpoints.AddRange(Transaction.Inputs.Select(input => input.PrevOut));
        }
Example #4
0
 internal void Clear()
 {
     Reset = false;
     UTXOs.Clear();
     SpentOutpoints.Clear();
 }