示例#1
0
        private IActionResult ConfirmAddresses(WalletSetupViewModel vm, DerivationSchemeSettings strategy)
        {
            vm.DerivationScheme = strategy.AccountDerivation.ToString();
            var deposit = new KeyPathTemplates(null).GetKeyPathTemplate(DerivationFeature.Deposit);

            if (!string.IsNullOrEmpty(vm.DerivationScheme))
            {
                var line = strategy.AccountDerivation.GetLineFor(deposit);

                for (uint i = 0; i < 10; i++)
                {
                    var keyPath       = deposit.GetKeyPath(i);
                    var rootedKeyPath = vm.GetAccountKeypath()?.Derive(keyPath);
                    var derivation    = line.Derive(i);
                    var address       = strategy.Network.NBXplorerNetwork.CreateAddress(strategy.AccountDerivation,
                                                                                        line.KeyPathTemplate.GetKeyPath(i),
                                                                                        derivation.ScriptPubKey).ToString();
                    vm.AddressSamples.Add((keyPath.ToString(), address, rootedKeyPath));
                }
            }

            vm.Confirmation = true;
            ModelState.Remove(nameof(vm.Config)); // Remove the cached value

            return(View("ImportWallet/ConfirmAddresses", vm));
        }
示例#2
0
        private Dictionary <string, string> GenerateAddresses(DerivationStrategyBase derivation,
                                                              NBXplorerNetwork network)
        {
            var result  = new Dictionary <string, string>();
            var deposit = new KeyPathTemplates(null).GetKeyPathTemplate(DerivationFeature.Deposit);

            var line = derivation.GetLineFor(deposit);

            for (int i = 0; i < 20; i++)
            {
                result.Add(deposit.GetKeyPath((uint)i).ToString(),
                           line.Derive((uint)i).ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork).ToString());
            }

            return(result);
        }