Example #1
0
        [TestMethod] // very long execution
        public void shouldGetTransactionsToApprove()
        {
            GetTransactionsToApproveResponse res = iotaApi.GetTransactionsToApprove(27);

            Assert.IsNotNull(res.TrunkTransaction);
            Assert.IsNotNull(res.BranchTransaction);
        }
Example #2
0
        /// <summary>
        /// Sends the trytes.
        /// </summary>
        /// <param name="trytes">The trytes.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="minWeightMagnitude">Optional (default 18). The minimum weight magnitude.</param>
        /// <returns>an Array of Transactions</returns>
        public Transaction[] SendTrytes(string[] trytes, int depth, int minWeightMagnitude = 18)
        {
            GetTransactionsToApproveResponse transactionsToApproveResponse = GetTransactionsToApprove(depth);

            AttachToTangleResponse attachToTangleResponse =
                AttachToTangle(transactionsToApproveResponse.TrunkTransaction,
                               transactionsToApproveResponse.BranchTransaction, trytes, minWeightMagnitude);

            try
            {
                BroadcastAndStore(attachToTangleResponse.Trytes);
            }
            catch (System.Exception)
            {
                return(new Transaction[0]);
            }

            List <Transaction> trx = new List <Transaction>();

            foreach (string tx in attachToTangleResponse.Trytes)
            {
                trx.Add(new Transaction(tx, curl));
            }
            return(trx.ToArray());
        }