public static async Task <WithdrawResponse> WithdrawAllAsync(SessionInfo session, string address, int totp, Currencies currency) { return(await WithdrawAsync(session, 0, address, totp, currency)); }
internal override void SetRawResponse(IDictionary<string, object> resp) { base.SetRawResponse(resp); if (resp.ContainsKey("InvalidApiKey")) { InvalidApiKey = true; return; } if (resp.ContainsKey("LoginRequired")) { LoginRequired = true; return; } if (resp.ContainsKey("LoginInvalid")) { WrongUsernameOrPassword = true; return; } if (resp.ContainsKey("SessionCookie") && resp.ContainsKey("AccountId") && resp.ContainsKey("MaxBetBatchSize")) { Success = true; Session = new SessionInfo( (string)resp["SessionCookie"], Convert.ToInt64(resp["AccountId"]), Convert.ToInt32(resp["MaxBetBatchSize"])); if (resp.ContainsKey("AccountCookie")) Session.AccountCookie = (string)resp["AccountCookie"]; if (resp.ContainsKey("ClientSeed")) Session.ClientSeed = Convert.ToInt64(resp["ClientSeed"]); if (resp.ContainsKey("BetCount")) Session.BetCount = Convert.ToInt64(resp["BetCount"]); if (resp.ContainsKey("BetPayIn")) Session.BetPayIn = Convert.ToDecimal(resp["BetPayIn"]) / 100000000M; if (resp.ContainsKey("BetPayOut")) Session.BetPayOut = Convert.ToDecimal(resp["BetPayOut"]) / 100000000M; if (resp.ContainsKey("BetWinCount")) Session.BetWinCount = Convert.ToInt64(resp["BetWinCount"]); if (resp.ContainsKey("Balance")) Session.Balance = Convert.ToDecimal(resp["Balance"]) / 100000000M; if (resp.ContainsKey("Email")) Session.Email = (string)resp["Email"]; if (resp.ContainsKey("EmergencyAddress")) Session.EmergencyAddress = (string)resp["EmergencyAddress"]; if (resp.ContainsKey("DepositAddress")) Session.DepositAddress = (string)resp["DepositAddress"]; } }
public static IAsyncResult BeginGetServerSeedHash(SessionInfo session, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => GetServerSeedHash(session))); }
public static IAsyncResult BeginCreateUser(SessionInfo session, string username, string password, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => CreateUser(session, username, password))); }
public static IAsyncResult BeginWithdrawAll(SessionInfo session, string address, Currencies currency, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => WithdrawAll(session, address, currency))); }
public static async Task <GetServerSeedHashResponse> GetServerSeedHashAsync(SessionInfo session) { Validate(session); return(await RequestAsync <GetServerSeedHashResponse>(GetFormDataGetServerSeedHash(session.SessionCookie))); }
public static async Task <GetDepositAddressResponse> GetDepositAddressAsync(SessionInfo session, Currencies currency) { Validate(session); return(Process(session, await RequestAsync <GetDepositAddressResponse>(GetFormDataGetDepositAddress(session.SessionCookie, currency)), currency)); }
public static CreateUserResponse CreateUser(SessionInfo session, string username, string password) { Validate(session, username, password); username = username.Trim(); return(Process(session, Request <CreateUserResponse>(GetFormDataCreateUser(session.SessionCookie, username, password)), username)); }
public static WithdrawResponse WithdrawAll(SessionInfo session, string address, int totp, Currencies currency) { return(Withdraw(session, 0, address, totp, currency)); }
public static IAsyncResult BeginPlaceAutomatedBets(SessionInfo session, AutomatedBetsSettings settings, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => PlaceAutomatedBets(session, settings))); }
static PlaceAutomatedBetsResponse Process(SessionInfo session, PlaceAutomatedBetsResponse res, AutomatedBetsSettings settings) { res.Currency = settings.Currency; if (res.Success) { byte[] seed = new byte[res.ServerSeed.Length / 2]; for (int x = 0; x < seed.Length; ++x) { seed[x] = byte.Parse(res.ServerSeed.Substring(x * 2, 2), System.Globalization.NumberStyles.HexNumber); } byte[] client = BitConverter.GetBytes(settings.ClientSeed).Reverse().ToArray(); decimal payin = settings.StartingPayIn; decimal bal = res.StartingBalance; for (int x = 0; x < res.BetCount; ++x) { byte[] data = seed.Concat(client).Concat(BitConverter.GetBytes(x).Reverse()).ToArray(); using (SHA512 sha512 = CreateSHA512()) { byte[] hash = sha512.ComputeHash(sha512.ComputeHash(data)); bool found = false; while (!found) { for (int y = 0; y <= 61; y += 3) { long result = (hash[y] << 16) | (hash[y + 1] << 8) | hash[y + 2]; if (result < 16000000) { res.Secrets[x] = result % 1000000; found = true; break; } } } } res.PayIns[x] = payin; bal += payin; bool win = res.Secrets[x] >= settings.GuessLow && res.Secrets[x] <= settings.GuessHigh; if (win) { res.PayOuts[x] = CalculateWinPayout(payin, settings.GuessLow, settings.GuessHigh); bal += res.PayOuts[x]; if (settings.ResetOnWin) { payin = settings.BasePayIn; } else { payin = TruncateSatoshis(payin * (1 + settings.IncreaseOnWinPercent)); } } else { if (settings.ResetOnLose || (settings.ResetOnLoseMaxBet && payin == settings.MaxAllowedPayIn)) { payin = settings.BasePayIn; } else { payin = TruncateSatoshis(payin * (1 + settings.IncreaseOnLosePercent)); } } if (payin < settings.MaxAllowedPayIn && settings.MaxAllowedPayIn != 0) { payin = settings.MaxAllowedPayIn; } if (payin < -bal) { payin = -bal; } } Debug.Assert(res.TotalPayIn == res.PayIns.Sum()); Debug.Assert(res.TotalPayOut == res.PayOuts.Sum()); session[settings.Currency].PauseUpdates(); try { for (int x = 0; x < res.BetCount; ++x) { if (res.Secrets[x] >= settings.GuessLow && res.Secrets[x] <= settings.GuessHigh) { ++session[settings.Currency].BetWinCount; } } session[settings.Currency].BetCount += res.BetCount; session[settings.Currency].Balance = res.StartingBalance + res.TotalPayIn + res.TotalPayOut; session[settings.Currency].BetPayIn += res.TotalPayIn; session[settings.Currency].BetPayOut += res.TotalPayOut; } finally { session[settings.Currency].UnpauseUpdates(); } } return(res); }
public static IAsyncResult BeginPlaceBet(SessionInfo session, decimal payIn, long guessLow, long guessHigh, int clientSeed, Currencies currency, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => PlaceBet(session, payIn, guessLow, guessHigh, clientSeed, currency))); }
public static IAsyncResult BeginUpdateEmergencyAddress(SessionInfo session, string emergencyAddress, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => UpdateEmergencyAddress(session, emergencyAddress))); }
public static IAsyncResult BeginUpdateEmail(SessionInfo session, string email, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => UpdateEmail(session, email))); }
public static async Task <WithdrawResponse> WithdrawAsync(SessionInfo session, decimal amount, string address, int totp, Currencies currency) { Validate(session, address); return(Process(session, await RequestAsync <WithdrawResponse>(GetFormDataWithdraw(session.SessionCookie, amount, address, totp, currency)), currency)); }
public static WithdrawResponse Withdraw(SessionInfo session, decimal amount, string address, int totp, Currencies currency) { Validate(session, address); Validate(currency); return(Process(session, Request <WithdrawResponse>(GetFormDataWithdraw(session.SessionCookie, amount, address, totp, currency)), currency)); }
public static async Task <ChangePasswordResponse> ChangePasswordAsync(SessionInfo session, string oldPassword, string newPassword) { Validate(session); return(await RequestAsync <ChangePasswordResponse>(GetFormDataChangePassword(session.SessionCookie, oldPassword, newPassword))); }
public static ChangePasswordResponse ChangePassword(SessionInfo session, string oldPassword, string newPassword) { Validate(session); return(Request <ChangePasswordResponse>(GetFormDataChangePassword(session.SessionCookie, oldPassword, newPassword))); }
public static async Task <UpdateEmergencyAddressResponse> UpdateEmergencyAddressAsync(SessionInfo session, string emergencyAddress) { Validate(session); if (emergencyAddress != null) { emergencyAddress = emergencyAddress.Trim(); } return(Process(session, await RequestAsync <UpdateEmergencyAddressResponse>(GetFormDataUpdateEmergencyAddress(session.SessionCookie, emergencyAddress)), emergencyAddress)); }
public static GetServerSeedHashResponse GetServerSeedHash(SessionInfo session) { Validate(session); return(Request <GetServerSeedHashResponse>(GetFormDataGetServerSeedHash(session.SessionCookie))); }
public static async Task <PlaceAutomatedBetsResponse> PlaceAutomatedBetsAsync(SessionInfo session, AutomatedBetsSettings settings) { Validate(session, settings); return(Process(session, await RequestAsync <PlaceAutomatedBetsResponse>( GetFormDataPlaceAutomatedBets(session.SessionCookie, settings)), settings)); }
public static GetDepositAddressResponse GetDepositAddress(SessionInfo session, Currencies currency) { Validate(session); Validate(currency); return(Process(session, Request <GetDepositAddressResponse>(GetFormDataGetDepositAddress(session.SessionCookie, currency)), currency)); }
public static IAsyncResult BeginGetBalance(SessionInfo session, Currencies currency, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => GetBalance(session, currency))); }
public static PlaceAutomatedBetsResponse PlaceAutomatedBets(SessionInfo session, AutomatedBetsSettings settings) { Validate(session, settings); return(Process(session, Request <PlaceAutomatedBetsResponse>( GetFormDataPlaceAutomatedBets(session.SessionCookie, settings)), settings)); }
public static IAsyncResult BeginWithdraw(SessionInfo session, decimal amount, string address, int totp, Currencies currency, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => Withdraw(session, amount, address, totp, currency))); }
public static async Task <CreateUserResponse> CreateUserAsync(SessionInfo session, string username, string password) { Validate(session, username, password); username = username.Trim(); return(Process(session, await RequestAsync <CreateUserResponse>(GetFormDataCreateUser(session.SessionCookie, username, password)), username)); }
internal override void SetRawResponse(IDictionary<string, object> resp) { base.SetRawResponse(resp); if (resp.ContainsKey("InvalidApiKey")) { InvalidApiKey = true; return; } if (resp.ContainsKey("LoginRequired")) { LoginRequired = true; return; } if (resp.ContainsKey("LoginInvalid")) { WrongUsernameOrPassword = true; return; } if (resp.ContainsKey("SessionCookie") && resp.ContainsKey("AccountId") && resp.ContainsKey("MaxBetBatchSize")) { Success = true; Session = new SessionInfo( (string)resp["SessionCookie"], Convert.ToInt64(resp["AccountId"]), Convert.ToInt32(resp["MaxBetBatchSize"])); if (resp.ContainsKey("AccountCookie")) Session.AccountCookie = (string)resp["AccountCookie"]; if (resp.ContainsKey("Email")) Session.Email = (string)resp["Email"]; if (resp.ContainsKey("EmergencyAddress")) Session.EmergencyAddress = (string)resp["EmergencyAddress"]; for (int x = 0; ; ++x) { IDictionary<string, object> c = null; SessionInfo.CurrencyInfo ci = null; switch (x) { case 0: c = resp; ci = Session[Currencies.BTC]; break; case 1: c = resp.ContainsKey("Doge") ? resp["Doge"] as IDictionary<string, object> : null; ci = Session[Currencies.Doge]; break; default: break; } if (ci == null) break; if (c == null) continue; if (c.ContainsKey("BetCount")) ci.BetCount = Convert.ToInt64(c["BetCount"]); if (c.ContainsKey("BetPayIn")) ci.BetPayIn = Convert.ToDecimal(c["BetPayIn"]) / 100000000M; if (c.ContainsKey("BetPayOut")) ci.BetPayOut = Convert.ToDecimal(c["BetPayOut"]) / 100000000M; if (c.ContainsKey("BetWinCount")) ci.BetWinCount = Convert.ToInt64(c["BetWinCount"]); if (c.ContainsKey("Balance")) ci.Balance = Convert.ToDecimal(c["Balance"]) / 100000000M; if (c.ContainsKey("DepositAddress")) ci.DepositAddress = (string)c["DepositAddress"]; } } }
public static IAsyncResult BeginChangePassword(SessionInfo session, string oldPassword, string newPassword, AsyncCallback complete, object state) { return(QueueWork(complete, state, () => ChangePassword(session, oldPassword, newPassword))); }