/// <inheritdoc /> public void FinishTumbling() { this.logger.LogDebug($"The tumbling process is wrapping up. Current height is {this.chain.Tip.Height}."); this.blockReceiver.Dispose(); this.tumblingState.Delete(); this.tumblingState = null; }
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 TumbleBitManager(ILoggerFactory loggerFactory, IWalletManager walletManager, ConcurrentChain chain, Network network, Signals signals) { this.walletManager = walletManager; this.chain = chain; this.signals = signals; this.network = network; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.tumblingState = new TumblingState(loggerFactory, this.chain, this.walletManager, this.network); }
public TumbleBitManager(ILoggerFactory loggerFactory, IWalletManager walletManager, ConcurrentChain chain, Network network, Signals signals) { this.lastCycleStarted = 0; this.walletManager = walletManager; this.chain = chain; this.signals = signals; this.network = network; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); // load the persisted tumbling state this.tumblingState = TumblingState.LoadState(); }
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 TumbleBitManager(ILoggerFactory loggerFactory, WalletManager walletManager, WatchOnlyWalletManager watchOnlyWalletManager, ConcurrentChain chain, Network network, Signals signals, WalletTransactionHandler walletTransactionHandler, BlockStoreManager blockStoreManager, MempoolManager mempoolManager, WalletSyncManager walletSyncManager) { this.walletManager = walletManager; this.watchOnlyWalletManager = watchOnlyWalletManager; this.walletSyncManager = walletSyncManager; this.walletTransactionHandler = walletTransactionHandler; this.chain = chain; this.signals = signals; this.network = network; this.loggerFactory = loggerFactory; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.blockStoreManager = blockStoreManager; this.mempoolManager = mempoolManager; this.tumblingState = new TumblingState(loggerFactory, this.chain, this.walletManager, this.watchOnlyWalletManager, this.network, this.walletTransactionHandler, this.blockStoreManager, this.mempoolManager, this.walletSyncManager); }
/// <inheritdoc /> public void LoadStateFromMemory() { var stateFilePath = GetStateFilePath(); if (!File.Exists(stateFilePath)) { return; } // load the file from the local system TumblingState savedState = JsonConvert.DeserializeObject <TumblingState>(File.ReadAllText(stateFilePath)); this.OriginWalletName = savedState.OriginWalletName; this.DestinationWalletName = savedState.DestinationWalletName; this.LastBlockReceivedHeight = savedState.LastBlockReceivedHeight; this.TumblerParameters = savedState.TumblerParameters; this.TumblerUri = savedState.TumblerUri; this.TumblerNetwork = savedState.TumblerNetwork; }
/// <inheritdoc /> public async Task <ClassicTumblerParameters> ConnectToTumblerAsync(Uri serverAddress) { this.tumblerService = new TumblerService(serverAddress); this.TumblerParameters = await this.tumblerService.GetClassicTumblerParametersAsync(); if (this.TumblerParameters.Network != this.network) { throw new Exception($"The tumbler is on network {this.TumblerParameters.Network} while the wallet is on network {this.network}."); } if (this.tumblingState == null) { this.tumblingState = new TumblingState(); } // update and save the state this.tumblingState.TumblerParameters = this.TumblerParameters; this.tumblingState.Save(); return(this.TumblerParameters); }
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); }
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) { this.tumblingState = tumblingState; }
public FullNodeDestinationWallet(TumblingState tumblingState) { this.tumblingState = tumblingState ?? throw new ArgumentNullException(nameof(tumblingState)); }