private async Task ManageStakePoolsActionAsync()
        {
            var prevConfiguredStakepoolCount = ConfiguredStakePools.Count;

            // Open dialog that downloads stakepool listing and lets user enter their api key.
            var shell  = (ShellViewModel)ViewModelLocator.ShellViewModel;
            var dialog = new ManageStakePoolsDialogViewModel(shell);

            shell.ShowDialog(dialog);
            await dialog.NotifyCompletionSource.Task; // Wait until dialog is hidden

            await App.Current.Dispatcher.InvokeAsync(() =>
            {
                foreach (var configuredPool in dialog.ConfiguredPools)
                {
                    var poolInfo       = configuredPool.Item1;
                    var poolUserConfig = configuredPool.Item2;

                    if (!ConfiguredStakePools.OfType <StakePoolSelection>().Where(p => p.PoolInfo.Uri.Host == poolInfo.Uri.Host).Any())
                    {
                        var stakePoolSelection = new StakePoolSelection(poolInfo, poolUserConfig.ApiKey,
                                                                        Hexadecimal.Decode(poolUserConfig.MultisigVoteScript));
                        ConfiguredStakePools.Add(stakePoolSelection);
                        RaisePropertyChanged(nameof(VotePreferencesVisibility));
                        SelectedStakePool = stakePoolSelection;
                    }
                }
            });

            if (prevConfiguredStakepoolCount != ConfiguredStakePools.Count)
            {
                await UpdateStakepoolVotePreferences();
            }
        }
예제 #2
0
        public static void DecodeAndValidateUserInputTest(string seed, string pgpSeed)
        {
            var decodedSeed    = WalletSeed.DecodeAndValidateUserInput(pgpSeed, PgpWordList);
            var decodedSeedHex = Hexadecimal.Decode(seed);

            Assert.Equal(decodedSeedHex, decodedSeed);
        }
예제 #3
0
        public static void ValidDecodings(string hexEncoding, string pgpWordListEncoding)
        {
            var words         = pgpWordListEncoding.Split();
            var expectedBytes = Hexadecimal.Decode(hexEncoding);

            var decodedBytes = PgpWordList.Decode(words);

            Assert.Equal(expectedBytes, decodedBytes);
        }
예제 #4
0
        public static void PositiveHexTests(string decodedAsHexString, string encoded)
        {
            var decoded = Hexadecimal.Decode(decodedAsHexString);

            var encodeResult = Base58.Encode(decoded);

            Assert.Equal(encoded, encodeResult);

            var decodeResult = Base58.Decode(encoded);

            Assert.Equal(decoded, decodeResult);
        }
예제 #5
0
        public static void DecodeIsCaseInsensitive(string hexEncoding, string pgpWordListEncoding)
        {
            var expectedBytes = Hexadecimal.Decode(hexEncoding);

            var upperCaseWords   = pgpWordListEncoding.ToUpper().Split();
            var decodedUpperCase = PgpWordList.Decode(upperCaseWords);

            Assert.Equal(expectedBytes, decodedUpperCase);

            var lowerCaseWords   = pgpWordListEncoding.ToLower().Split();
            var decodedLowerCase = PgpWordList.Decode(lowerCaseWords);

            Assert.Equal(expectedBytes, decodedLowerCase);
        }
예제 #6
0
            public OutputScript BuildOutputScript()
            {
                switch (OutputType)
                {
                case Kind.Address:
                    var address = Address.Decode(Destination);
                    return(address.BuildScript());

                case Kind.Script:
                    return(new OutputScript.Unrecognized(Hexadecimal.Decode(Destination)));

                default:
                    throw new Exception($"Unknown pending output kind {OutputType}");
                }
            }
        public async Task RunActivityAsync()
        {
            var poolListing = await PoolListApi.QueryStakePoolInfoAsync(_httpClient, _jsonSerializer);

            AvailablePools.AddRange(poolListing
                                    .Select(p => p.Value)
                                    .Where(p => p.ApiEnabled)
                                    .Where(p => p.Uri.Scheme == "https")
                                    .Where(p => p.Network == App.Current.ActiveNetwork.Name)
                                    .Where(p => p.SupportedApiVersions.Where(PoolApiClient.IsSupportedApiVersion).Any())
                                    .OrderBy(p => p.Uri.Host));

            if (File.Exists(_configPath))
            {
                var config = await ReadConfig(_configPath);

                await App.Current.Dispatcher.InvokeAsync(() =>
                {
                    foreach (var entry in config.Entries)
                    {
                        var entryInfo = AvailablePools.Where(p => p.Uri.Host == entry.Host).FirstOrDefault();
                        if (entryInfo == null)
                        {
                            continue;
                        }
                        var stakePoolSelection = new StakePoolSelection(entryInfo, entry.ApiKey, Hexadecimal.Decode(entry.MultisigVoteScript));
                        ConfiguredStakePools.Add(stakePoolSelection);
                        RaisePropertyChanged(nameof(VotePreferencesVisibility));

                        // If only one pool is saved, use this as the default.
                        if (config.Entries.Length == 1)
                        {
                            SelectedStakePool = stakePoolSelection;
                        }
                    }
                });
            }

            await App.Current.Dispatcher.InvokeAsync(() =>
            {
                ManageStakePools.Executable = true;
                CommandManager.InvalidateRequerySuggested();
            });
        }