public static RawTransaction Decode(string hexRawTransaction) { if (!StringUtils.IsHex(hexRawTransaction)) { return(null); } var rawTxBytes = ByteUtils.ToByteArray(hexRawTransaction); var list = RlpDecoder.Decode(rawTxBytes); if (list == null) { return(null); } var rlpContent = list.Values; //It should only has one element. if (rlpContent.Count != 1) { return(null); } var rawTransaction = new RawTransaction(); var listValues = ((RlpList)rlpContent[0]).Values; for (int index = 0; index < listValues.Count; index++) { FillTransaction(rawTransaction, listValues, index); } return(rawTransaction); }
public void DecodeStaticString() { var input = "f902d6819a8702288058b9af928202d0f90273e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f8000080e094d3ef28df6b553ed2fc47259e8134319cb1121a2a89364200111c48f800008001830616988088ff9198c817655decc0b841bd61e198f126adddb169eebf5cd3da25ae3a3f07102e574bcd1368440d1e307c4c47884364e2abc66ef6940c4953758dd1c57f8255025639702104ce83e9a3b501"; var rlpList = RlpDecoder.Decode(input.HexStringToByteArray()); var nethereumRLP = RLP.Decode(input.HexStringToByteArray()); Assert.True(RlpCompare(rlpList, nethereumRLP)); }
public void DecoderTest() { string hexRaw = "0xf83d81c7860881eec535498202d0e1e094000000002beadb038203be21ed5ce7c9b1bff60289056bc75e2d63100000808082520880884773cc184328eb3ec0"; var rlpList = RlpDecoder.Decode(hexRaw.HexStringToByteArray()); // The list should only have 1 element Assert.Single(rlpList); byte[] encodedinner = RlpEncoder.Encode(rlpList[0]); string hexEncodedinner = encodedinner.ByteArrayToString(StringType.Hex | StringType.ZeroLowerX); Assert.Equal(hexRaw, hexEncodedinner); }