예제 #1
0
 internal void MarkAsUnspent()
 {
     _availableForSpending = true;
     _spentBy = null;
 }
예제 #2
0
 /// <summary>
 /// Adds an input directly, with no checking that it's valid.
 /// </summary>
 public void AddInput(TransactionInput input)
 {
     _inputs.Add(input);
 }
예제 #3
0
 /// <summary>
 /// Sets this objects availableToSpend flag to false and the spentBy pointer to the given input.
 /// If the input is null, it means this output was signed over to somebody else rather than one of our own keys.
 /// </summary>
 internal void MarkAsSpent(TransactionInput input)
 {
     Debug.Assert(_availableForSpending);
     _availableForSpending = false;
     _spentBy = input;
 }
예제 #4
0
파일: Block.cs 프로젝트: Virus-X/CoinSharp
        /// <summary>
        /// Returns a solved block that builds on top of this one. This exists for unit tests.
        /// </summary>
        internal Block CreateNextBlock(Address to, uint time)
        {
            var b = new Block(Params);
            b.DifficultyTarget = _difficultyTarget;
            b.AddCoinbaseTransaction(_emptyBytes);

            // Add a transaction paying 50 coins to the "to" address.
            var t = new Transaction(Params);
            t.AddOutput(new TransactionOutput(Params, t, Utils.ToNanoCoins(50, 0), to));
            // The input does not really need to be a valid signature, as long as it has the right general form.
            var input = new TransactionInput(Params, t, Script.CreateInputScript(_emptyBytes, _emptyBytes));
            // Importantly the outpoint hash cannot be zero as that's how we detect a coinbase transaction in isolation
            // but it must be unique to avoid 'different' transactions looking the same.
            var counter = new byte[32];
            counter[0] = (byte) _txCounter++;
            input.Outpoint.Hash = new Sha256Hash(counter);
            t.AddInput(input);
            b.AddTransaction(t);

            b.PrevBlockHash = Hash;
            b.TimeSeconds = time;
            b.Solve();
            b.VerifyHeader();
            return b;
        }
예제 #5
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();
 }
예제 #6
0
 /// <summary>
 /// Adds an input directly, with no checking that it's valid.
 /// </summary>
 public void AddInput(TransactionInput input)
 {
     _inputs.Add(input);
 }
예제 #7
0
 internal void MarkAsUnspent()
 {
     _availableForSpending = true;
     _spentBy = null;
 }
예제 #8
0
 /// <summary>
 /// Sets this objects availableToSpend flag to false and the spentBy pointer to the given input.
 /// If the input is null, it means this output was signed over to somebody else rather than one of our own keys.
 /// </summary>
 internal void MarkAsSpent(TransactionInput input)
 {
     Debug.Assert(_availableForSpending);
     _availableForSpending = false;
     _spentBy = input;
 }