public void From_Trytes_CorrectBundleHasCalculated() { var trytes = "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999PB9999999999999999999999999NLMUSYD99999999999999999999RFIKCEZSNAPU9YE9AGSEJGDDDHLYBQYCYABLQBYIRYCYBLJOOBKDLKYRJXYEWHCXVNCVYCGVCHZKNHXDARWPUKHFMLUZIJOJQEERBATERWDDYIRDW9ZONGRPLRRHCDHHQXNUOTGAOXQOQHS9CUGSVJTZOCF9SZ9999FABABXCQBZYPMQV9LXKQKVHAPMMLMITNOEEIMTGM9ABYCROVWTXLGTFXMFABTRZ9HXVCUATHXQAE99999PB9999999999999999999999999WGHEDR9JE999999999L99999999FOXFFRCQBNXNBWDEORRLQCITSEZ"; var tran = new TransactionItem(trytes); Assert.AreEqual("RFIKCEZSNAPU9YE9AGSEJGDDDHLYBQYCYABLQBYIRYCYBLJOOBKDLKYRJXYEWHCXVNCVYCGVCHZKNHXDA", tran.Bundle); 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); }
/// <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 TestPOW_doesNotCorruptBundleHash2() { var trytes = "SPAMSPAMSPAM999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999TF9MSIX99999999999999999999BVVKTYD99999999999999999999NLAVEPNFGLLJXER9VKTTBQSHTXZGBLNH9ILHB9TXH9YEGGETCQAWIYPKKWSAODFORD9TWJHPHLNYHWIQXMNLKSORAJWXRFTGAEGZVVXHIZBUFHQSFC9TRYMVGMFFSWDMFYLVUHEXYALANIKXOU9PLNGUHMQQDZ9999HDTF9BHXPQKGJNJFZ9WBJQWNBUPZBVCRQFZBMXSHVESWECTEQBUDYMELUMIW9LYHSFTBKBASDNZDA9999999MSIX99999999999999999999COZMOXBJE999999999L99999999EUBOPNIPRRCYKBKBJRXQPCHELMM"; var tran = new TransactionItem(trytes); Assert.AreEqual("NLAVEPNFGLLJXER9VKTTBQSHTXZGBLNH9ILHB9TXH9YEGGETCQAWIYPKKWSAODFORD9TWJHPHLNYHWIQX", tran.Bundle); var output = (new string[] { trytes }.DoPow(tran.TrunkTransaction, tran.BranchTransaction, 5, CancellationToken.None)).Result; Assert.IsTrue(ValidBundle_SingleItem(output[0])); var tran2 = new TransactionItem(output[0]); Assert.AreEqual(tran2.Bundle, tran.Bundle); var bundle = new TransactionItem[] { tran2 }; var response = bundle.FinalizeBundleHash(new Kerl()); Assert.AreEqual(response, "NLAVEPNFGLLJXER9VKTTBQSHTXZGBLNH9ILHB9TXH9YEGGETCQAWIYPKKWSAODFORD9TWJHPHLNYHWIQX"); }
static void Main(string[] args) { Console.WriteLine("Finding an IOTA node"); INodeFinder nodeFinder = new IotaDanceNodeFinder(); var node = nodeFinder.FindNodes().Result.First(); Console.WriteLine($"Creating transfer now. This may take a few seconds."); // We'll create out 2 transactions. var transaction1 = new TransactionItem("FAKEADDRESS9999999999999999999999999999999999999999999999999999999999999999999999", 0, "BEEFROG") { SignatureFragment = BeeFrog.Iota.Api.Utils.Converter.AsciiToTrytes("Message part 1") }; var transaction2 = new TransactionItem("FAKEADDRESS9999999999999999999999999999999999999999999999999999999999999999999999", 0, "BEEFROG") { SignatureFragment = BeeFrog.Iota.Api.Utils.Converter.AsciiToTrytes("Message part 2") }; // Create an array and bundle the transactions together. var trans = new TransactionItem[] { transaction1, transaction2 }; trans.FinalizeBundleHash(new Curl()); // Now we can send them. var api = new IotaApi(node.Url); var apiResult = api.AttachTransactions(trans, CancellationToken.None).Result; if (apiResult.Successful) { var transaction = apiResult.Result; Console.WriteLine($"Your transaction bundle is: {transaction[0].Bundle}"); } else { Console.WriteLine($"{apiResult.ErrorMessage} Exception: {apiResult.ExceptionInfo}"); } Console.WriteLine($"Press any key to close"); Console.ReadKey(); }