Ejemplo n.º 1
0
        public static byte[] EncodeMultTransfer(byte[] origin, byte[] dest, List <byte[]> from, List <byte[]> signatures, byte[] to, byte[] value, List <byte[]> pubkeyHashList)
        {
            int length = RLP.EncodeElement(origin).Length + RLP.EncodeElement(dest).Length + RLPUtils.EncodeList(from.ToArray()).Length + RLPUtils.EncodeList(signatures.ToArray()).Length + RLP.EncodeElement(to).Length + RLP.EncodeElement(value).Length + RLPUtils.EncodeList(pubkeyHashList.ToArray()).Length;

            if (length < 56)
            {
                return(Utils.Combine(new byte[] { (byte)(0xc0 + length) }, RLP.EncodeElement(origin), RLP.EncodeElement(dest), RLP.EncodeList(EncodeElementsBytes(from.ToArray())), RLP.EncodeList(EncodeElementsBytes(signatures.ToArray())), RLP.EncodeElement(to), RLP.EncodeElement(value), RLP.EncodeList(EncodeElementsBytes(pubkeyHashList.ToArray()))));
            }
            else
            {
                Tuple <byte, byte[]> tuple = NumericsUtils.getLengthByte(length);
                return(Utils.Combine(new byte[] { (byte)(0xf7 + tuple.Item1) }, tuple.Item2, RLP.EncodeElement(origin), RLP.EncodeElement(dest), RLP.EncodeList(EncodeElementsBytes(from.ToArray())), RLP.EncodeList(EncodeElementsBytes(signatures.ToArray())), RLP.EncodeElement(to), RLP.EncodeElement(value), RLP.EncodeList(EncodeElementsBytes(pubkeyHashList.ToArray()))));
            }
        }
Ejemplo n.º 2
0
        public static byte[] EncodeMultiple(byte[] a, byte[] b, byte[] c, List <byte[]> d, List <byte[]> e, List <byte[]> f)
        {
            int length = RLP.EncodeElement(a).Length + RLP.EncodeElement(b).Length + RLP.EncodeElement(c).Length + RLPUtils.EncodeList(d.ToArray()).Length + RLPUtils.EncodeList(e.ToArray()).Length + RLPUtils.EncodeList(f.ToArray()).Length;

            if (length < 56)
            {
                return(Utils.Combine(new byte[] { (byte)(0xc0 + length) }, RLP.EncodeElement(a), RLP.EncodeElement(b), RLP.EncodeElement(c), RLP.EncodeList(EncodeElementsBytes(d.ToArray())), RLP.EncodeList(EncodeElementsBytes(e.ToArray())), RLP.EncodeList(EncodeElementsBytes(f.ToArray()))));
            }
            else
            {
                Tuple <byte, byte[]> tuple = NumericsUtils.getLengthByte(length);
                return(Utils.Combine(new byte[] { (byte)(0xf7 + tuple.Item1) }, tuple.Item2, RLP.EncodeElement(a), RLP.EncodeElement(b), RLP.EncodeElement(c), RLP.EncodeList(EncodeElementsBytes(d.ToArray())), RLP.EncodeList(EncodeElementsBytes(e.ToArray())), RLP.EncodeList(EncodeElementsBytes(f.ToArray()))));
            }
        }
Ejemplo n.º 3
0
        public static byte[] EncodeRateHeightLockWithdraw(byte[] depositHash, byte[] to)
        {
            int length = RLP.EncodeElement(depositHash).Length + RLP.EncodeElement(to).Length;

            if (length < 56)
            {
                return(Utils.Combine(new byte[] { (byte)(0xc0 + length) }, RLP.EncodeElement(depositHash), RLP.EncodeElement(to)));
            }
            else
            {
                Tuple <byte, byte[]> tuple = NumericsUtils.getLengthByte(length);
                return(Utils.Combine(new byte[] { (byte)(0xf7 + tuple.Item1) }, tuple.Item2, RLP.EncodeElement(depositHash), RLP.EncodeElement(to)));
            }
        }
Ejemplo n.º 4
0
 public static byte[] EncodeList(params byte[][] bytes)
 {
     return(RLP.EncodeList(EncodeElementsBytes(bytes)));
 }
Ejemplo n.º 5
0
        public static byte[] EncodeRateHeightLock(byte[] assetHash, long oneTimeDepositMultiple, int withDrawPeriodHeight, string withDrawRate, byte[] dest, Dictionary <byte[], Extract> stateMap)
        {
            List <byte[]> list   = EncodeStateMap(stateMap);
            int           length = RLP.EncodeElement(assetHash).Length + RLP.EncodeElement(oneTimeDepositMultiple.ToBytesForRLPEncoding()).Length
                                   + RLP.EncodeElement(withDrawPeriodHeight.ToBytesForRLPEncoding()).Length + RLP.EncodeElement(withDrawRate.ToBytesForRLPEncoding()).Length
                                   + RLP.EncodeElement(dest).Length + RLP.EncodeList(list.ToArray()).Length;

            if (length < 56)
            {
                return(Utils.Combine(new byte[] { (byte)(0xc0 + length) }, RLP.EncodeElement(assetHash), RLP.EncodeElement(oneTimeDepositMultiple.ToBytesForRLPEncoding())
                                     , RLP.EncodeElement(withDrawPeriodHeight.ToBytesForRLPEncoding()), RLP.EncodeElement(withDrawRate.ToBytesForRLPEncoding())
                                     , RLP.EncodeElement(dest), RLP.EncodeList(list.ToArray())));
            }
            else
            {
                Tuple <byte, byte[]> tuple = NumericsUtils.getLengthByte(length);
                return(Utils.Combine(new byte[] { (byte)(0xf7 + tuple.Item1) }, tuple.Item2, RLP.EncodeElement(assetHash), RLP.EncodeElement(oneTimeDepositMultiple.ToBytesForRLPEncoding())
                                     , RLP.EncodeElement(withDrawPeriodHeight.ToBytesForRLPEncoding()), RLP.EncodeElement(withDrawRate.ToBytesForRLPEncoding())
                                     , RLP.EncodeElement(dest), RLP.EncodeList(list.ToArray())));
            }
        }