/// <summary> /// Creates a clone of this instance /// </summary> /// <returns>A clone of this instance</returns> public object Clone() { return(new ExpansionBoard { Name = (Name != null) ? string.Copy(Name) : null, Revision = (Revision != null) ? string.Copy(Revision) : null, Firmware = (Firmware)Firmware.Clone(), VIn = (MinMaxCurrent <float?>)VIn.Clone(), McuTemp = (MinMaxCurrent <float?>)McuTemp.Clone(), MaxHeaters = MaxHeaters, MaxMotors = MaxMotors }); }
/// <summary> /// Creates a clone of this instance /// </summary> /// <returns>A clone of this instance</returns> public object Clone() { return(new Electronics { Type = (Type != null) ? string.Copy(Type) : null, Name = (Name != null) ? string.Copy(Name) : null, Revision = (Revision != null) ? string.Copy(Revision) : null, Firmware = (Firmware)Firmware.Clone(), ProcessorID = (ProcessorID != null) ? string.Copy(ProcessorID) : null, VIn = (MinMaxCurrent <float?>)VIn.Clone(), McuTemp = (MinMaxCurrent <float?>)McuTemp.Clone(), ExpansionBoards = ExpansionBoards.Select(board => (ExpansionBoard)board.Clone()).ToList() }); }
public bool Equals(Payload other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(TransactionId, other.TransactionId) && string.Equals(Hash, other.Hash) && Size == other.Size && Vsize == other.Vsize && Version == other.Version && LockTime == other.LockTime && string.Equals(Blockhash, other.Blockhash) && BlockNumber == other.BlockNumber && Confirmations == other.Confirmations && string.Equals(Time, other.Time) && VIn.SequenceEqual(other.VIn) && VOut.SequenceEqual(other.VOut)); }
public override int GetHashCode() { unchecked { var hashCode = (TransactionId != null ? TransactionId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Hash != null ? Hash.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Size.GetHashCode(); hashCode = (hashCode * 397) ^ Vsize.GetHashCode(); hashCode = (hashCode * 397) ^ Version.GetHashCode(); hashCode = (hashCode * 397) ^ LockTime.GetHashCode(); hashCode = (hashCode * 397) ^ (Blockhash != null ? Blockhash.GetHashCode() : 0); hashCode = (hashCode * 397) ^ BlockNumber.GetHashCode(); hashCode = (hashCode * 397) ^ Confirmations.GetHashCode(); hashCode = (hashCode * 397) ^ (Time != null ? Time.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VIn != null ? VIn.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VOut != null ? VOut.GetHashCode() : 0); return(hashCode); } }
public async Task <Transaction> GetTransaction(string id) { try { GetRawTransactionRpcModel tx = await RpcClient.GetRawTransactionAsync(id); if (tx == null) { return(null); } TransactionType transactiontype = GetTransactionType(tx); var transaction = new Transaction { OriginalJson = tx.OriginalJson, TransactionType = transactiontype, Blockhash = tx.Blockhash, TransactionId = tx.Txid, Size = tx.Size, TransactionIn = new List <VIn>(), TransactionsOut = new List <Out>(), Time = tx.GetTime() }; int index = 0; foreach (var rpcIn in tx.Vin) { var vIn = new VIn { Index = index, Coinbase = rpcIn.Coinbase, Sequence = rpcIn.Sequence, ScriptSigHex = rpcIn.ScriptSig?.Hex, AssetId = null, // pointer to previous tx/vout: PrevTxIdPointer = rpcIn.Txid, PrevVOutPointer = (int)rpcIn.Vout, // we'll try to fetch this id possible PrevVOutFetchedAddress = null, PrevVOutFetchedValue = 0 }; if (rpcIn.Txid != null) { // Retrieve the origin address by retrieving the previous transaction and extracting the receive address and value var previousTx = await RpcClient.GetRawTransactionAsync(rpcIn.Txid); if (previousTx != null) { var n = rpcIn.Vout; Debug.Assert(n == previousTx.Vout[n].N); vIn.PrevVOutFetchedAddress = previousTx.Vout[n].ScriptPubKey.Addresses.First(); vIn.PrevVOutFetchedValue = previousTx.Vout[n].Value; } } transaction.TransactionIn.Add(vIn); } index = 0; foreach (var output in tx.Vout) { var @out = new Out { TransactionId = transaction.TransactionId, Value = output.Value, Quantity = output.N, AssetId = null, Index = index++, }; if (output.ScriptPubKey.Addresses != null) // Satoshi 14.2 { @out.Address = output.ScriptPubKey.Addresses.FirstOrDefault(); } else { string hexScript = output.ScriptPubKey.Hex; if (!string.IsNullOrEmpty(hexScript)) { byte[] decodedScript = Encoders.Hex.DecodeData(hexScript); Script script = new Script(decodedScript); var pubKey = PayToPubkeyTemplate.Instance.ExtractScriptPubKeyParameters(script); if (pubKey != null) { BitcoinPubKeyAddress address = pubKey.GetAddress(NetworkSpec.ObsidianMain()); @out.Address = address.ToString(); } else { @out.Address = script.ToString(); } } else { Debug.Assert(output.ScriptPubKey.Type == NonStandardAddress); @out.Address = output.ScriptPubKey.Type; } } transaction.TransactionsOut.Add(@out); } return(transaction); } catch { } return(null); }