public static Signature DecodeSignature(Rlp.DecoderContext context) { Span <byte> vBytes = context.DecodeByteArraySpan(); Span <byte> rBytes = context.DecodeByteArraySpan(); Span <byte> sBytes = context.DecodeByteArraySpan(); if (vBytes[0] == 0 || rBytes[0] == 0 || sBytes[0] == 0) { throw new RlpException("VRS starting with 0"); } if (rBytes.Length > 32 || sBytes.Length > 32) { throw new RlpException("R and S lengths expected to be less or equal 32"); } int v = vBytes.ToInt32(); if (rBytes.SequenceEqual(Bytes.Zero32) && sBytes.SequenceEqual(Bytes.Zero32)) { throw new RlpException("Both 'r' and 's' are zero when decoding a transaction."); } Signature signature = new Signature(rBytes, sBytes, v); return(signature); }
public NetworkNode Decode(Rlp.DecoderContext context, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { context.ReadSequenceLength(); var publicKey = new PublicKey(context.DecodeByteArray()); var ip = System.Text.Encoding.UTF8.GetString(context.DecodeByteArray()); var port = context.DecodeByteArraySpan().ToInt32(); System.Text.Encoding.UTF8.GetString(context.DecodeByteArray()); var reputation = context.DecodeByteArray().ToInt64(); var networkNode = new NetworkNode(publicKey, ip != string.Empty ? ip : null, port, reputation); return(networkNode); }
public ParityLikeTxTrace Decode(Rlp.DecoderContext context, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { ParityLikeTxTrace trace = new ParityLikeTxTrace(); context.ReadSequenceLength(); trace.BlockHash = context.DecodeKeccak(); trace.BlockNumber = (long)context.DecodeUInt256(); trace.TransactionHash = context.DecodeKeccak(); Span <byte> txPosBytes = context.DecodeByteArraySpan(); trace.TransactionPosition = txPosBytes.Length == 0 ? (int?)null : txPosBytes.ToInt32(); context.ReadSequenceLength(); trace.Action = DecodeAction(context); trace.StateChanges = DecodeStateDiff(context); // stateChanges return(trace); }