Ejemplo n.º 1
0
        protected override async Task Submit(ButtonRow button)
        {
            IsBusy = true;

            var password = _password?.Edit?.Text;

            if (!WalletApp.IsCoreAccountUnlocked)
            {
                if (!await WalletApp.UnlockCoreAccount(password))
                {
                    await ErrorAsync("PasswordWrong");

                    IsBusy = false;

                    return;
                }
            }

            var chainId     = int.Parse(_chainIdText.Edit.Text);
            var coreAccount = WalletApp.CurrentCoreAccount;
            var secretKey   = await PassphraseSecretKeyInfo.NewPassphraseSecretKey(chainId, $"{Hex.ToString(coreAccount.RawData)}.{coreAccount.AccountId}");

            var key = await Task.Run(() => Key.GenerateEd25519(secretKey.SecretHash));

            var encryption = await Task.Run(() => Encryption.GenerateAes256(key.Data, _derivedPassword));

            _keyView.Update(key);

            if (!await ConfirmAsync("AuthorizeConfirm"))
            {
                IsBusy = false;
                return;
            }

            (var response, var publicKey) = await WalletApp.JoinChain(chainId, 0, key.PublicKey, password);

            if (response.TransactionResult == TransactionResultTypes.Ok || response.TransactionResult == TransactionResultTypes.AlreadyJoined)
            {
                var derivedKey = new DerivedKey(coreAccount.AccountId, chainId, publicKey.KeyIndex, encryption);

                var hex = Hex.ToCrcString(derivedKey.ToByteArray());
                _export.Edit.Text = hex;
                UIApp.CopyToClipboard(hex);

                await MessageAsync("SuccessDerived");
            }
            else
            {
                await ErrorTextAsync(response.GetErrorMessage());
            }

            IsBusy = false;
        }
Ejemplo n.º 2
0
        async Task Unlock(ButtonRow button)
        {
            IsBusy = true;
            var pw      = _unlockPassword?.Edit?.Text;
            var success = await WalletApp.UnlockCoreAccount(pw);

            IsBusy = false;

            if (!success)
            {
                await MessageAsync("UnlockFailed");
            }
        }