/// <summary> /// Creates an UNSIGNED input that links to the given output /// </summary> internal TransactionInput(NetworkParameters networkParams, Transaction parentTransaction, TransactionOutput output) : base(networkParams) { var outputIndex = output.Index; Outpoint = new TransactionOutPoint(networkParams, outputIndex, output.ParentTransaction); ScriptBytes = EmptyArray; _sequence = uint.MaxValue; ParentTransaction = parentTransaction; }
/// <summary> /// Adds the given output to this transaction. The output must be completely initialized. /// </summary> public void AddOutput(TransactionOutput to) { to.ParentTransaction = this; _outputs.Add(to); }
/// <summary> /// Adds an input to this transaction that imports value from the given output. Note that this input is NOT /// complete and after every input is added with addInput() and every output is added with addOutput(), /// signInputs() must be called to finalize the transaction and finish the inputs off. Otherwise it won't be /// accepted by the network. /// </summary> public void AddInput(TransactionOutput from) { AddInput(new TransactionInput(Params, this, from)); }
/// <exception cref="ProtocolException"/> protected override void Parse() { _version = ReadUint32(); // First come the inputs. var numInputs = ReadVarInt(); _inputs = new List<TransactionInput>((int) numInputs); for (var i = 0UL; i < numInputs; i++) { var input = new TransactionInput(Params, this, Bytes, Cursor); _inputs.Add(input); Cursor += input.MessageSize; } // Now the outputs var numOutputs = ReadVarInt(); _outputs = new List<TransactionOutput>((int) numOutputs); for (var i = 0UL; i < numOutputs; i++) { var output = new TransactionOutput(Params, this, Bytes, Cursor); _outputs.Add(output); Cursor += output.MessageSize; } _lockTime = ReadUint32(); }