Example #1
0
        private async Task ContinueAsync(Key key, IList <byte> localPassword)
        {
            var response = await TonService.SendAsync(new ExportKey(new InputKeyRegular(key, localPassword)));

            if (response is ExportedKey exportedKey)
            {
                var indices = new List <int>();
                var random  = new Random();

                while (indices.Count < 3)
                {
                    var next = random.Next(0, 24);
                    if (!indices.Contains(next))
                    {
                        indices.Add(next);
                    }
                }

                indices.Sort();

                TonService.SetCreationState(new WalletCreationState
                {
                    LocalPassword = localPassword,
                    Key           = key,
                    WordList      = exportedKey.WordList,
                    Indices       = indices
                });

                NavigationService.Navigate(typeof(WalletInfoPage), WalletInfoState.Created);
            }
        }
Example #2
0
        private async void DeleteExecute()
        {
            var confirm = await TLMessageDialog.ShowAsync(Strings.Resources.WalletDeleteInfo, Strings.Resources.WalletDeleteTitle, Strings.Resources.Delete, Strings.Resources.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            TonService.CleanUp();
            NavigationService.Navigate(typeof(WalletCreatePage));
        }
Example #3
0
        private async Task ContinueAsync(IList <byte> localPassword, IList <byte> salt)
        {
            var response = await TonService.SendAsync(new CreateNewKey(localPassword, new byte[0], salt));

            if (response is Key key)
            {
                await ContinueAsync(key, localPassword);
            }
            else if (response is Error error)
            {
                await TLMessageDialog.ShowAsync(error.Message, error.Code.ToString(), Strings.Resources.OK);
            }
        }
Example #4
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            state.TryGet("public_key", out string publicKey);
            state.TryGet("secret", out IList <byte> secret);
            state.TryGet("local_password", out IList <byte> localPassword);

            state.TryGet("address", out string address);
            state.TryGet("amount", out long amount);
            state.TryGet("comment", out string comment);

            IList <byte> message;

            if (string.IsNullOrEmpty(comment))
            {
                message = new byte[0];
            }
            else
            {
                message = Encoding.UTF8.GetBytes(comment.Substring(0, Math.Min(128, comment.Length)));
            }

            var sender    = TonService.Execute(new WalletGetAccountAddress(new WalletInitialAccountState(publicKey))) as AccountAddress;
            var recipient = new AccountAddress(address);

            var privateKey = new InputKeyRegular(new Key(publicKey, secret), localPassword);

            var response = await TonService.SendAsync(new GenericSendGrams(privateKey, sender, recipient, amount, 0, true, message));

            if (response is SendGramsResult result)
            {
                var parameters = new Dictionary <string, object>
                {
                    { "amount", amount }
                };

                NavigationService.Navigate(typeof(WalletInfoPage), WalletInfoState.Sent, parameters);
            }
            else if (response is Error error)
            {
                await TLMessageDialog.ShowAsync(error.Message, error.Code.ToString(), Strings.Resources.OK);
            }
        }