public void CanGenerateAddress() { using (var server = TumblerServerTester.Create()) { var key = new ExtKey().GetWif(Network.RegTest); var w = new ClientDestinationWallet(key.Neuter(), new KeyPath("0/1"), server.ClientRuntime.Repository, server.ClientRuntime.Network); var k1 = w.GetNewDestination(); var k2 = w.GetNewDestination(); Assert.Equal(new KeyPath("0/1/0"), w.GetKeyPath(k1)); Assert.Equal(new KeyPath("0/1/1"), w.GetKeyPath(k2)); Assert.Null(w.GetKeyPath(new Key().ScriptPubKey)); var wrpc = new RPCDestinationWallet(server.AliceNode.CreateRPCClient()); k1 = wrpc.GetNewDestination(); k2 = wrpc.GetNewDestination(); Assert.Equal(new KeyPath("0'/0'/1'"), wrpc.GetKeyPath(k1)); Assert.Equal(new KeyPath("0'/0'/2'"), wrpc.GetKeyPath(k2)); Assert.Null(w.GetKeyPath(new Key().ScriptPubKey)); } }
//public RPCArgs RPCArgs //{ // get; set; //} = new RPCArgs(); public FullNodeTumblerClientConfiguration LoadArgs(String[] args) { ConfigurationFile = args.Where(a => a.StartsWith("-conf=", StringComparison.Ordinal)).Select(a => a.Substring("-conf=".Length).Replace("\"", "")).FirstOrDefault(); DataDir = args.Where(a => a.StartsWith("-datadir=", StringComparison.Ordinal)).Select(a => a.Substring("-datadir=".Length).Replace("\"", "")).FirstOrDefault(); if (DataDir != null && ConfigurationFile != null) { var isRelativePath = Path.GetFullPath(ConfigurationFile).Length > ConfigurationFile.Length; if (isRelativePath) { ConfigurationFile = Path.Combine(DataDir, ConfigurationFile); } } Network = args.Contains("-testnet", StringComparer.OrdinalIgnoreCase) ? Network.TestNet : args.Contains("-regtest", StringComparer.OrdinalIgnoreCase) ? Network.RegTest : Network.Main; if (ConfigurationFile != null) { AssetConfigFileExists(); var configTemp = TextFileConfiguration.Parse(File.ReadAllText(ConfigurationFile)); Network = configTemp.GetOrDefault <bool>("testnet", false) ? Network.TestNet : configTemp.GetOrDefault <bool>("regtest", false) ? Network.RegTest : Network.Main; } if (DataDir == null) { DataDir = DefaultDataDirectory.GetDefaultDirectory("NTumbleBit", Network); } if (ConfigurationFile == null) { ConfigurationFile = GetDefaultConfigurationFile(DataDir, Network); } Logs.Configuration.LogInformation("Network: " + Network); Logs.Configuration.LogInformation("Data directory set to " + DataDir); Logs.Configuration.LogInformation("Configuration file set to " + ConfigurationFile); if (!Directory.Exists(DataDir)) { throw new ConfigurationException("Data directory does not exists"); } var consoleConfig = new TextFileConfiguration(args); var config = TextFileConfiguration.Parse(File.ReadAllText(ConfigurationFile)); consoleConfig.MergeInto(config, true); config.AddAlias("server", "tumbler.server"); OnlyMonitor = config.GetOrDefault <bool>("onlymonitor", false); Cooperative = config.GetOrDefault <bool>("cooperative", true); TumblerServer = config.GetOrDefault("tumbler.server", null as TumblerUrlBuilder); TorPath = config.GetOrDefault <string>("torpath", "tor"); //RPCArgs = RPCArgs.Parse(config, Network); if (!OnlyMonitor && TumblerServer == null) { throw new ConfigException("tumbler.server not configured"); } try { var key = config.GetOrDefault("outputwallet.extpubkey", null as string); if (key != null) { OutputWallet.RootKey = new BitcoinExtPubKey(key, Network); } } catch { throw new ConfigException("outputwallet.extpubkey is not configured correctly"); } OutputWallet.KeyPath = new KeyPath("0"); string keyPathString = config.GetOrDefault("outputwallet.keypath", null as string); if (keyPathString != null) { try { OutputWallet.KeyPath = new KeyPath(keyPathString); } catch { throw new ConfigException("outputwallet.keypath is not configured correctly"); } } if (OutputWallet.KeyPath.ToString().Contains("'")) { throw new ConfigException("outputwallet.keypath should not contain any hardened derivation"); } if (OutputWallet.RootKey != null && OutputWallet.RootKey.Network != Network) { throw new ConfigException("outputwallet.extpubkey is pointing an incorrect network"); } OutputWallet.RPCArgs = RPCArgs.Parse(config, Network, "outputwallet"); AliceConnectionSettings = ConnectionSettingsBase.ParseConnectionSettings("alice", config); BobConnectionSettings = ConnectionSettingsBase.ParseConnectionSettings("bob", config); AllowInsecure = config.GetOrDefault <bool>("allowinsecure", IsTest(Network)); //RPCClient rpc = null; //try //{ // rpc = RPCArgs.ConfigureRPCClient(Network); //} //catch //{ // throw new ConfigException("Please, fix rpc settings in " + ConfigurationFile); //} DBreezeRepository = new DBreezeRepository(Path.Combine(DataDir, "db2")); Tracker = new Tracker(DBreezeRepository, Network); Services = Breeze.TumbleBit.Client.ExternalServices.CreateUsingFullNode(DBreezeRepository, Tracker, this.tumblingState); if (OutputWallet.RootKey != null && OutputWallet.KeyPath != null) { DestinationWallet = new ClientDestinationWallet(OutputWallet.RootKey, OutputWallet.KeyPath, DBreezeRepository, Network); } else if (OutputWallet.RPCArgs != null) { try { DestinationWallet = new RPCDestinationWallet(OutputWallet.RPCArgs.ConfigureRPCClient(Network)); } catch { throw new ConfigException("Please, fix outputwallet rpc settings in " + ConfigurationFile); } } else { throw new ConfigException("Missing configuration for outputwallet"); } return(this); }