private static void WriteCharacter(char C) { if (OutputState == OutputStates.ReadingColor) { if (C == ';') { var color = ConsoleColor.White; if (Enum.TryParse(ColorName, out color)) { Console.ForegroundColor = color; } OutputState = OutputStates.Normal; } else { ColorName += C; } } else if (C == '$') { OutputState = OutputStates.ReadingColor; ColorName = ""; } else { Console.Write(C); } }
public UnspentTx(UInt256 txHash, int blockIndex, int txIndex, int length, OutputState state) { TxHash = txHash; BlockIndex = blockIndex; TxIndex = txIndex; OutputStates = new OutputStates(length, state); IsFullySpent = state == OutputState.Spent; }
public UnspentTx(UInt256 txHash, int blockIndex, int txIndex, OutputStates outputStates) { TxHash = txHash; BlockIndex = blockIndex; TxIndex = txIndex; OutputStates = outputStates; IsFullySpent = OutputStates.All(x => x == OutputState.Spent); }
public static byte[] EncodeOutputStates(OutputStates outputStates) { using (var stream = new MemoryStream()) { EncodeOutputStates(stream, outputStates); return(stream.ToArray()); } }
public static void EncodeOutputStates(Stream stream, OutputStates outputStates) { using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true)) { writer.WriteVarBytes(outputStates.ToByteArray()); writer.WriteInt32(outputStates.Length); } }
public UnspentTx(UInt256 txHash, int blockIndex, int txIndex, uint txVersion, bool isCoinbase, OutputStates outputStates) { TxHash = txHash; BlockIndex = blockIndex; TxIndex = txIndex; TxVersion = txVersion; IsCoinbase = isCoinbase; OutputStates = outputStates; IsFullySpent = OutputStates.All(x => x == OutputState.Spent); }
public static byte[] EncodeOutputStates(OutputStates outputStates) { var outputStateBytes = outputStates.ToByteArray(); var buffer = new byte[4 + outputStateBytes.Length]; Buffer.BlockCopy(BitConverter.GetBytes(outputStates.Length), 0, buffer, 0, 4); Buffer.BlockCopy(outputStateBytes, 0, buffer, 4, outputStateBytes.Length); return(buffer); }
public static UnspentTx DecodeUnspentTx(byte[] buffer, ref int offset) { var txHash = DecodeUInt256(buffer, ref offset); var blockIndex = DecodeInt32(buffer, ref offset); var index = DecodeInt32(buffer, ref offset); var txVersion = DecodeUInt32(buffer, ref offset); var isCoinbase = DecodeBool(buffer, ref offset); var outputStateBits = buffer.ReadVarBytes(ref offset); var outputStateLength = DecodeInt32(buffer, ref offset); var outputStates = new OutputStates(outputStateBits, outputStateLength); return(new UnspentTx(txHash, blockIndex, index, txVersion, isCoinbase, outputStates)); }
public static byte[] EncodeOutputStates(OutputStates outputStates) { var outputStateBytes = outputStates.ToByteArray(); var buffer = new byte[4 + outputStateBytes.Length]; Buffer.BlockCopy(BitConverter.GetBytes(outputStates.Length), 0, buffer, 0, 4); Buffer.BlockCopy(outputStateBytes, 0, buffer, 4, outputStateBytes.Length); return buffer; }
public static UnspentTx DecodeUnspentTx(byte[] buffer, ref int offset) { var txHash = DecodeUInt256(buffer, ref offset); var blockIndex = DecodeInt32(buffer, ref offset); var index = DecodeInt32(buffer, ref offset); var txVersion = DecodeUInt32(buffer, ref offset); var isCoinbase = DecodeBool(buffer, ref offset); var outputStateBits = buffer.ReadVarBytes(ref offset); var outputStateLength = DecodeInt32(buffer, ref offset); var outputStates = new OutputStates(outputStateBits, outputStateLength); return new UnspentTx(txHash, blockIndex, index, txVersion, isCoinbase, outputStates); }