// GET: /<controller>/
        public WalletCreator CreateWallet()
        {
            var httpClient    = new BlockchainHttpClient("api-code", "http://127.0.0.1:3000");
            var walletCreator = new WalletCreator(httpClient);

            return(walletCreator);
        }
    /// <summary>
    /// Initializes the UserWallet with the PlayerPrefPassword object.
    /// </summary>
    /// <param name="prefPassword"> The PlayerPrefPassword object used for managing the wallet's encryption password. </param>
    /// <param name="popupManager"> The active PopupManager. </param>
    /// <param name="ethereumNetworkManager"> The active EthereumNetworkManager. </param>
    /// <param name="dynamicDataCache"> The active ProtectedStringDataCache. </param>
    /// <param name="hopeWalletInfoManager"> The active HopeWalletInfoManager. </param>
    public HopeWallet(PlayerPrefPasswordDerivation prefPassword,
                      PopupManager popupManager,
                      EthereumNetworkManager ethereumNetworkManager,
                      DynamicDataCache dynamicDataCache,
                      HopeWalletInfoManager hopeWalletInfoManager)
    {
        this.popupManager     = popupManager;
        this.dynamicDataCache = dynamicDataCache;

        passwordEncryptor       = new MemoryEncryptor(this);
        walletCreator           = new WalletCreator(popupManager, prefPassword, dynamicDataCache, hopeWalletInfoManager);
        walletUnlocker          = new WalletUnlocker(popupManager, prefPassword, dynamicDataCache, hopeWalletInfoManager);
        walletTransactionSigner = new WalletTransactionSigner(prefPassword, dynamicDataCache, ethereumNetworkManager, passwordEncryptor, hopeWalletInfoManager);
    }
        public ApiHelper(string apiCode = null, IHttpClient baseHttpClient = null, string serviceUrl = null, IHttpClient serviceHttpClient = null)
        {
            if (baseHttpClient == null)
            {
                baseHttpClient = new ApiHttpClient(apiCode);
            }
            else
            {
                this.baseHttpClient = baseHttpClient;
                if (apiCode != null)
                {
                    baseHttpClient.ApiCode = apiCode;
                }
            }

            if (serviceHttpClient == null && serviceUrl != null)
            {
                serviceHttpClient = new ApiHttpClient(apiCode, serviceUrl);
            }
            else if (serviceHttpClient != null)
            {
                this.serviceHttpClient = serviceHttpClient;
                if (apiCode != null)
                {
                    serviceHttpClient.ApiCode = apiCode;
                }
            }
            else
            {
                serviceHttpClient = null;
            }

            this.blockExplorer          = new BlockExplorer(baseHttpClient);
            this.transactionBroadcaster = new TransactionPusher(baseHttpClient);
            this.exchangeRateExplorer   = new ExchangeRateExplorer(baseHttpClient);
            this.statisticsExplorer     = new StatisticsExplorer(new ApiHttpClient("https://api.blockchain.info"));

            if (serviceHttpClient != null)
            {
                walletCreator = new WalletCreator(serviceHttpClient);
            }
            else
            {
                walletCreator = null;
            }
        }
Exemple #4
0
        // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        public CreateWalletResponse CreateWallet(string passwordString, string walletLabel)
        {
            BlockchainApiSettings blockchainApiSettings = GetSettings();

            using (BlockchainApiHelper apiHelper = new BlockchainApiHelper(apiCode: blockchainApiSettings.ApiKey,
                                                                           serviceUrl: blockchainApiSettings.ServiceUrl))
            {
                try
                {
                    WalletCreator        walletCreator = apiHelper.CreateWalletCreator();
                    CreateWalletResponse newWallet     =
                        walletCreator.CreateAsync(passwordString, label: walletLabel).Result;

                    return(newWallet);
                }
                catch (ClientApiException e)
                {
                    throw new ArgumentException("Blockchain exception: " + e.Message);
                }
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            try
            {
                var builder = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("config.json");
                Config = builder.Build();

                var httpClient    = new BlockchainHttpClient(Config["BlockChainInfo:ApiCode"], Config["BlockChainInfo:WalletServiceLink"]);
                var walletCreator = new WalletCreator(httpClient);
                CreateWalletResponse walletResponce = walletCreator.CreateAsync(Config["BlockChainInfo:MainPassword"], null, Config["BlockChainInfo:Label"]).Result;

                StreamWriter w = new StreamWriter(Config["WritePath"]);
                w.Write(JsonConvert.SerializeObject(walletResponce));
                w.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }