public TrackedTransaction(TrackedTransactionKey key, TrackedSource trackedSource, IEnumerable <Coin> receivedCoins, Dictionary <Script, KeyPath> knownScriptMapping) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (!key.IsPruned) { throw new ArgumentException("The key should be pruned", nameof(key)); } if (trackedSource == null) { throw new ArgumentNullException(nameof(trackedSource)); } TrackedSource = trackedSource; Key = key; if (knownScriptMapping != null) { KnownKeyPathMapping = knownScriptMapping; } if (receivedCoins != null) { ReceivedCoins.AddRange(receivedCoins); } }
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 }); } } } }