public static RateHeightLock DecodeRateHeightLock(byte[] encodeResult) { RateHeightLock rateHeightLock = new RateHeightLock(); var collections = RLP.Decode(encodeResult) as RLPCollection; rateHeightLock.assetHash = collections[0].RLPData; rateHeightLock.oneTimeDepositMultiple = collections[1].RLPData.ToLongFromRLPDecoded(); rateHeightLock.withDrawPeriodHeight = collections[2].RLPData.ToIntFromRLPDecoded(); rateHeightLock.withDrawRate = collections[3].RLPData.ToStringFromRLPDecoded(); rateHeightLock.dest = collections[4].RLPData; List <byte[]> list = (collections[5] as RLPCollection).Select(x => x.RLPData).ToList(); Dictionary <byte[], Extract> dictionary = new Dictionary <byte[], Extract>(); var cos = (RLP.Decode(list[1]) as RLPCollection).Select(x => x.RLPData).ToList(); Extract extract1 = new Extract(); extract1.extractHeight = cos[0].ToLongFromRLPDecoded(); extract1.surplus = cos[1].ToIntFromRLPDecoded(); dictionary.Add(list[0], extract1); var cos2 = (RLP.Decode(list[3]) as RLPCollection).Select(x => x.RLPData).ToList(); Extract extract2 = new Extract(); extract1.extractHeight = cos2[0].ToLongFromRLPDecoded(); extract1.surplus = cos2[1].ToIntFromRLPDecoded(); dictionary.Add(list[2], extract2); rateHeightLock.stateMap = dictionary; return(rateHeightLock); }
public static RateHeightLockWithdraw DecodeRateHeightLockWithdraw(byte[] encodeResult) { RateHeightLockWithdraw rateHeightLockWithdraw = new RateHeightLockWithdraw(); var collections = RLP.Decode(encodeResult) as RLPCollection; rateHeightLockWithdraw.depositHash = collections[0].RLPData; rateHeightLockWithdraw.to = collections[1].RLPData; return(rateHeightLockWithdraw); }
public static Multiple DecodeMultiple(byte[] encodeResult) { Multiple multiple = new Multiple(); var collections = RLP.Decode(encodeResult) as RLPCollection; multiple.assetHash = collections[0].RLPData; multiple.max = collections[1].RLPData.ToIntFromRLPDecoded(); multiple.min = collections[2].RLPData.ToIntFromRLPDecoded(); multiple.pubList = (collections[3] as RLPCollection).Select(x => x.RLPData).ToList(); multiple.signatures = (collections[4] as RLPCollection).Select(x => x.RLPData).ToList(); multiple.pubkeyHashList = (collections[5] as RLPCollection).Select(x => x.RLPData).ToList(); return(multiple); }
public static Asset DecodeAsset(byte[] encodeResult) { Asset asset = new Asset(); var collections = RLP.Decode(encodeResult) as RLPCollection; asset.code = collections[0].RLPData.ToStringFromRLPDecoded(); asset.offering = collections[1].RLPData.ToLongFromRLPDecoded(); asset.totalAmount = collections[2].RLPData.ToLongFromRLPDecoded(); asset.createUser = collections[3].RLPData; asset.owner = collections[4].RLPData; asset.allowIncrease = collections[5].RLPData.ToIntFromRLPDecoded(); asset.info = collections[6].RLPData; return(asset); }
public static MultTransfer DecodeMultTransfer(byte[] encodeResult) { MultTransfer multTransfer = new MultTransfer(); var collections = RLP.Decode(encodeResult) as RLPCollection; multTransfer.origin = collections[0].RLPData.ToIntFromRLPDecoded(); multTransfer.dest = collections[1].RLPData.ToIntFromRLPDecoded(); multTransfer.from = (collections[2] as RLPCollection).Select(x => x.RLPData).ToList(); multTransfer.signatures = (collections[3] as RLPCollection).Select(x => x.RLPData).ToList(); multTransfer.to = collections[4].RLPData; multTransfer.value = collections[5].RLPData.ToIntFromRLPDecoded(); multTransfer.pubkeyHashList = (collections[6] as RLPCollection).Select(x => x.RLPData).ToList(); return(multTransfer); }
public void TestRLPEncodeShortString() { List <byte[]> list = new List <byte[]>(); list.Add(new byte[] { 0x01, 0x02 }); list.Add(new byte[] { 0x01, 0x03 }); var encodeResult = RLPUtils.EncodeMultiple(new byte[] { 0x01, 0x02 }, new byte[] { 0x01, 0x02 }, new byte[] { 0x01, 0x02 }, list, new List <byte[]>(), list); var collections = RLP.Decode(encodeResult) as RLPCollection; Assert.Equal("0102", collections[0].RLPData.ToHex()); Assert.Equal("0102", collections[1].RLPData.ToHex()); Assert.Equal("0102", collections[2].RLPData.ToHex()); Assert.Equal(list, (collections[3] as RLPCollection).Select(x => x.RLPData).ToList()); Assert.Equal(new List <byte[]>(), (collections[4] as RLPCollection).Select(x => x.RLPData).ToList()); Assert.Equal(list, (collections[5] as RLPCollection).Select(x => x.RLPData).ToList()); }