Ejemplo n.º 1
0
 /// <summary>
 /// Creates an UNSIGNED input that links to the given output
 /// </summary>
 internal TransactionInput(NetworkParameters @params, Transaction parentTransaction, TransactionOutput output)
     : base(@params)
 {
     var outputIndex = output.Index;
     Outpoint = new TransactionOutPoint(@params, outputIndex, output.ParentTransaction);
     ScriptBytes = EmptyArray;
     _sequence = uint.MaxValue;
     ParentTransaction = parentTransaction;
 }
Ejemplo n.º 2
0
 /// <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));
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 /// <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();
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 /// <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));
 }
Ejemplo n.º 7
0
        /// <exception cref="BitCoinSharp.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();

            // Store a hash, it may come in useful later (want to avoid re-serialization costs).
            _hash = new Sha256Hash(Utils.ReverseBytes(Utils.DoubleDigest(Bytes, Offset, Cursor - Offset)));
        }
        /// <summary>
        /// Creates an UNSIGNED input that links to the given output
        /// </summary>
        internal TransactionInput(NetworkParameters @params, Transaction parentTransaction, TransactionOutput output)
            : base(@params)
        {
            var outputIndex = output.Index;

            Outpoint          = new TransactionOutPoint(@params, outputIndex, output.ParentTransaction);
            ScriptBytes       = EmptyArray;
            _sequence         = uint.MaxValue;
            ParentTransaction = parentTransaction;
        }