public EthereumIndexerService(IEthereumSamuraiApi ethereumSamuraiApi) { _addressUtil = new AddressUtil(); _ethereumSamuraiApi = ethereumSamuraiApi; }
public Address(string host, int port) : this(host, AddressUtil.GetAddressByName(host), port) { }
/// <summary> /// Create a transaction builder for a given coin. /// Some other Blockchain coins have different serializes of network parameters, /// this is calculated when creating the builder. /// </summary> public static TransactionBuilder Create(CoinParameters param) { AddressUtil.PopulateCoinParameters(param); // todo: move factory selector in a configuration file var lst = new List <string> { "BTC", "TRC", "GRC", "DOGE", "DASH", "RDD", "XPM", "LTC", "NMC", "QRK", "PPC", "MTR", "GB", "SHM", "CRX", "UBIQ", "ARG", "ZYD", "DLC", "STRAT", "SH" }; if (lst.Contains(param.CoinTag)) { var ser = new TransactionSerializer(param); // coin scale can be found in util.h (static const int64_t COIN = 100000000) param.CoinScale = 100000000; param.TransactionVersion = 1; if (param.CoinTag == "QRK") { param.CoinScale = 100000; } if (param.CoinTag == "PPC") { param.CoinScale = 1000000; ser = new TransactionSerializerTimeStamped(param); } if (param.CoinTag == "GRC") { ser = new TransactionSerializerGridcoin(param); } if (param.CoinTag == "RDD") { param.TransactionVersion = 2; ser = new TransactionSerializerReddcoin(param); } if (param.CoinTag == "MTR") { ser = new TransactionSerializerTimeStamped(param); } if (param.CoinTag == "GB") { ser = new TransactionSerializerTimeStamped(param); } if (param.CoinTag == "SHM") { ser = new TransactionSerializerTimeStamped(param); } if (param.CoinTag == "CRX") { ser = new TransactionSerializerTimeStamped(param); } if (param.CoinTag == "UBIQ") { ser = new TransactionSerializerTimeStamped(param); } if (param.CoinTag == "STRAT") { ser = new TransactionSerializerTimeStamped(param); } var builder = new TransactionBuilder(param, ser, new TransactionSigner(param, ser)); return(builder); } return(new TransactionBuilderClient()); }
private bool BeValidEthereumAddress(string aDestinationAddress) => AddressUtil.IsValidEthereumAddressHexFormat(aDestinationAddress);
public IPAddress GetInetAddress() { return(AddressUtil.GetAddressByName(GetScopedHost())); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { //public string StreetAddress { get; set; } //public string AddressLine2 { get; set; } //public string City { get; set; } //public string Province { get; set; } //public string PostalCode { get; set; } //public double Latitude { get; set; } //public double Longitude { get; set; } try { GeocodeValue geocodeValue; geocodeValue = GeocodingUtil.ConvertAddressToGeocode(AddressUtil.BuildAddrString(model.StreetAddress, model.AddressLine2, model.City, model.Province, model.PostalCode)); model.Latitude = geocodeValue.Latitude; model.Longitude = geocodeValue.Longitude; } catch (InvalidGeocodeInfoException e) { } var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, StreetAddress = model.UserName, AddressLine2 = model.AddressLine2, City = model.City, Province = model.Province, PostalCode = model.PostalCode, Latitude = model.Latitude, Longitude = model.Longitude }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { result = await UserManager.AddToRoleAsync(user.Id, model.RoleName); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } List <SelectListItem> list = new List <SelectListItem>(); foreach (var role in RoleManager.Roles) { list.Add(new SelectListItem() { Value = role.Name, Text = role.Name }); } ViewBag.Roles = list; // If we got this far, something failed, redisplay form return(View(model)); }
public SignatureService(ILykkeSigningAPI signatureApi) { _signatureApi = signatureApi; _addressUtil = new AddressUtil(); }
public ActionResult PlaceDetail(int?id) { var _placeService = this.Service <IPlaceService>(); Place place = _placeService.FirstOrDefault(p => p.Id == id.Value); var _placeImageService = this.Service <IPlaceImageService>(); List <PlaceImage> placeImages = _placeImageService.Get(p => p.PlaceId == id.Value).ToList(); Country vietnam = AddressUtil.GetINSTANCE().GetCountry(Server.MapPath(AddressUtil.PATH)); Province province = vietnam.VietNamese.Where(p => (p.Type + " " + p.Name).Equals(place.City)).FirstOrDefault(); var provinces = vietnam.VietNamese.Select(p => new SelectListItem { Text = p.Type + " " + p.Name, Value = p.Type + " " + p.Name }) .OrderBy(p => p.Value); IOrderedEnumerable <SelectListItem> districts = new List <SelectListItem>().OrderBy(d => d.Value); IOrderedEnumerable <SelectListItem> wards = new List <SelectListItem>().OrderBy(d => d.Value); if (province != null) { districts = province.Districts.Select(d => new SelectListItem { Text = d.Type + " " + d.Name, Value = d.Type + " " + d.Name }) .OrderBy(d => d.Value); District district = province.Districts.Where(d => (d.Type + " " + d.Name).Equals(place.District)).FirstOrDefault(); if (district != null) { wards = district.Wards.Select(w => new SelectListItem { Text = w.Type + " " + w.Name, Value = w.Type + " " + w.Name }) .OrderBy(w => w.Value); } } provinces.ToList().Add(new SelectListItem { Text = "", Value = " " }); districts.ToList().Add(new SelectListItem { Text = "", Value = " " }); wards.ToList().Add(new SelectListItem { Text = "", Value = " " }); List <SelectListItem> statuss = new List <SelectListItem>(); statuss.Add(new SelectListItem { Text = Utils.GetEnumDescription(PlaceStatus.Active), Value = Convert.ToString((int)PlaceStatus.Active) }); statuss.Add(new SelectListItem { Text = Utils.GetEnumDescription(PlaceStatus.Repairing), Value = Convert.ToString((int)PlaceStatus.Repairing) }); ViewBag.placeImages = placeImages; ViewBag.provinces = provinces; ViewBag.districts = districts; ViewBag.wards = wards; ViewBag.statusList = statuss; return(View(place)); }
public Web3Interface(string web3ApiPath, string contractAddress, string minerAddress, string privateKey, float gasToMine, string abiFileName, int updateInterval, int hashratePrintInterval, ulong gasLimit) { m_updateInterval = updateInterval; m_submittedChallengeList = new List <string>(); m_submitDateTimeList = new List <DateTime>(MAX_SUBMIT_DTM_COUNT + 1); Nethereum.JsonRpc.Client.ClientBase.ConnectionTimeout = MAX_TIMEOUT * 1000; LastSubmitLatency = -1; Latency = -1; if (string.IsNullOrWhiteSpace(contractAddress)) { Program.Print("[INFO] Contract address not specified, default 0xBTC"); contractAddress = Config.Defaults.Contract0xBTC_mainnet; } var addressUtil = new AddressUtil(); if (!addressUtil.IsValidAddressLength(contractAddress)) { throw new Exception("Invalid contract address provided, ensure address is 42 characters long (including '0x')."); } else if (!addressUtil.IsChecksumAddress(contractAddress)) { throw new Exception("Invalid contract address provided, ensure capitalization is correct."); } if (!string.IsNullOrWhiteSpace(privateKey)) { m_account = new Account(privateKey); minerAddress = m_account.Address; } if (!addressUtil.IsValidAddressLength(minerAddress)) { throw new Exception("Invalid miner address provided, ensure address is 42 characters long (including '0x')."); } else if (!addressUtil.IsChecksumAddress(minerAddress)) { throw new Exception("Invalid miner address provided, ensure capitalization is correct."); } Program.Print("[INFO] Miner's address : " + minerAddress); MinerAddress = minerAddress; SubmitURL = string.IsNullOrWhiteSpace(web3ApiPath) ? DEFAULT_WEB3_API : web3ApiPath; m_web3 = new Web3(SubmitURL); var abi = File.ReadAllText(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), abiFileName)); m_contract = m_web3.Eth.GetContract(abi, contractAddress); if (!string.IsNullOrWhiteSpace(privateKey)) { m_gasToMine = gasToMine; Program.Print(string.Format("[INFO] Gas to mine: {0}", m_gasToMine)); m_gasLimit = gasLimit; Program.Print(string.Format("[INFO] Gas limit: {0}", m_gasLimit)); m_mintMethod = m_contract.GetFunction("mint"); m_transferMethod = m_contract.GetFunction("transfer"); m_getMiningDifficulty = m_contract.GetFunction("getMiningDifficulty"); m_getMiningTarget = m_contract.GetFunction("getMiningTarget"); m_getChallengeNumber = m_contract.GetFunction("getChallengeNumber"); m_getMiningReward = m_contract.GetFunction("getMiningReward"); if (m_contract.ContractBuilder.ContractABI.Functions.Any(f => f.Name == "_MAXIMUM_TARGET")) { m_MAXIMUM_TARGET = m_contract.GetFunction("_MAXIMUM_TARGET"); } m_mintMethodInputParamCount = m_contract.ContractBuilder. ContractABI.Functions. First(f => f.Name == "mint"). InputParameters.Count(); m_hashPrintTimer = new Timer(hashratePrintInterval); m_hashPrintTimer.Elapsed += m_hashPrintTimer_Elapsed; m_hashPrintTimer.Start(); } }
public SignatureChecker() { _addressUtil = new AddressUtil(); }
public JsonResult VietNam() { Country vietnam = AddressUtil.GetINSTANCE().GetCountry(Server.MapPath(AddressUtil.PATH)); return(Json(vietnam, JsonRequestBehavior.AllowGet)); }
public bool isTargetFriendly() { return(AddressUtil.getTargetType() == 0); }