/// <summary> /// Parses an input from the specified stream. /// </summary> /// <param name="stream">A BlockDataStream containing the data to load.</param> /// <exception cref="System.ArgumentException">The specified stream is NULL or invalid.</exception> /// <exception cref="System.InvalidOperationException">The input could not be parsed from the specified stream.</exception> /// <returns>An Input parsed from the stream.</returns> internal static Input Parse(BlockchainStream stream) { Input returnValue; // Verify params if (stream == null) { throw new ArgumentException("The specified stream is NULL", nameof(stream)); } // Get the previous transaction if (stream.TryReadBytes(32, out byte[] transaction))
/// <summary> /// Parses a variable integer from the specified stream. /// </summary> /// <param name="stream">A BlockDataStream to pasre the variable integer from.</param> /// <returns>A VarInt pasred from the stream.</returns> internal static VarInt Parse(BlockchainStream stream) { VarInt returnValue; // Verify params if (stream == null) { throw new ArgumentException("The specified stream is NULL", nameof(stream)); } // Get the leading byte if (stream.TryReadBytes(1, out byte[] data))
/// <summary> /// Parses an output from the specified stream. /// </summary> /// <param name="stream">A BlockDataStream containing the data to load.</param> /// <exception cref="System.ArgumentException">The specified stream is NULL or invalid.</exception> /// <exception cref="System.InvalidOperationException">The output could not be parsed from the specified stream.</exception> /// <returns>An Output parsed from the stream.</returns> internal static Output Parse(BlockchainStream stream) { Output returnValue; // Verify params if (stream == null) { throw new ArgumentException("The specified stream is NULL", nameof(stream)); } // Get the value of the output if (stream.TryReadLong(out long value)) { // Get the size of the redeem script if (stream.TryReadVarInt(out VarInt scriptPubKeySize) && scriptPubKeySize.AsInt32 > 0) { // Get the signature script if (stream.TryReadBytes(scriptPubKeySize.AsInt32, out byte[] scriptPubKey)) { returnValue = new Output(value, scriptPubKey); }