Exemple #1
0
        /// <summary>
        /// Promotes the transaction by creating a new zero sum transaction and linking to it as the trunk.
        /// It will get a tip to for the branch.
        /// </summary>
        /// <param name="transactionHash">The has of the transaction to promote</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public async Task <APIResult <TransactionItem> > PromoteTransaction(string transactionHash, CancellationToken cancellationToken)
        {
            var tipsTask = this.IriApi.GetTransactionsToApprove(this.Depth);

            var transaction = new TransactionItem(new string('9', 81), 0, "BEEFROG9PROMOTE");

            transaction.TrunkTransaction = transactionHash;

            var tips = await tipsTask;

            if (!tips.Successful)
            {
                return(tips.RePackage <TransactionItem>(r => null));
            }

            transaction.BranchTransaction = tips.Result.TrunkTransaction;
            transaction.FinalizeBundleHash();
            var trytes = new string[] { };

            var trytesToSend = (await NonceSeeker
                                .SearchNonce(new string[] { transaction.ToTransactionTrytes() }, transactionHash, tips.Result.TrunkTransaction, cancellationToken))
                               .Single();

            await IriApi.BroadcastTransactions(trytesToSend);

            await IriApi.StoreTransactions(trytesToSend);

            return(new APIResult <TransactionItem>(new TransactionItem(trytesToSend)));
        }
        public void FromTrytes_Bundle_ValidateCorrectly()
        {
            var trytes = "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999PB9999999999999999999999999NLMUSYD99999999999999999999RFIKCEZSNAPU9YE9AGSEJGDDDHLYBQYCYABLQBYIRYCYBLJOOBKDLKYRJXYEWHCXVNCVYCGVCHZKNHXDARWPUKHFMLUZIJOJQEERBATERWDDYIRDW9ZONGRPLRRHCDHHQXNUOTGAOXQOQHS9CUGSVJTZOCF9SZ9999FABABXCQBZYPMQV9LXKQKVHAPMMLMITNOEEIMTGM9ABYCROVWTXLGTFXMFABTRZ9HXVCUATHXQAE99999PB9999999999999999999999999WGHEDR9JE999999999L99999999FOXFFRCQBNXNBWDEORRLQCITSEZ";
            var tran   = new TransactionItem(trytes);

            Assert.AreEqual("RFIKCEZSNAPU9YE9AGSEJGDDDHLYBQYCYABLQBYIRYCYBLJOOBKDLKYRJXYEWHCXVNCVYCGVCHZKNHXDA", tran.Bundle);


            var success = ValidBundle_SingleItem(trytes);

            var bundle    = new TransactionItem[] { tran };
            var response  = bundle.FinalizeBundleHash(new Kerl());
            var response2 = bundle.FinalizeBundleHash(new Kerl());

            Assert.AreEqual(response, response2);
            Assert.AreEqual("RFIKCEZSNAPU9YE9AGSEJGDDDHLYBQYCYABLQBYIRYCYBLJOOBKDLKYRJXYEWHCXVNCVYCGVCHZKNHXDA", response);
            Assert.AreEqual("RFIKCEZSNAPU9YE9AGSEJGDDDHLYBQYCYABLQBYIRYCYBLJOOBKDLKYRJXYEWHCXVNCVYCGVCHZKNHXDA", tran.Bundle);

            Assert.IsTrue(ValidBundle_SingleItem(tran.ToTransactionTrytes()));
        }