/// <summary>
        /// Return encoded representation of the transaction with a prefix suitable for signing
        /// </summary>
        /// <returns>bytes</returns>
        private byte[] BytesToSign()
        {
            byte[] encodedTx       = Encoder.EncodeToMsgPack(this);
            byte[] prefixEncodedTx = JavaHelper <byte> .ArrayCopyOf(TG_PREFIX, TG_PREFIX.Length + encodedTx.Length);

            JavaHelper <byte> .SyatemArrayCopy(encodedTx, 0, prefixEncodedTx, TG_PREFIX.Length, encodedTx.Length);

            return(prefixEncodedTx);
        }
        public override void NextBytes(byte[] bytes)
        {
            if (this.index >= this.fixedValue.Length)
            {
                // no more data to copy
                return;
            }
            int len = bytes.Length;

            if (len > this.fixedValue.Length - this.index)
            {
                len = this.fixedValue.Length - this.index;
            }
            JavaHelper <byte> .SyatemArrayCopy(this.fixedValue, this.index, bytes, 0, len);

            this.index += bytes.Length;
        }
Esempio n. 3
0
        public static ByteConstBlock ReadByteConstBlock(byte[] program, int pc)
        {
            List <byte[]> results = new List <byte[]>();
            int           size    = 1;
            VarintResult  result  = GetUVarint(program, pc + size);

            if (result.length <= 0)
            {
                throw new ArgumentException(
                          string.Format("could not decode byte[] const block at pc=%d", pc)
                          );
            }
            size += result.length;
            int numInts = result.value;

            for (int i = 0; i < numInts; i++)
            {
                if (pc + size >= program.Length)
                {
                    throw new ArgumentException("byte[] const block exceeds program length");
                }
                result = GetUVarint(program, pc + size);
                if (result.length <= 0)
                {
                    throw new ArgumentException(
                              string.Format("could not decode byte[] const[%d] block at pc=%d", i, pc + size)
                              );
                }
                size += result.length;
                if (pc + size >= program.Length)
                {
                    throw new ArgumentException("byte[] const block exceeds program length");
                }
                byte[] buff = new byte[result.value];
                JavaHelper <byte> .SyatemArrayCopy(program, pc + size, buff, 0, result.value);

                results.Add(buff);
                size += result.value;
            }
            return(new ByteConstBlock(size, results));
        }