Пример #1
0
        private ReplayBundleResponse ReplayBundle(Bundle bundle, int depth, int minWeightMagnitude, string reference,
                                                  Stopwatch stopWatch)
        {
            List <string> bundleTrytes = new List <string>();

            foreach (var trx in bundle.Transactions)
            {
                bundleTrytes.Add(trx.ToTrytes());
            }

            bundleTrytes.Reverse();


            var trxs = SendTrytes(bundleTrytes.ToArray(), depth, minWeightMagnitude, reference);

            bool[] successful = new bool[trxs.Length];

            for (int i = 0; i < trxs.Length; i++)
            {
                var response = IotaClient.FindTransactionsByBundles(trxs[i].Bundle);

                successful[i] = response.Hashes.Count != 0;
            }

            stopWatch.Stop();
            return(new ReplayBundleResponse(new Bundle(trxs.ToList(), trxs.Length), successful,
                                            stopWatch.ElapsedMilliseconds));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="seed"></param>
        /// <param name="security"></param>
        /// <param name="depth"></param>
        /// <param name="minWeightMagnitude"></param>
        /// <param name="transfers"></param>
        /// <param name="inputs"></param>
        /// <param name="remainderAddress"></param>
        /// <param name="validateInputs"></param>
        /// <param name="validateInputAddresses"></param>
        /// <param name="tips"></param>
        /// <returns></returns>
        public SendTransferResponse SendTransfer(
            string seed, int security,
            int depth, int minWeightMagnitude,
            Transfer[] transfers, Input[] inputs,
            string remainderAddress,
            bool validateInputs, bool validateInputAddresses,
            Transaction[] tips)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            var trytes = PrepareTransfers(seed, security, transfers,
                                          remainderAddress, inputs, tips, validateInputs);

            if (validateInputAddresses)
            {
                ValidateTransfersAddresses(seed, security, trytes);
            }

            string reference = tips != null && tips.Length > 0 ? tips[0].CurlHash() : null;

            var transactions = SendTrytes(trytes.ToArray(), depth, minWeightMagnitude, reference);

            var successful = new bool[transactions.Length];

            for (var i = 0; i < transactions.Length; i++)
            {
                var response = IotaClient.FindTransactionsByBundles(transactions[i].Bundle);

                successful[i] = response.Hashes.Count != 0;
            }

            stopwatch.Stop();

            return(new SendTransferResponse(transactions, successful, stopwatch.ElapsedMilliseconds));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bundles"></param>
        /// <returns></returns>
        public List <Transaction> FindTransactionObjectsByBundle(params string[] bundles)
        {
            var ftr = IotaClient.FindTransactionsByBundles(bundles);

            if (ftr?.Hashes == null)
            {
                return(new List <Transaction>());
            }

            // get the transaction objects of the transactions
            return(FindTransactionObjectsByHashes(ftr.Hashes.ToArray()));
        }