Exemplo n.º 1
0
        public Response <IOperation[]> Read(string hex)
        {
            Response <IOperation[]> resp = new Response <IOperation[]>();

            if (!Base16.IsValid(hex))
            {
                resp.Errors.Add("Invalid base-16 string.");
            }
            else
            {
                byte[]     data   = Base16.ToByteArray(hex);
                int        offset = 0;
                CompactInt len    = new CompactInt(data.Length);
                data = len.ToByteArray().ConcatFast(data);

                Script scr = new Helper();
                if (scr.TryDeserialize(data, ref offset, out string error))
                {
                    resp.Result = scr.OperationList;
                }
                else
                {
                    resp.Errors.Add(error);
                }
            }

            return(resp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts this instance into its byte array representation.
        /// </summary>
        /// <exception cref="ArgumentNullException"/>
        /// <returns>An array of bytes.</returns>
        public virtual byte[] Serialize()
        {
            byte[] result = ToByteArray();

            CompactInt lengthOrCount = new CompactInt(IsWitness ? OperationList.Length : result.Length);

            return(lengthOrCount.ToByteArray().ConcatFast(result));
        }
Exemplo n.º 3
0
        private void SetFields()
        {
            CompactInt temp   = new CompactInt(10000 /*coin.ScriptSigMaxLength*/);
            int        opSize = new Outpoint().Size;

            MinSize = opSize + 1 + 0 + sizeof(uint);
            MaxSize = opSize + temp.ToByteArray().Length + 10000 + sizeof(uint);
        }