public void CanAdd() { var cjIdStore = new CoinJoinIdStore(); cjIdStore.TryAdd(uint256.One); Assert.True(cjIdStore.Contains(uint256.One)); cjIdStore.TryAdd(uint256.One); cjIdStore.TryAdd(uint256.One); Assert.Single(cjIdStore.GetCoinJoinIds); }
public async Task SuccessFromPreviousCoinJoinAsync() { WabiSabiConfig cfg = new(); var round = WabiSabiFactory.CreateRound(cfg); using Key key = new(); var coin = WabiSabiFactory.CreateCoin(key); var rpc = WabiSabiFactory.CreatePreconfiguredRpcClient(coin); var coinJoinIdStore = new CoinJoinIdStore(); coinJoinIdStore.TryAdd(coin.Outpoint.Hash); using Arena arena = await ArenaBuilder.From(cfg).With(rpc).With(coinJoinIdStore).CreateAndStartAsync(round); var minAliceDeadline = DateTimeOffset.UtcNow + cfg.ConnectionConfirmationTimeout * 0.9; var arenaClient = WabiSabiFactory.CreateArenaClient(arena); var ownershipProof = WabiSabiFactory.CreateOwnershipProof(key, round.Id); var(resp, _) = await arenaClient.RegisterInputAsync(round.Id, coin.Outpoint, ownershipProof, CancellationToken.None); AssertSingleAliceSuccessfullyRegistered(round, minAliceDeadline, resp); var myAlice = Assert.Single(round.Alices); Assert.True(myAlice.IsPayingZeroCoordinationFee); await arena.StopAsync(CancellationToken.None); }
private void Arena_CoinJoinBroadcast(object?sender, Transaction transaction) { LastSuccessfulCoinJoinTime = DateTimeOffset.UtcNow; CoinJoinIdStore.TryAdd(transaction.GetHash()); var coinJoinScriptStoreFilePath = Parameters.CoinJoinScriptStoreFilePath; try { File.AppendAllLines(coinJoinScriptStoreFilePath, transaction.Outputs.Select(x => x.ScriptPubKey.ToHex())); } catch (Exception ex) { Logger.LogError($"Could not write file {coinJoinScriptStoreFilePath}.", ex); } }