public static ExternalServices CreateFromFullNode(IRepository repository, Tracker tracker, TumblingState tumblingState) { var minimumRate = tumblingState.NodeSettings.MinRelayTxFeeRate; var service = new ExternalServices(); // On regtest the estimatefee always fails if (tumblingState.TumblerNetwork == Network.RegTest) { service.FeeService = new FullNodeFeeService(tumblingState.WalletFeePolicy) { MinimumFeeRate = minimumRate, FallBackFeeRate = new FeeRate(Money.Satoshis(50), 1) }; } else // On test and mainnet fee estimation should just fail, not fall back to fixed fee { service.FeeService = new FullNodeFeeService(tumblingState.WalletFeePolicy) { MinimumFeeRate = minimumRate }; } var cache = new FullNodeWalletCache(tumblingState); service.WalletService = new FullNodeWalletService(tumblingState); service.BroadcastService = new FullNodeBroadcastService(cache, repository, tumblingState); service.BlockExplorerService = new FullNodeBlockExplorerService(cache, tumblingState); service.TrustedBroadcastService = new FullNodeTrustedBroadcastService(service.BroadcastService, service.BlockExplorerService, repository, cache, tracker, tumblingState) { // BlockExplorer will already track the addresses, since they used a shared bitcoind, no need of tracking again (this would overwrite labels) TrackPreviousScriptPubKey = false }; return(service); }
public FullNodeTumblerClientConfiguration(TumblingState tumblingState, bool onlyMonitor, bool connectionTest = false, bool useProxy = true) { this.tumblingState = tumblingState ?? throw new ArgumentNullException(nameof(tumblingState)); Network = tumblingState.TumblerNetwork ?? throw new ArgumentNullException(nameof(tumblingState.TumblerNetwork)); Logs.LogDir = this.tumblingState.NodeSettings.DataDir; if (!onlyMonitor || connectionTest) { TorPath = "tor"; Cooperative = true; AllowInsecure = true; if (tumblingState.TumblerUri != null) { TumblerServer = new TumblerUrlBuilder(this.tumblingState.TumblerUri); if (TumblerServer == null) { throw new ConfigException("Tumbler server is not configured"); } } if (useProxy) { AliceConnectionSettings = new SocksConnectionSettings() { Proxy = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050) }; BobConnectionSettings = new SocksConnectionSettings() { Proxy = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050) }; } else { // This mode is only for unit/integration tests, as it allows testing with latency introduced by Tor AliceConnectionSettings = new ConnectionSettingsBase(); BobConnectionSettings = new ConnectionSettingsBase(); } if (connectionTest) { return; } } OnlyMonitor = onlyMonitor; Logs.Configuration.LogInformation("Network: " + Network); DataDir = GetTumbleBitDataDir(this.tumblingState.NodeSettings.DataDir); Logs.Configuration.LogInformation("Data directory set to " + DataDir); DBreezeRepository = new DBreezeRepository(Path.Combine(DataDir, "db2")); Tracker = new Tracker(DBreezeRepository, Network); // Need to use our own ExternalServices implementations to remove RPC dependency Services = ExternalServices.CreateFromFullNode(DBreezeRepository, Tracker, this.tumblingState); }
public FullNodeTumblerClientConfiguration(TumblingState tumblingState, bool onlyMonitor, bool connectionTest = false) { this.tumblingState = tumblingState ?? throw new ArgumentNullException(nameof(tumblingState)); Network = tumblingState.TumblerNetwork ?? throw new ArgumentNullException(nameof(tumblingState.TumblerNetwork)); if (!onlyMonitor || connectionTest) { TorPath = "tor"; Cooperative = true; AllowInsecure = true; if (tumblingState.TumblerUri != null) { TumblerServer = new TumblerUrlBuilder(this.tumblingState.TumblerUri); if (TumblerServer == null) { throw new ConfigException("Tumbler server is not configured"); } } AliceConnectionSettings = new SocksConnectionSettings() { Proxy = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050) }; // TODO: Need to check what recommended configuration is to prevent Alice/Bob linkage BobConnectionSettings = new SocksConnectionSettings() { Proxy = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050) }; if (connectionTest) { return; } } OnlyMonitor = onlyMonitor; Logs.Configuration.LogInformation("Network: " + Network); DataDir = Path.Combine(this.tumblingState.NodeSettings.DataDir, "TumbleBit"); Logs.Configuration.LogInformation("Data directory set to " + DataDir); DBreezeRepository = new DBreezeRepository(Path.Combine(DataDir, "db2")); Tracker = new Tracker(DBreezeRepository, Network); // Need to use our own ExternalServices implementations to remove RPC dependency Services = ExternalServices.CreateFromFullNode(DBreezeRepository, Tracker, this.tumblingState); }
public static ExternalServices CreateUsingFullNode(IRepository repository, Tracker tracker, TumblingState tumblingState) { FeeRate minimumRate = new FeeRate(MempoolValidator.MinRelayTxFee.FeePerK); ExternalServices service = new ExternalServices(); service.FeeService = new FullNodeFeeService() { MinimumFeeRate = minimumRate }; // on regtest the estimatefee always fails if (tumblingState.TumblerNetwork == Network.RegTest) { service.FeeService = new FullNodeFeeService() { MinimumFeeRate = minimumRate, FallBackFeeRate = new FeeRate(Money.Satoshis(50), 1) }; } // TODO: These ultimately need to be brought in from the tumblebit client UI string dummyWalletName = ""; string dummyAccountName = ""; FullNodeWalletCache cache = new FullNodeWalletCache(repository, tumblingState); service.WalletService = new FullNodeWalletService(tumblingState, dummyWalletName, dummyAccountName); service.BroadcastService = new FullNodeBroadcastService(cache, repository, tumblingState); service.BlockExplorerService = new FullNodeBlockExplorerService(cache, repository, tumblingState); service.TrustedBroadcastService = new FullNodeTrustedBroadcastService(service.BroadcastService, service.BlockExplorerService, repository, cache, tracker, tumblingState) { // BlockExplorer will already track the addresses, since they used a shared bitcoind, no need of tracking again (this would overwrite labels) TrackPreviousScriptPubKey = false }; return(service); }