private static void Promote(IotaApi api, string hash) { while (true) { Console.WriteLine("Waiting 60 seconds before promoting. Press any key to stop."); for (int i = 0; i < 240; i++) { if (i % 4 == 0) { Console.Write("."); } Thread.Sleep(250); if (Console.KeyAvailable) { Console.ReadKey(); return; } } var states = api.IriApi.GetInclusionStates(new[] { hash }).Result; if (states.Successful && states.Result.Any() && states.Result[0]) { Console.WriteLine("Your transaction has been confirmed!"); return; } var consistencyResponse = api.IriApi.CheckConsistency(hash, hash).Result; if (consistencyResponse.Successful) { if (consistencyResponse.Result == false) { Console.WriteLine("Your transaction needs to be re-attached!"); var response = api.GetTransactionItems(hash).Result; if (response.Successful) { Console.WriteLine("Re-attaching!"); var reattachResponse = api.AttachTransactions(response.Result, CancellationToken.None).Result; if (reattachResponse.Successful) { hash = reattachResponse.Result[0].Hash; Console.WriteLine("Success! Your new hash is:" + hash); continue; } else { Console.WriteLine($"Re-attach Failed! Reason: {reattachResponse.ErrorMessage} Exception:{reattachResponse.ExceptionInfo}"); } } else { Console.WriteLine($"Get Transaction Failed! Reason: {response.ErrorMessage} Exception:{response.ExceptionInfo}"); } } Console.WriteLine(" Promoting."); var promoteResponse = api.PromoteTransaction(hash, CancellationToken.None).Result; if (promoteResponse.Successful) { Console.WriteLine(promoteResponse.Result.Hash); } else { Console.WriteLine($"Promotion failed!! Reason: {promoteResponse.ErrorMessage} Exception:{promoteResponse.ExceptionInfo}"); } } else { Console.WriteLine($"CheckConsistency failed! Reason: {consistencyResponse.ErrorMessage} Exception:{consistencyResponse.ExceptionInfo}"); } } }