Improve Alice removal
MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -222,7 +222,7 @@ namespace WalletWasabi.Backend.Controllers
// Check if mempool would accept a fake transaction created with the registered inputs.
// This will catch ascendant/descendant count and size limits for example.
- var result = await RpcClient.TestMempoolAcceptAsync(new Coin(inputProof.Input.ToOutPoint(), getTxOutResponse.TxOut));
+ var result = await RpcClient.TestMempoolAcceptAsync(new[] { new Coin(inputProof.Input.ToOutPoint(), getTxOutResponse.TxOut) });
if (!result.accept)
{

MODIFY
WalletWasabi/Extensions/RPCClientExtensions.cs
WalletWasabi/Extensions/RPCClientExtensions.cs
@@ -182,13 +182,13 @@ namespace NBitcoin.RPC
}
/// <returns>(allowed, reject-reason)</returns>
- public static async Task<(bool accept, string rejectReason)> TestMempoolAcceptAsync(this RPCClient rpc, Coin coin)
+ public static async Task<(bool accept, string rejectReason)> TestMempoolAcceptAsync(this RPCClient rpc, IEnumerable<Coin> coins)
{
// Check if mempool would accept a fake transaction created with the registered inputs.
// This will catch ascendant/descendant count and size limits for example.
var fakeTransaction = rpc.Network.CreateTransaction();
- fakeTransaction.Inputs.Add(new TxIn(coin.Outpoint));
- Money fakeOutputValue = NBitcoinHelpers.TakeAReasonableFee(coin.TxOut.Value);
+ fakeTransaction.Inputs.AddRange(coins.Select(coin=> new TxIn(coin.Outpoint)));
+ Money fakeOutputValue = NBitcoinHelpers.TakeAReasonableFee(coins.Sum(coin=>coin.TxOut.Value));
fakeTransaction.Outputs.Add(fakeOutputValue, new Key());
MempoolAcceptResult testMempoolAcceptResult = await rpc.TestMempoolAcceptAsync(fakeTransaction, allowHighFees: true);

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
@@ -994,19 +994,25 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
throw new InvalidOperationException("Removing Alice is only allowed in InputRegistration and ConnectionConfirmation phases.");
}
+ var checkingTasks = new List<(Alice alice, Task<(bool accepted, string reason)> task)>();
+ var batch = RpcClient.PrepareBatch();
foreach (Alice alice in Alices)
- {
- foreach (Coin input in alice.Inputs)
{
// Check if mempool would accept a fake transaction created with the registered inputs.
// This will catch ascendant/descendant count and size limits for example.
- var result = await RpcClient.TestMempoolAcceptAsync(input);
+ checkingTasks.Add( (alice, batch.TestMempoolAcceptAsync(alice.Inputs)) );
+ }
+ var waiting = Task.WhenAll(checkingTasks.Select(t=>t.task));
+ await batch.SendBatchAsync();
+ await waiting;
- if (!result.accept)
+ foreach(var t in checkingTasks)
{
- alicesRemoved.Add(alice);
- Alices.Remove(alice);
- }
+ var result = await t.task;
+ if(!result.accepted)
+ {
+ alicesRemoved.Add(t.alice);
+ Alices.Remove(t.alice);
}
}
}

Improve Alice removal