Esempio n. 1
0
        /// <summary>
        /// Creates a vote transaction.
        /// </summary>
        ///
        /// <param name="votes">The votes.</param>
        ///
        /// <param name="passphrase">The account's first passphrase.</param>
        ///
        /// <param name="secondPassphrase">The account's second passphrase.</param>
        ///
        /// <returns>Returns an instance of the <see cref="TransactionApi"/> type.</returns>
        ///
        public TransactionApi CreateVote(List <string> votes, string passphrase, string secondPassphrase = null)
        {
            try
            {
                var tx = new TransactionApi(3, 0, _networkApi.NetworkSettings.Fee.Vote);
                tx.asset.Add("votes", votes);
                tx.Timestamp   = Slot.GetTime();
                tx.RecipientId = Crypto.GetAddress(Crypto.GetKeys(passphrase), _networkApi.NetworkSettings.BytePrefix);
                tx.Sign(passphrase);
                tx.StrBytes = Encoders.Hex.EncodeData(tx.ToBytes());
                if (secondPassphrase != null)
                {
                    tx.SecondSign(secondPassphrase);
                }

                tx.Id = Crypto.GetId(tx);
                _logger.Info(string.Format("Creating vote transaction <<{0}>>", JsonConvert.SerializeObject(tx)));

                return(tx);
            }
            catch (Exception e)
            {
                _logger.Error(e.ToString());
                throw e;
            }
        }
Esempio n. 2
0
        public static TransactionApi CreateTransaction(string recipientId, long satoshiAmount, string vendorField,
                                                       string passphrase, string secondPassphrase = null)
        {
            var tx = new TransactionApi(0, recipientId, satoshiAmount, ArkNetApi.Instance.NetworkSettings.Fee.Send, vendorField);

            tx.Timestamp = Slot.GetTime();
            tx.Sign(passphrase);
            tx.StrBytes = Encoders.Hex.EncodeData(tx.ToBytes());
            if (secondPassphrase != null)
            {
                tx.SecondSign(secondPassphrase);
            }

            tx.Id = Crypto.GetId(tx);
            return(tx);
        }
Esempio n. 3
0
        public static TransactionApi CreateVote(List <string> votes, string passphrase, string secondPassphrase = null)
        {
            var tx = new TransactionApi(3, 0, ArkNetApi.Instance.NetworkSettings.Fee.Vote);

            tx.asset.Add("votes", votes);
            tx.Timestamp   = Slot.GetTime();
            tx.RecipientId = Crypto.GetAddress(Crypto.GetKeys(passphrase), ArkNetApi.Instance.NetworkSettings.BytePrefix);
            tx.Sign(passphrase);
            tx.StrBytes = Encoders.Hex.EncodeData(tx.ToBytes());
            if (secondPassphrase != null)
            {
                tx.SecondSign(secondPassphrase);
            }

            tx.Id = Crypto.GetId(tx);

            return(tx);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a transaction.
        /// </summary>
        ///
        /// <param name="recipientId">The address of the transaction's recipient.</param>
        ///
        /// <param name="satoshiAmount">The amount in satoshi of the transaction.</param>
        ///
        /// <param name="vendorField">The vendorfield of the transaction.</param>
        ///
        /// <param name="passphrase">The account first's passphrase.</param>
        ///
        /// <param name="secondPassphrase">The account's second passphrase.</param>
        ///
        /// <returns>Returns an instance of the <see cref="TransactionApi"/> type.</returns>
        ///
        public TransactionApi CreateTransaction(string recipientId, long satoshiAmount, string vendorField,
                                                string passphrase, string secondPassphrase = null)
        {
            try
            {
                var tx = new TransactionApi(0, recipientId, satoshiAmount, _networkApi.NetworkSettings.Fee.Send, vendorField);
                tx.Timestamp = Slot.GetTime();
                tx.Sign(passphrase);
                tx.StrBytes = Encoders.Hex.EncodeData(tx.ToBytes());
                if (secondPassphrase != null)
                {
                    tx.SecondSign(secondPassphrase);
                }

                tx.Id = Crypto.GetId(tx);
                _logger.Info(string.Format("Creating transaction <<{0}>>", JsonConvert.SerializeObject(tx)));
                return(tx);
            }
            catch (Exception e)
            {
                _logger.Error(e.ToString());
                throw e;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Get the bytes of a transaction.
 /// </summary>
 /// <param name="t">
 /// The <see cref="TransactionApi"/> whose bytes you want to get.
 /// </param>
 /// <param name="skipSignature">
 /// <see cref="bool"/> Skip first signature.
 /// Default = true.
 /// </param>
 /// <param name="skipSecondSignature">
 /// <see cref="bool"/> Skip second signature.
 /// </param>
 /// <returns>
 /// The <see cref="byte[]"/>.
 /// </returns>
 public static byte[] GetBytes(TransactionApi t, bool skipSignature = true, bool skipSecondSignature = true)
 {
     return(t.ToBytes(skipSignature, skipSecondSignature));
 }