Example #1
0
        public async Task CreateTransaction()
        {
            var chainTag = await _vechainClient.GetChainTag();

            var blockref = "0x001a7d4448f0948b"; // await _vechainClient.GetLatestBlockRef();


            var trans = RawTransaction.CreateUnsigned(chainTag, blockref, new[]
            {
                new RawClause("0xd3ae78222beadb038203be21ed5ce7c9b1bff602", "1", "", false)
            }, "12345678", 720, 0, 21000, "");

            var rlpTransaction = new RlpTransaction(trans).AsRlpValues();


            var asHexString = RlpEncoder.Encode(rlpTransaction);

            var rawTransaction = asHexString.ByteArrayToString(StringType.Hex | StringType.ZeroLowerX);

            // 0x44C3e1Ce754129Eb74522E3CA5695B7Cfa6d2B19
            var privateKey = new BigInteger("0xdce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65".HexStringToByteArray());
            var publicKey  = ECDSASign.PublicKeyFromPrivate(privateKey);


            var customKey = new ECKeyPair(privateKey, publicKey);

            var result = trans.Sign(customKey).CalculateTxId(new Address(customKey.GetHexAddress())).Transfer(_vechainClient);
        }
Example #2
0
        public ECKeyPair(BigInteger privateKey, BigInteger publicKey, bool check = false)
        {
            PrivateKey = privateKey;

            PublicKey = publicKey;

            if (check && !Equals(publicKey, ECDSASign.PublicKeyFromPrivate(privateKey)))
            {
                throw new InvalidKeyException("The public key does not match the private key.");
            }
        }
Example #3
0
        public ECKeyPair(BigInteger privateKey)
        {
            PrivateKey = privateKey;

            PublicKey = ECDSASign.PublicKeyFromPrivate(privateKey);
        }
Example #4
0
 public static ECKeyPair Create(BigInteger privateKey)
 {
     return(new ECKeyPair(privateKey, ECDSASign.PublicKeyFromPrivate(privateKey)));
 }