Adding more inputs and outputs
MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -228,9 +228,14 @@ namespace WalletWasabi.Backend.Controllers
return BadRequest("Provided input is neither confirmed, nor is from an unconfirmed coinjoin.");
}
- // Check if mempool would accept a fake transaction created with the registered inputs.
+ // Check if mempool would accept a fake transaction created with all of the registered inputs plus the new input.
// This will catch ascendant/descendant count and size limits for example.
- var result = await RpcClient.TestMempoolAcceptAsync(new[] { new Coin(inputProof.Input, getTxOutResponse.TxOut) });
+
+ var currentAlices = round.GetAlicesBy(AliceState.InputsRegistered).ToArray();
+ var coinsToTest = currentAlices.SelectMany(alice => alice.Inputs).ToList();
+ coinsToTest.Add(new Coin(inputProof.Input, getTxOutResponse.TxOut));
+
+ var result = await RpcClient.TestMempoolAcceptAsync(coinsToTest, fakeOutputsCount: currentAlices.Length * 2);
if (!result.accept)
{
return BadRequest($"Provided input is from an unconfirmed coinjoin, but a limit is reached: {result.rejectReason}");

MODIFY
WalletWasabi/Extensions/RPCClientExtensions.cs
WalletWasabi/Extensions/RPCClientExtensions.cs
@@ -214,14 +214,17 @@ namespace NBitcoin.RPC
return newEstimations;
}
- public static async Task<(bool accept, string rejectReason)> TestMempoolAcceptAsync(this IRPCClient rpc, IEnumerable<Coin> coins)
+ public static async Task<(bool accept, string rejectReason)> TestMempoolAcceptAsync(this IRPCClient rpc, IEnumerable<Coin> coins, int fakeOutputsCount = 1)
{
// 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.AddRange(coins.Select(coin => new TxIn(coin.Outpoint)));
Money fakeOutputValue = NBitcoinHelpers.TakeAReasonableFee(coins.Sum(coin => coin.TxOut.Value));
+ for (int i = 0; i < fakeOutputsCount; i++)
+ {
fakeTransaction.Outputs.Add(fakeOutputValue, new Key());
+ }
MempoolAcceptResult testMempoolAcceptResult = await rpc.TestMempoolAcceptAsync(fakeTransaction, allowHighFees: true);
if (!testMempoolAcceptResult.IsAllowed)

Adding more inputs and outputs