public static ISignedTransaction CreateLegacyTransaction(string to, BigInteger gas, BigInteger gasPrice, BigInteger amount, string data, BigInteger nonce, string r, string s, string v) { var rBytes = r.HexToByteArray(); var sBytes = s.HexToByteArray(); var vBytes = v.HexToByteArray(); var signature = EthECDSASignatureFactory.FromComponents(rBytes, sBytes, vBytes); if (signature.IsVSignedForChain()) { var vBigInteger = vBytes.ToBigIntegerFromRLPDecoded(); var chainId = EthECKey.GetChainFromVChain(vBigInteger); return(new LegacyTransactionChainId(nonce.ToBytesForRLPEncoding(), gasPrice.ToBytesForRLPEncoding(), gas.ToBytesForRLPEncoding(), to.HexToByteArray(), amount.ToBytesForRLPEncoding(), data.HexToByteArray(), chainId.ToBytesForRLPEncoding(), rBytes, sBytes, vBytes)); } else { return(new LegacyTransaction(nonce.ToBytesForRLPEncoding(), gasPrice.ToBytesForRLPEncoding(), gas.ToBytesForRLPEncoding(), to.HexToByteArray(), amount.ToBytesForRLPEncoding(), data.HexToByteArray(), rBytes, sBytes, vBytes[0])); } }
private BigInteger GetChainFromVChain() { return(EthECKey.GetChainFromVChain(Signature.V.ToBigIntegerFromRLPDecoded())); }