public TransactionInput ThawTree() { ContractsCommon.IsThawed(Contract.Result <TransactionInput>().Source); ContractsCommon.IsThawed(Contract.Result <TransactionInput>().Script); return(new TransactionInput(this, true)); }
public Transaction ThawTree() { ContractsCommon.IsThawed(Contract.Result <Transaction>().TransactionInputs); ContractsCommon.IsThawed(Contract.Result <Transaction>().TransactionOutputs); return(new Transaction(this, true)); }
protected static short ReadInt16(Stream stream) { ContractsCommon.NotNull(stream, "stream"); int value = stream.ReadByte() | (stream.ReadByte() << 8); return((short)value); }
public Hash160 Ripemd160(byte[] buffer) { ContractsCommon.NotNull(buffer, "buffer"); ContractsCommon.ResultIsNonNull <Hash160>(); return(default(Hash160)); }
protected Hash(byte[] hash) { ContractsCommon.NotNull(hash, "hash"); Contract.Assert(hash.Length == HashByteSize); _bytes = (byte[])hash.Clone(); }
public Hash256 Hash256(byte[] buffer) { ContractsCommon.NotNull(buffer, "buffer"); ContractsCommon.ResultIsNonNull <Hash256>(); return(default(Hash256)); }
protected sealed override void Deserialize(Stream stream) { ContractsCommon.NotFrozen(this); ContractsCommon.NotNull(stream, "stream"); //Contract.Requires<ArgumentOutOfRangeException>(length <= stream.Length, "length"); //Contract.Requires<ArgumentOutOfRangeException>(stream.Position + length <= stream.Length, "length"); }
public static void Serialize(Stream stream, BitcoinSerializable obj) { ContractsCommon.NotNull(stream, "stream"); ContractsCommon.NotNull(obj, "obj"); obj.Serialize(stream); }
public TransactionOutpoint(TransactionOutpoint outpoint) { ContractsCommon.NotNull(outpoint, "outpoint"); _sourceTransactionHash = outpoint._sourceTransactionHash; _outputSequenceNumber = outpoint._outputSequenceNumber; }
protected static void WriteBytes(Stream stream, byte[] buffer, int offset, int length) { ContractsCommon.CanWriteToStream(stream, BufferOperations.UINT8_SIZE * length); ContractsCommon.NotNull(buffer, "buffer"); ContractsCommon.ValidOffsetLength(0, buffer.Length, offset, length); stream.Write(buffer, offset, length); }
public Block(Block block, bool thawChildren) { ContractsCommon.NotNull(block, "block"); Contract.Ensures(this.Version == block.Version); Contract.Ensures(this.PreviousBlockHash == block.PreviousBlockHash); Contract.Ensures(this.Timestamp == block.Timestamp); Contract.Ensures(this.DifficultyBits == block.DifficultyBits); Contract.Ensures(this.Nonce == block.Nonce); Contract.Ensures(this.Transactions.SequencedEquals(block.Transactions)); Contract.Ensures(this.MerkleRoot == block.MerkleRoot); ContractsCommon.ChildrenThawed(Transactions, thawChildren); this._version = block._version; this._previousBlockHash = block._previousBlockHash; this._timestamp = block._timestamp; this._difficultyBits = block._difficultyBits; this._nonce = block._nonce; if (block._merkleTree != null) { var tree = new ArrayList <Hash256>(block._merkleTree.Count); tree.AddAll(block._merkleTree); this._merkleTree = new GuardedList <Hash256>(tree); } var transactions = new HashedArrayList <Transaction>(block.Transactions.Count); transactions.AddAll(FreezableExtensions.ThawChildren(block.Transactions, thawChildren)); transactions.CollectionChanged += InvalidateMerkleTree; this.Transactions = transactions; }
private void InvalidateMerkleTree(object sender) { ContractsCommon.NotFrozen(this); _merkleTree = null; InvalidateBitcoinHashes(); }
public bool VerifyHash(byte[] hash, byte[] signature) { ContractsCommon.NotNull(hash, "hash"); ContractsCommon.NotNull(signature, "signature"); return(default(bool)); }
protected static void Write(Stream stream, short value) { ContractsCommon.CanWriteToStream(stream, BufferOperations.UINT16_SIZE); var bytes = BitConverter.GetBytes(value); stream.Write(bytes, 0, bytes.Length); }
public static T Peek <T>(this IStack <T> stack, int depth) { ContractsCommon.NotNull(stack, "stack"); ContractsCommon.ValidOffset(0, stack.Count, depth, "depth"); return(stack[stack.Count - depth - 1]); }
public int ResultCount(ExecutionContext context) { ContractsCommon.NotNull(context, "context"); Contract.Ensures(Contract.Result <int>() >= 0); return(default(int)); }
public byte[] RetreivePrivateKey() { Contract.Requires(HasPrivateKey); ContractsCommon.ResultIsNonNull <byte[]>(); return(default(byte[])); }
public static IList <Hash256> CalculateMerkleTree(SCG.IEnumerable <Transaction> transactions) { ContractsCommon.NotNull(transactions, "transactions"); Contract.Requires(Contract.ForAll(transactions, tx => tx != null)); ContractsCommon.ResultIsNonNull <IList <Hash256> >(); var tree = new ArrayList <Hash256>(); foreach (var trans in transactions) { tree.Add(trans.Hash256); } int j = 0; for (int size = tree.Count; size > 1; size = (size + 1) / 2) { for (int i = 0; i < size; i += 2) { int i2 = Math.Min(i + 1, size - 1); tree.Add(CryptoFunctionProviderFactory.Default.Hash256(tree[j + i].Bytes, tree[j + i2].Bytes)); } j += size; } return(new GuardedList <Hash256>(tree)); }
public TransactionOutput(TransactionOutput txOut, bool thawChildren) { ContractsCommon.NotNull(txOut, "txOut"); ContractsCommon.ChildThawed(Script, thawChildren); _value = txOut._value; _script = FreezableExtensions.ThawChild(txOut._script, thawChildren); }
public T ThawTree() { ContractsCommon.ResultIsNonNull <T>(); ContractsCommon.IsThawed(Contract.Result <T>()); Contract.Ensures(IsFrozen == Contract.OldValue(IsFrozen)); return(default(T)); }
public byte[] SignHash(byte[] hash) { Contract.Requires(HasPrivateKey); ContractsCommon.NotNull(hash, "hash"); ContractsCommon.ResultIsNonNull <byte[]>(); return(default(byte[])); }
public Hash160 Sha1(byte[] buffer, int offset, int length) { ContractsCommon.NotNull(buffer, "buffer"); ContractsCommon.ValidOffsetLength(0, buffer.Length, offset, length); ContractsCommon.ResultIsNonNull <Hash160>(); return(default(Hash160)); }
public ECDsaBouncyCastle(byte[] encodedPublicKey) { ContractsCommon.NotNull(encodedPublicKey, "encodedPublicKey"); var secp256k1 = SecP256k1; _publicKey = new ECPublicKeyParameters(secp256k1.Curve.DecodePoint(encodedPublicKey), secp256k1); }
protected BitcoinSerializable(Stream stream) { ContractsCommon.NotNull(stream, "stream"); //Contract.Requires<ArgumentOutOfRangeException>(length <= stream.Length, "length"); //Contract.Requires<ArgumentOutOfRangeException>(stream.Position + length <= stream.Length, "length"); this.Deserialize(stream); }
public Script Subscript(int offset, int length) { ContractsCommon.ValidOffsetLength(0, Atoms.Count, offset, length); var script = new Script(); script.Atoms.AddAll(this.Atoms.Skip(offset).Take(length)); return(script); }
public byte this[int index] { get { ContractsCommon.ValidIndex(0, _bytes.Length, index); return(_bytes[index]); } }
public static BitcoinSerializable DeserializeFromStream <T>(Stream stream) where T : BitcoinSerializable, new() { ContractsCommon.NotNull(stream, "stream"); var ooze = new T(); ooze.Deserialize(stream); return(ooze); }
protected override byte[] BuildBitcoinHashByteArray() { ContractsCommon.ResultIsNonNull <byte[]>(); var ms = new MemoryStream(); this.SerializeHeader(ms); return(ms.ToArray()); }
public void SerializeToBuffer(byte[] buffer, int offset) { ContractsCommon.NotNull(buffer, "buffer"); ContractsCommon.ValidOffsetLength(0, buffer.Length, offset, this.SerializedByteSize, "offset", "offset"); var stream = new MemoryStream(buffer, offset, buffer.Length - offset); this.Serialize(stream); }
public Script Subscript(int offset) { ContractsCommon.ValidOffset(0, Atoms.Count, offset); var script = new Script(); script.Atoms.AddAll(this.Atoms.Skip(offset)); return(script); }