Exemplo n.º 1
0
        protected override void Parse()
        {
            _version          = ReadUint32();
            _prevBlockHash    = ReadHash();
            _merkleRoot       = ReadHash();
            _time             = ReadUint32();
            _difficultyTarget = ReadUint32();
            _nonce            = ReadUint32();

            _hash = Utilities.ReverseBytes(Utilities.DoubleDigest(Bytes, 0, Cursor));

            if (Cursor == Bytes.Length)
            {
                // This message is just a header, it has no transactions.
                return;
            }

            var numTransactions = (int)ReadVarInt();

            Transactions = new List <TransactionMessage>(numTransactions);
            for (var i = 0; i < numTransactions; i++)
            {
                var tx = new TransactionMessage(Bytes, Cursor, P2PNetParameters);
                Transactions.Add(tx);
                Cursor += tx.MessageSize;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates an UNSIGNED input that links to the given output
 /// </summary>
 internal TransactionInput(TransactionMessage parentTransaction, Byte[] outpointHash, uint outpointIndex, P2PNetworkParameters netParams) : base(netParams)
 {
     _outpointHash     = outpointHash;
     _outpointIndex    = outpointIndex;
     ScriptBytes       = EmptyArray;
     _sequence         = uint.MaxValue;
     ParentTransaction = parentTransaction;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds a transaction to this block.
 /// </summary>
 internal void AddTransaction(TransactionMessage t)
 {
     if (Transactions == null)
     {
         Transactions = new List <TransactionMessage>();
     }
     Transactions.Add(t);
     // Force a recalculation next time the values are needed.
     _merkleRoot = null;
     _hash       = null;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deserializes an input message. This is usually part of a transaction message.
 /// </summary>
 /// <exception cref="BitCoinSharp.ProtocolException" />
 public TransactionInput(TransactionMessage parentTransaction, byte[] payload, int offset, P2PNetworkParameters netParams) : base(payload, offset, true, netParams)
 {
     ParentTransaction = parentTransaction;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Used only in creation of the genesis block.
 /// </summary>
 internal TransactionInput(TransactionMessage parentTransaction, byte[] scriptBytes, P2PNetworkParameters netParams) : base(netParams)
 {
     ScriptBytes       = scriptBytes;
     _sequence         = uint.MaxValue;
     ParentTransaction = parentTransaction;
 }