public PasswordSection(
            PlayerPrefPasswordDerivation playerPrefPasswordDerivation,
            UserWalletManager userWalletManager,
            HopeWalletInfoManager hopeWalletInfoManager,
            DynamicDataCache dynamicDataCache,
            SettingsPopupAnimator settingsPopupAnimator,
            HopeInputField newPasswordField,
            HopeInputField confirmPasswordField,
            Button saveButton,
            GameObject loadingIcon)
        {
            this.playerPrefPasswordDerivation = playerPrefPasswordDerivation;
            this.hopeWalletInfoManager        = hopeWalletInfoManager;
            this.dynamicDataCache             = dynamicDataCache;
            this.settingsPopupAnimator        = settingsPopupAnimator;
            this.newPasswordField             = newPasswordField;
            this.confirmPasswordField         = confirmPasswordField;
            this.saveButton  = saveButton;
            this.loadingIcon = loadingIcon;

            walletEncryptor = new WalletEncryptor(playerPrefPasswordDerivation, dynamicDataCache);
            walletDecryptor = new WalletDecryptor(playerPrefPasswordDerivation, dynamicDataCache);
            walletInfo      = hopeWalletInfoManager.GetWalletInfo(userWalletManager.GetWalletAddress());

            newPasswordField.OnInputUpdated     += _ => PasswordsUpdated();
            confirmPasswordField.OnInputUpdated += _ => PasswordsUpdated();
            saveButton.onClick.AddListener(SavePasswordButtonClicked);
        }
        public WalletNameSection(
            HopeWalletInfoManager hopeWalletInfoManager,
            WalletPasswordVerification walletPasswordVerification,
            ContactsManager contactsManager,
            DynamicDataCache dynamicDataCache,
            UserWalletManager userWalletManager,
            SettingsPopupAnimator settingsPopupAnimator,
            GameObject currentPasswordSection,
            GameObject walletNameSection,
            GameObject loadingIcon,
            HopeInputField currentPasswordField,
            HopeInputField currentWalletNameField,
            HopeInputField newWalletNameField,
            Button nextButton,
            Button saveButton,
            GameObject[] hopeOnlyCategoryButtons)
        {
            this.hopeWalletInfoManager      = hopeWalletInfoManager;
            this.walletPasswordVerification = walletPasswordVerification;
            this.contactsManager            = contactsManager;
            this.dynamicDataCache           = dynamicDataCache;
            this.settingsPopupAnimator      = settingsPopupAnimator;
            this.currentPasswordSection     = currentPasswordSection;
            this.walletNameSection          = walletNameSection;
            this.loadingIcon             = loadingIcon;
            this.currentPasswordField    = currentPasswordField;
            this.currentWalletNameField  = currentWalletNameField;
            this.newWalletNameField      = newWalletNameField;
            this.nextButton              = nextButton;
            this.saveButton              = saveButton;
            this.hopeOnlyCategoryButtons = hopeOnlyCategoryButtons;

            walletInfo = hopeWalletInfoManager.GetWalletInfo(userWalletManager.GetWalletAddress());
            SetListeners();
        }
Пример #3
0
        /// <summary>
        /// Returns an object containing various wallet state info.
        /// </summary>
        /// <returns>Wallet response wrapper; Success: WalletInfo object, Error: WalletError object</returns>
        public static async Task <ParsedWalletResponse <WalletInfo?> > GetWalletInfoAsync(this WalletClient client)
        {
            //make internal request to the wallet implementation
            var response = await client.MakeRequestAsync("getwalletinfo");

            if (response.Error == null)
            {
                //try deserialize walletinfo
                WalletInfo walletInfo = default(WalletInfo);

                try
                {
                    walletInfo = JsonConvert.DeserializeObject <WalletInfo>(response.Result);
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                return(ParsedWalletResponse <WalletInfo?> .CreateContent(walletInfo));
            }
            else
            {
                return(ParsedWalletResponse <WalletInfo?> .CreateError(response.Error));
            }
        }
Пример #4
0
        private void GetInfo()
        {
            WalletInfo = new List <WalletInfo>();
            XElement xeResources;

            commonCulture.appData.GetRootResourceNonLanguage("/Shared/Wallets", out xeResources);

            var walletList = xeResources.Elements(commonVariables.OperatorCode).Elements("Wallets").Elements().Where(m => m.Attribute("enable").Value == "true").ToList().OrderBy(x => (int)x.Attribute("orderBy"));

            foreach (var element in walletList)
            {
                var item = new WalletInfo
                {
                    Id            = Convert.ToInt16(element.Attribute("id").Value),
                    OrderBy       = Convert.ToInt16(element.Attribute("orderBy").Value),
                    SelectOrder   = Convert.ToInt16(element.Attribute("selectOrder").Value),
                    Restriction   = element.Attribute("CurrRestriction").Value.ToUpper(),
                    AllowOnly     = element.Attribute("CurrAllowOnly").Value.ToUpper(),
                    CurrencyLabel = element.Attribute("CurrStaticLabel").Value.ToUpper()
                };

                foreach (var v in element.Elements("lang").Select(x => x.Element(commonVariables.SelectedLanguageShort)))
                {
                    item.Name = Convert.ToString(v.Value);
                }

                foreach (var v in element.Elements("selection").Select(x => x.Element(commonVariables.SelectedLanguageShort)))
                {
                    item.SelectName = Convert.ToString(v.Value);
                }

                var curr = commonCookie.CookieCurrency;

                if (!string.IsNullOrWhiteSpace(item.AllowOnly))
                {
                    if (item.AllowOnly.Contains(curr))
                    {
                        WalletInfo.Add(item);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(item.Restriction))
                {
                    if (!item.Restriction.Contains(curr))
                    {
                        WalletInfo.Add(item);
                    }
                }
                else
                {
                    WalletInfo.Add(item);
                }
            }

            var note = xeResources.Elements(commonVariables.OperatorCode).Elements("FundsPageNote").Select(x => x.Element(commonVariables.SelectedLanguageShort));

            foreach (var item in note)
            {
                FundsPageNote = Convert.ToString(item.Value);
            }
        }
Пример #5
0
        public static void CreateWalletToKeystoreFile(string[] args)
        {
            if (args.Length < 2)
            {
                WriteLine("You have input invalid parameters.");
                Environment.Exit(0);
            }
            WalletInfo walletInfo = WalletUtils.CreateWallet(args[1]);

            byte[] rawPrivateKey = walletInfo.KeyPair.GetRawPrivateKey();
            string newPrivateKey = ByteUtils.ToHexString(rawPrivateKey, Prefix.ZeroLowerX);
            string keyStoreStr   = walletInfo.ToKeystoreString();
            string path          = "./keystore.json";

            if (args.Length > 2)
            {
                path = args[2];
            }

            var parent = Directory.GetDirectoryRoot(path);

            if (!string.IsNullOrEmpty(parent))
            {
                Directory.CreateDirectory(parent);
            }
            File.WriteAllText(path, keyStoreStr);
            WriteLine("The wallet created successfully and the key store is:");
            WriteLine(keyStoreStr);
            WriteLine("The wallet created successfully and the privateKey is:");
            WriteLine(newPrivateKey);
        }
Пример #6
0
    /// <summary>
    /// Adds a new wallet to the list of WalletInfo.
    /// </summary>
    /// <param name="walletName"> The name of the wallet. </param>
    /// <param name="walletAddresses"> The array of addresses associated with the wallet. </param>
    /// <param name="encryptionHashes"> The encrypted hashes used to encrypt the seed of the wallet. </param>
    /// <param name="encryptedSeed"> The encrypted wallet seed. </param>
    /// <param name="passwordHash"> The pbkdf2 password hash of the password used to encrypt the wallet. </param>
    public void AddWalletInfo(string walletName, string[][] walletAddresses, string[] encryptionHashes, string encryptedSeed, string passwordHash)
    {
        var encryptedWalletData = new WalletInfo.EncryptedDataContainer(encryptionHashes, encryptedSeed, passwordHash);
        var walletInfo          = new WalletInfo(encryptedWalletData, walletName, (string[][])walletAddresses.Clone(), wallets.Count + 1);

        wallets.Add(walletInfo);
    }
Пример #7
0
        public WalletInfo GetWalletInfo()
        {
            var syncingInfo = new WalletInfo
            {
                ConsensusTipHeight = this.chainState.ConsensusTip.Height,
                ConsensusTipHash   = this.chainState.ConsensusTip.HashBlock,
                ConsensusTipAge    = (int)(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - this.chainState.ConsensusTip.Header.Time),
                MaxTipAge          = this.network.MaxTipAge,
                AssemblyName       = typeof(WalletController).Assembly.GetName().Name,
                AssemblyVersion    = typeof(WalletController).Assembly.GetShortVersionString(),
                IsAtBestChainTip   = this.chainState.IsAtBestChainTip
            };

            if (this.chainState.BlockStoreTip != null)
            {
                syncingInfo.BlockStoreHeight = this.chainState.BlockStoreTip.Height;
                syncingInfo.BlockStoreHash   = this.chainState.BlockStoreTip.HashBlock;
            }

            syncingInfo.ConnectionInfo = GetConnections();

            if (this.walletName != null)
            {
                syncingInfo.WalletDetails = GetWalletDetails();
            }

            return(syncingInfo);
        }
Пример #8
0
 public static double PriseWithFee(double price, WalletInfo walletInfo)
 {
     return(PriseWithFee(
                price,
                walletInfo.WalletFeePercent,
                walletInfo.WalletPublisherFeePercent,
                walletInfo.WalletFeeMinimum));
 }
Пример #9
0
        protected override async Task InitializationAsync()
        {
            var walletResult = await OfoApi.GetWalletInfoAsync();

            if (await CheckOfoApiResult(walletResult))
            {
                WalletInfo = walletResult.Data;
            }
        }
        public MyWalletsViewModel(
            IAtomexApp app, Action <ViewModelBase> showContent)
        {
            AtomexApp = app ?? throw new ArgumentNullException(nameof(app));
            Wallets   = WalletInfo.AvailableWallets();
            AtomexApp.TerminalChanged += OnTerminalChangedEventHandler;

            ShowContent += showContent;
        }
Пример #11
0
    /// <summary>
    /// Updates the info of the wallet given the address of the wallet.
    /// </summary>
    /// <param name="walletAddress"> An address of the wallet to update. </param>
    /// <param name="newWalletInfo"> The new wallet info. </param>
    public void UpdateWalletInfo(string walletAddress, WalletInfo newWalletInfo)
    {
        if (!wallets.Contains(walletAddress))
        {
            return;
        }

        wallets[walletAddress] = newWalletInfo;
    }
Пример #12
0
    /// <summary>
    /// Updates the info of the wallet given the wallet number.
    /// </summary>
    /// <param name="walletNum"> The wallet number to update. </param>
    /// <param name="newWalletInfo"> The new wallet info. </param>
    public void UpdateWalletInfo(int walletNum, WalletInfo newWalletInfo)
    {
        if (wallets.Count < walletNum)
        {
            return;
        }

        wallets[walletNum - 1] = newWalletInfo;
    }
Пример #13
0
        public static double PriceReFee(double price, WalletInfo walletInfo)
        {
            var priseWithoutFee = PriseWithoutFee(price, walletInfo.WalletFeePercent,
                                                  walletInfo.WalletPublisherFeePercent, walletInfo.WalletFeeMinimum);
            var priseWithFee = PriseWithFee(priseWithoutFee, walletInfo.WalletFeePercent,
                                            walletInfo.WalletPublisherFeePercent, walletInfo.WalletFeeMinimum);

            return(priseWithFee);
        }
        public MyWalletsViewModel(
            IAtomixApp app,
            IDialogViewer dialogViewer)
        {
            App          = app ?? throw new ArgumentNullException(nameof(app));
            DialogViewer = dialogViewer ?? throw new ArgumentNullException(nameof(dialogViewer));

            Wallets = WalletInfo.AvailableWallets();
        }
Пример #15
0
 public Task <int> SaveWalletAsync(WalletInfo Wallet)
 {
     if (Wallet.ID != 0)
     {
         return(_database.UpdateAsync(Wallet));
     }
     else
     {
         return(_database.InsertAsync(Wallet));
     }
 }
Пример #16
0
    /// <summary>
    /// Decrypts the wallet given the user's password.
    /// </summary>
    /// <param name="walletInfo"> The wallet to decrypt. </param>
    /// <param name="password"> The user's password to the wallet. </param>
    /// <param name="onWalletDecrypted"> Action called once the wallet has been decrypted, passing the <see langword="byte"/>[] seed of the wallet. </param>
    public void DecryptWallet(WalletInfo walletInfo, byte[] password, Action <byte[]> onWalletDecrypted)
    {
        MainThreadExecutor.QueueAction(() =>
        {
            playerPrefPassword.PopulatePrefDictionary(walletInfo.WalletAddresses[0][0]);

            Task.Factory.StartNew(() => AsyncDecryptWallet(
                                      walletInfo.EncryptedWalletData.EncryptionHashes,
                                      walletInfo.EncryptedWalletData.EncryptedSeed,
                                      password,
                                      onWalletDecrypted));
        });
    }
Пример #17
0
        public WalletInfo Get([FromBody] long IdCode)
        {
            WalletInfo walletInfo = null;

            Wallet wallet = databaseBTCContext.Wallet.FirstOrDefault(ww => ww.IdCode == IdCode);

            if (wallet != null)
            {
                walletInfo = new WalletInfo();
                walletInfo.WalletAdressName = wallet.AdressName;
            }

            return(walletInfo);
        }
Пример #18
0
        public static AddWalletDialogFragment NewInstance(string[] networkProviders, WalletInfo wallet = null, bool edit = false)
        {
            AddWalletDialogFragment fragment = new AddWalletDialogFragment();
            Bundle bundle = new Bundle();

            bundle.PutStringArray("networks", networkProviders);
            bundle.PutBoolean("edit", edit);
            if (wallet != null)
            {
                bundle.PutString("wallet", JsonConvert.SerializeObject(wallet));
            }

            fragment.Arguments = bundle;
            return(fragment);
        }
        public StartViewModel(Action <ViewModelBase> showContent, Action showStart, IAtomexApp app,
                              MainWindowViewModel mainWindowWM)
        {
#if DEBUG
            if (Env.IsInDesignerMode())
            {
                DesignerMode();
            }
#endif
            AtomexApp  = app ?? throw new ArgumentNullException(nameof(app));
            HasWallets = WalletInfo.AvailableWallets().Count() > 0;

            MainWindowVM = mainWindowWM;
            ShowContent += showContent;
            ShowStart   += showStart;
        }
Пример #20
0
        public async Task <JsonResult> GetWalletInfo(string cryptoCode)
        {
            var n = _networkProvider.GetByCryptoCode(cryptoCode);
            var derivationStrategy = await _walletService.GetOurDerivationStrategyAsync(n);

            var balance = await _walletService.GetBalanceAsync(n);

            var outboundCaps = _peerManagerProvider.GetPeerManager(n).ChannelManager.ListChannels(_pool)
                               .Select(c => c.OutboundCapacityMSat).ToArray();
            var offChainBalance = outboundCaps.Length == 0 ? 0 : outboundCaps.Aggregate((x, acc) => x + acc);
            var resp            = new WalletInfo {
                DerivationStrategy = derivationStrategy, OnChainBalanceSatoshis = balance, OffChainBalanceMSat = offChainBalance
            };

            return(new JsonResult(resp, _repositoryProvider.GetSerializer(n).Options));
        }
Пример #21
0
    public async Task Topup()
    {
        var      amount   = 20;
        var      time     = 1;
        var      user_id  = this.Context.Message.Author.AvatarId;
        long     guild_id = (long)this.Context.Guild.Id;
        DateTime current  = DateTime.Now;

        using (var db = new DatabaseContext())
        {
            db.Database.Initialize(true);
        }
        using (var db = new WalletDbContext())
        {
            var row = db.Wallets.SingleOrDefault(u => u.User_id == user_id && u.Guild_id == guild_id);
            using (var wdb = new WalletInfoDbContext())
            {
                var        info       = wdb.WalletInfos.SingleOrDefaultAsync(w => w.Guid == row.Guid);
                var        user       = Context.User.Mention;
                WalletInfo walletinfo = (from x in wdb.WalletInfos where x.Guid == row.Guid select x).First();
                if (info.Result.Modified_on <= current.AddHours(-time))
                {
                    walletinfo.Points      = walletinfo.Points + amount;
                    walletinfo.TopupAmount = walletinfo.TopupAmount + amount;
                    walletinfo.TopupCount  = walletinfo.TopupCount + 1;
                    walletinfo.Modified_on = current;
                    this.Context.Channel.SendMessageAsync(user + " Topup successfull. Your new wallet balance is : " + walletinfo.Points);
                }
                else
                {
                    walletinfo.TopupFail = walletinfo.TopupFail + 1;
                    TimeSpan span = current.Subtract(info.Result.Modified_on);
                    if (time == 1)
                    {
                        this.Context.Channel.SendMessageAsync(user + "You may top up every hour. It has been " + (int)span.TotalMinutes + " minutes since your last topup.");
                    }
                    else
                    {
                        this.Context.Channel.SendMessageAsync(user + "You may top up every " + time + " hours. It has been " + (int)span.TotalMinutes + " minutes since your last topup.");
                    }
                }
                wdb.SaveChanges();
            }
        }
    }
Пример #22
0
        async void OnSaveWalletClicked(object sender, EventArgs e)
        {
            txtpwd.Text = txtpwd.Text.Trim();
            if (txtpwd.Text.Trim() == "" || txtpwd.Text.Length < 8)
            {
                await DisplayAlert("Password Error!", "Password length cannot be less than 8", "OK");

                return;
            }
            (sender as Button).IsEnabled = false;
            try
            {
                bool answer = await DisplayAlert("Password Confirm!", "Password:"******"Yes", "No");

                if (answer)
                {
                    try
                    {
                        WalletInfo wi    = new WalletInfo();
                        var        ecKey = EthECKey.GenerateKey();
                        wi.PublicKey  = HexByteConvertorExtensions.ToHex(ecKey.GetPubKey());
                        wi.PrivateKey = ecKey.GetPrivateKey();

                        wi.Address = ecKey.GetPublicAddress().ToLower();
                        var scryptService = new KeyStoreScryptService();
                        wi.FJson = scryptService.EncryptAndGenerateKeyStoreAsJson(txtpwd.Text, ecKey.GetPrivateKeyAsBytes()
                                                                                  , wi.Address.Replace("0x", ""), scryptParams);
                        await App.Wdb.SaveWalletAsync(wi);

                        txtpwd.Text = "";
                        WalletBind();
                        await DisplayAlert("Tips", "Success", "OK");
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Exception!", "Try again later " + ex.Message, "OK");
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Exception!", "Try again later " + ex.Message, "OK");
            }
            (sender as Button).IsEnabled = true;
        }
Пример #23
0
        public static double PriceCorrection(double price, WalletInfo walletInfo)
        {
            var minPrice = MinPriceForOrder(walletInfo);

            if (price <= minPrice)
            {
                return(minPrice);
            }

            var tempPrice = price;

            while (PriceReFee(tempPrice, walletInfo) > price)
            {
                tempPrice = tempPrice - 0.01;
            }

            return(tempPrice);
        }
Пример #24
0
        public void Create(WalletInfo model)
        {
            using (var db = this.GetWalletContext())
            {
                var entity = new BASE_WALLET
                {
                    ID             = model.Id,
                    WALLET_NAME    = model.WalletName,
                    PASSWORD       = model.Password,
                    MNEMONIC_WORDS = model.MnemonicWords,
                    DESCRIPTION    = model.Description,
                    IS_ACTIVE      = true,
                    CREATE_DATE    = DateTime.Now
                };

                db.BASE_WALLET.Add(entity);
                db.SaveChanges();
            }
        }
Пример #25
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            if (Arguments.ContainsKey("wallet"))
            {
                walletInfo = JsonConvert.DeserializeObject <WalletInfo>(Arguments.GetString("wallet"));
            }

            isEdit = Arguments.GetBoolean("edit");

            //
            networkProvider = Arguments.GetStringArray("networks").ToList();

            var view = Activity.LayoutInflater.Inflate(Resource.Layout.add_wallet_layout, null);
            var dlg  = new AlertDialog.Builder(Activity)
                       .SetTitle(isEdit ? "Edit Wallet" : "Add Wallet")
                       .SetView(view)
                       .SetPositiveButton(isEdit ? "Save Changes" : "Add", delegate { })
                       .SetNegativeButton("Cancel", delegate { })
                       .Create();

            networkProviderSpinner = view.FindViewById <Spinner>(Resource.Id.network_operators_spinner);
            tbPhoneNo = view.FindViewById <TextInputLayout>(Resource.Id.tb_phone);

            //  Assign network providers
            networkProviderSpinner.Adapter = new ArrayAdapter <string>(Activity, global::Android.Resource.Layout.SimpleSpinnerDropDownItem, networkProvider);

            if (walletInfo?.Provider != null)
            {
                var index = networkProvider.IndexOf(walletInfo.Provider);
                if (index >= 0)
                {
                    networkProviderSpinner.SetSelection(index);
                }
            }

            //
            if (walletInfo?.Value != null)
            {
                tbPhoneNo.EditText.Text = walletInfo.Value;
            }

            return(dlg);
        }
Пример #26
0
        public WalletInfo WalletInfo(string json)
        {
            var walletInfoDes = JsonConvert.DeserializeObject <JWalletInfo>(json);

            var walletInfo = new WalletInfo
            {
                Currency                  = walletInfoDes.Currency,
                WalletCountry             = walletInfoDes.WalletCountry,
                WalletBalance             = (double)walletInfoDes.WalletBalance / 100,
                MaxBalance                = (double)walletInfoDes.MaxBalance / 100,
                WalletFee                 = (double)walletInfoDes.WalletFee / 100,
                WalletFeeMinimum          = (double)walletInfoDes.WalletFeeMinimum / 100,
                WalletFeePercent          = Convert.ToInt32(walletInfoDes.WalletFeePercent * 100),
                WalletPublisherFeePercent =
                    Convert.ToInt32(walletInfoDes.WalletPublisherFeePercent * 100),
                WalletTradeMaxBalance = (double)walletInfoDes.WalletTradeMaxBalance / 100
            };

            return(walletInfo);
        }
Пример #27
0
        private async Task OnWalletTapped(WalletInfo wallet)
        {
            try
            {
                string authType = await SecureStorage.GetAsync(wallet.Name + "-" + "AuthType");

                if (authType == "Pin")
                {
                    await Navigation.PushAsync(new AuthPage(new UnlockViewModel(AtomexApp, wallet, Navigation)));
                }
                else
                {
                    await Navigation.PushAsync(new UnlockWalletPage(new UnlockViewModel(AtomexApp, wallet, Navigation)));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, AppResources.NotSupportSecureStorage);
                return;
            }
        }
Пример #28
0
        async void OnImportWalletClicked(object sender, EventArgs e)
        {
            try
            {
                var result = await Plugin.FilePicker.CrossFilePicker.Current.PickFile();

                if (result != null)
                {
                    var          stream     = result.GetStream();
                    StreamReader reader     = new StreamReader(stream);
                    string       str        = reader.ReadLine();
                    var          resultJson = JsonConvert.DeserializeObject <dynamic>(str);
                    string       address    = "0x" + resultJson.address;
                    if (address.Length > 20)
                    {
                        var wallet = App.Wdb.GetWalletAsyncByAddress(address).Result;
                        if (wallet == null)
                        {
                            WalletInfo wi = new WalletInfo();

                            wi.PublicKey  = "";
                            wi.PrivateKey = "";

                            wi.Address = address;
                            var scryptService = new KeyStoreScryptService();
                            wi.FJson = str;
                            await App.Wdb.SaveWalletAsync(wi);
                            await DisplayAlert("Tips", "Success", "OK");

                            WalletBind();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Exception!", "Try again later " + ex.Message, "OK");
            }
        }
Пример #29
0
        public MnemonicResult CreateWallet(string password)
        {
            var result   = KeyOperator.Instance.CreateMnemonicRoot(password);
            var mnemonic = string.Join(" ", result.MnemonicWords);
            var wallet   = new WalletInfo
            {
                Id            = Guid.NewGuid().ToString("N"),
                WalletName    = "Wallet_" + DateTime.Now.ToString("yyyyMMddHHmm"),
                Password      = MD5Helper.ToMD5(password),
                MnemonicWords = CryptHelper.AESEncryptText(mnemonic, password)
            };

            var rootAddress = new AddressInfo
            {
                Id              = Guid.NewGuid().ToString("N"),
                Address         = result.RootAddress,
                ExtPubKeyWif    = result.RootExtPubKeyWif,
                WalletId        = wallet.Id,
                Network         = result.Network,
                KeyPath         = null,
                AddressType     = (long)CustomAddressType.Root,
                AddressCategory = (long)AddressCategory.Default,
                Name            = "Coinbase"
            };

            WalletDao.Create(wallet);
            AddressDao.Create(rootAddress);

            GlobalWallet.Set(new ActiveWallet
            {
                Id           = wallet.Id,
                Name         = wallet.WalletName,
                RootXPrivKey = result.RootExtPrivKeyWif,
                RootXPubKey  = result.RootExtPubKeyWif
            });

            return(result);
        }
Пример #30
0
        protected async void OnWalletCreated(object sender, WalletInfo wallet)
        {
            await RefreshView(false, false).ContinueWith(t =>
            {
                if (wallets.Count == 1)
                {
                    RunOnUiThread(async delegate
                    {
                        if (await this.ShowConfirm("Configure Wallet", $"Do you want to make the wallet <b>{wallet.Provider}</b> - <b>{wallet.Value}</b> your default wallet?", "Yes", "No") == true)
                        {
                            UserPreferences.Default.PrimaryWalletId = wallet.Id;
                            itemsAdapter.NotifyDataSetChanged();
                        }

                        if (createOnly)
                        {
                            SetResult(Result.Ok);
                            Finish();
                        }
                    });
                }
            });
        }