public static SignedTransactionBase CreateTransaction(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 = CfxECKey.GetChainFromVChain(vBigInteger); return(new TransactionChainId(nonce.ToBytesForRLPEncoding(), gasPrice.ToBytesForRLPEncoding(), gas.ToBytesForRLPEncoding(), to.HexToByteArray(), amount.ToBytesForRLPEncoding(), data.HexToByteArray(), chainId.ToBytesForRLPEncoding(), rBytes, sBytes, vBytes)); } else { return(new Transaction(nonce.ToBytesForRLPEncoding(), gasPrice.ToBytesForRLPEncoding(), gas.ToBytesForRLPEncoding(), to.HexToByteArray(), amount.ToBytesForRLPEncoding(), data.HexToByteArray(), rBytes, sBytes, vBytes[0])); } }
private BigInteger GetChainFromVChain() { return(CfxECKey.GetChainFromVChain(Signature.V.ToBigIntegerFromRLPDecoded())); }