public async Task Gold(CommandContext ctx, [Description("This is your PUBLIC Address")] string publickey = "") { //Debug var username = ctx.Member.Username; var eyes = DiscordEmoji.FromName(ctx.Client, ":eyes:"); await ctx.Message.CreateReactionAsync(eyes).ConfigureAwait(false); var oldmessage = ctx.Message; Console.WriteLine("User: "******" requested NCG value against key: " + publickey); //debug end var ncg = new NCG(); string result = ncg.NCGGold(publickey); Console.WriteLine(result); var comms = new Communication(); if (result == null) { if (ncg.NCGGold("0xa49d64c31A2594e8Fb452238C9a03beFD1119963") == null) { await comms.SnapshotDown(ctx, oldmessage); } else { await comms.GenericError(ctx, oldmessage, username); } } else { await comms.NormalNCG(ctx, oldmessage, username, result); } }
public async Task SetProfileKey(CommandContext ctx, [Description("This is what you want to call your profile")] string alias, [Description("This is your PUBLIC Address")] string publickey) { Console.WriteLine("SetProfileReceived"); ulong userid = ctx.Member.Id; var username = ctx.Member.DisplayName; var eyes = DiscordEmoji.FromName(ctx.Client, ":eyes:"); var comms = new Communication(); var setup = new Setup(); var oldmessage = ctx.Message; bool state = setup.SetProfileNew(publickey, alias, userid); await ctx.Message.CreateReactionAsync(eyes).ConfigureAwait(false); if (state) { await comms.SetProfile(ctx, oldmessage, username, alias, publickey); } else { var ncg = new NCG(); if (ncg.NCGGold("0xa49d64c31A2594e8Fb452238C9a03beFD1119963") == null) { await comms.SnapshotDown(ctx, oldmessage); } else { await comms.GenericError(ctx, oldmessage, username); } } }
public static async Task PaymentProcessor(DiscordClient client) { var db = new SqliteDataAccess(); var comms = new Communication(); while (true) { //every 2 minutes we take 1 payment to process. var sw1 = Stopwatch.StartNew(); for (int ix = 0; ix < 120; ++ix) { Thread.Sleep(1000); } sw1.Stop(); Console.WriteLine("Sleep: {0}", sw1.ElapsedMilliseconds); PaymentModel paymentprofile = await db.CheckPaymentQueue(); TipModel profile = await db.LoadTipProfileForBalance(paymentprofile.DiscordUserId.ToString()); if (paymentprofile.Id != 0) { var ncg = new NCG(); if (ncg.NCGGold("0xa49d64c31A2594e8Fb452238C9a03beFD1119963") == null) { //Bot's Snapshot is down, we can't do any transfers. Console.WriteLine("Down"); } else { var txid = await ncg.SendNCG(paymentprofile.Key, paymentprofile.Amount); if (txid == null) { //Something made the payment fail, maybe the snapsshot is down. Let's keep it here for a re-try. //This logic can be expanded later to try 3~ times before it puts the transaction "on-hold" until someone reviews it. For now it will keep trying. await db.DumpPayment("RedeemFail", paymentprofile, paymentprofile, paymentprofile.Amount, txid); } else { await db.RemoveWithdrawl(paymentprofile); Console.WriteLine("Payment Succesful"); await comms.RedeemSuccess(client, paymentprofile, txid); await db.DumpPayment("RedeemSuccesful", paymentprofile, paymentprofile, paymentprofile.Amount, txid); } } } } }
public static async Task <bool> QueueTips(TipModel profile, string key, float amount, ulong userid) { //checks how much NCG is available - the amount of Tips already provided to users. //Available balance = Total NCG - Amount of Tops already given. var ncg = new NCG(); var db = new SqliteDataAccess(); string botaccount = "0x083B1ad95AF96B754E055384B260a3024d02c7ba"; //let's do every possible check in existance. string balance = ncg.NCGGold(botaccount); Console.WriteLine(balance); float floatPot = float.Parse(balance.ToString()); if (profile.Balance < amount) { return(false); } if (amount > floatPot) { return(false); } //Insert Anti-Exploit Function here. ///////////////////////////////////// //Everything Looks fine, let's go ahead. // float transferamount = amount; amount = profile.Balance - amount; bool check = await db.UpdateTipbalance(profile, amount); if (check) { bool check2 = await db.QueueWithdraw(profile, userid, key, transferamount, 1); if (check2) { await db.DumpTransfer("PaymentQueued", profile, profile, transferamount); return(true); } else { await db.UpdateTipbalance(profile, amount + amount); return(false); } } return(false); }
public static async Task <float> AdminBalanceCheck() { //checks how much NCG is available - the amount of Tips already provided to users. //Available balance = Total NCG - Amount of Tops already given. string botaccount = "0x083B1ad95AF96B754E055384B260a3024d02c7ba"; var ncg = new NCG(); var db = new SqliteDataAccess(); string balance = ncg.NCGGold(botaccount); var usedBalance = db.AdminBalance(); float result = float.Parse(balance) - float.Parse(usedBalance.Result); return(result); }
public async Task GoldProfile(CommandContext ctx, [Description("This is what you called your profile")] string alias = "givemeall") { var username = ctx.Member.DisplayName; var userid = ctx.Member.Id; var eyes = DiscordEmoji.FromName(ctx.Client, ":eyes:"); await ctx.Message.CreateReactionAsync(eyes).ConfigureAwait(false); var oldmessage = ctx.Message; SqliteDataAccess sqli = new SqliteDataAccess(); var ncg = new NCG(); //Debug Console.WriteLine("User: "******" requested NCG value against profile: " + username); //debug end if (alias == "givemeall") { ProfileModel[] array = await sqli.LoadProfileALL(ctx.User.Id, alias); int count = array.Length; int y = 1; List <DiscordMessage> messagesall = new List <DiscordMessage>(); foreach (var entry in array) { var result = await ncg.NCGProfileNewAsync(entry.PublicKey); var comms = new Communication(); if (result == null) { //snapshot down? if (ncg.NCGGold("0xa49d64c31A2594e8Fb452238C9a03beFD1119963") == null) { //f**k snapshot is down. await comms.SnapshotDown(ctx, oldmessage); } else { await comms.GenericError(ctx, oldmessage, username); } } else { bool state = await sqli.UpdateProfile(userid, entry.alias, result); if (state) { float increase = float.Parse(result) - entry.Value; messagesall = await comms.ProfileNCGALL(ctx, oldmessage, username, result, increase, entry.alias, count, y, messagesall); } else { await comms.GenericError(ctx, oldmessage, username); } } y++; } } else { ProfileModel profile = await sqli.LoadProfile(userid, alias); var result = await ncg.NCGProfileNewAsync(profile.PublicKey); var comms = new Communication(); if (result == null) { //snapshot down? if (ncg.NCGGold("0xa49d64c31A2594e8Fb452238C9a03beFD1119963") == null) { //f**k snapshot is down. await comms.SnapshotDown(ctx, oldmessage); } else { await comms.GenericError(ctx, oldmessage, username); } } else { bool state = await sqli.UpdateProfile(userid, alias, result); if (state) { float increase = float.Parse(result) - profile.Value; await comms.ProfileNCG(ctx, oldmessage, username, result, increase, alias); } else { await comms.GenericError(ctx, oldmessage, username); } } } }