Exemple #1
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;
            }
        }