Add taproot tests
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputFailureTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputFailureTests.cs
@@ -315,6 +315,27 @@ public class RegisterInputFailureTests
await arena.StopAsync(CancellationToken.None);
}
+ public async Task TaprootNotAllowed()
+ {
+ WabiSabiConfig cfg = new() { AllowP2trInputs = false };
+ var round = WabiSabiFactory.CreateRound(cfg);
+
+ using Key key = new();
+ var coin = WabiSabiFactory.CreateCoin(key, scriptPubKeyType: ScriptPubKeyType.TaprootBIP86);
+ var rpc = WabiSabiFactory.CreatePreconfiguredRpcClient(coin);
+ using Arena arena = await ArenaBuilder.From(cfg).With(rpc).CreateAndStartAsync(round);
+
+ var minAliceDeadline = DateTimeOffset.UtcNow + cfg.ConnectionConfirmationTimeout * 0.9;
+ var arenaClient = WabiSabiFactory.CreateArenaClient(arena);
+ var ownershipProof = WabiSabiFactory.CreateOwnershipProof(key, round.Id, scriptPubKeyType: ScriptPubKeyType.TaprootBIP86);
+
+ var ex = await Assert.ThrowsAsync<WabiSabiProtocolException>(
+ async () => await arenaClient.RegisterInputAsync(round.Id, coin.Outpoint, ownershipProof, CancellationToken.None));
+ Assert.Equal(WabiSabiProtocolErrorCode.ScriptNotAllowed, ex.ErrorCode);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task WrongScriptPubKeyInOwnershipProofAsync()
{

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputSuccessTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputSuccessTests.cs
@@ -125,4 +125,25 @@ public class RegisterInputSuccessTests
await arena.StopAsync(CancellationToken.None);
}
+
+ [Fact]
+ public async Task TaprootSuccessAsync()
+ {
+ WabiSabiConfig cfg = new() { AllowP2trInputs = true };
+ var round = WabiSabiFactory.CreateRound(cfg);
+
+ using Key key = new();
+ var coin = WabiSabiFactory.CreateCoin(key, scriptPubKeyType: ScriptPubKeyType.TaprootBIP86);
+ var rpc = WabiSabiFactory.CreatePreconfiguredRpcClient(coin);
+ using Arena arena = await ArenaBuilder.From(cfg).With(rpc).CreateAndStartAsync(round);
+
+ var minAliceDeadline = DateTimeOffset.UtcNow + cfg.ConnectionConfirmationTimeout * 0.9;
+ var arenaClient = WabiSabiFactory.CreateArenaClient(arena);
+ var ownershipProof = WabiSabiFactory.CreateOwnershipProof(key, round.Id, ScriptPubKeyType.TaprootBIP86);
+
+ var (resp, _) = await arenaClient.RegisterInputAsync(round.Id, coin.Outpoint, ownershipProof, CancellationToken.None);
+ AssertSingleAliceSuccessfullyRegistered(round, minAliceDeadline, resp);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterOutputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterOutputTests.cs
@@ -2,6 +2,7 @@ using NBitcoin;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using WalletWasabi.Helpers;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.WabiSabi.Backend;
using WalletWasabi.WabiSabi.Backend.Models;
@@ -29,6 +30,40 @@ public class RegisterOutputTests
await arena.StopAsync(CancellationToken.None);
}
+ [Fact]
+ public async Task TaprootSuccessAsync()
+ {
+ WabiSabiConfig cfg = new() { AllowP2trOutputs = true };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ round.SetPhase(Phase.OutputRegistration);
+ round.Alices.Add(WabiSabiFactory.CreateAlice(round));
+ using Arena arena = await ArenaBuilder.From(cfg).CreateAndStartAsync(round);
+
+ using Key privKey = new();
+ var req = WabiSabiFactory.CreateOutputRegistrationRequest(round, privKey.PubKey.GetScriptPubKey(ScriptPubKeyType.TaprootBIP86), Constants.P2trOutputVirtualSize);
+ await arena.RegisterOutputAsync(req, CancellationToken.None);
+ Assert.NotEmpty(round.Bobs);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
+ [Fact]
+ public async Task TaprootNotAllowedAsync()
+ {
+ WabiSabiConfig cfg = new() { AllowP2trOutputs = false };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ round.SetPhase(Phase.OutputRegistration);
+ round.Alices.Add(WabiSabiFactory.CreateAlice(round));
+ using Arena arena = await ArenaBuilder.From(cfg).CreateAndStartAsync(round);
+
+ using Key privKey = new();
+ var req = WabiSabiFactory.CreateOutputRegistrationRequest(round, privKey.PubKey.GetScriptPubKey(ScriptPubKeyType.TaprootBIP86), Constants.P2trOutputVirtualSize);
+ var ex = await Assert.ThrowsAsync<WabiSabiProtocolException>(async () => await arena.RegisterOutputAsync(req, CancellationToken.None));
+ Assert.Equal(WabiSabiProtocolErrorCode.ScriptNotAllowed, ex.ErrorCode);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task RoundNotFoundAsync()
{

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/SignTransactionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/SignTransactionTests.cs
@@ -35,6 +35,27 @@ public class SignTransactionTests
await arena.StopAsync(CancellationToken.None);
}
+ [Fact]
+ public async Task TaprootSuccessAsync()
+ {
+ WabiSabiConfig cfg = new() { AllowP2trInputs = true, AllowP2trOutputs = true };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ using Key key = new();
+ Alice alice = WabiSabiFactory.CreateAlice(key: key, round: round, scriptPubKeyType: ScriptPubKeyType.TaprootBIP86);
+ round.Alices.Add(alice);
+ round.CoinjoinState = round.AddInput(alice.Coin, alice.OwnershipProof, WabiSabiFactory.CreateCommitmentData(round.Id)).Finalize();
+ round.SetPhase(Phase.TransactionSigning);
+ using Arena arena = await ArenaBuilder.From(cfg).CreateAndStartAsync(round);
+
+ var aliceSignedCoinJoin = round.Assert<SigningState>().CreateUnsignedTransaction();
+ aliceSignedCoinJoin.Sign(key.GetBitcoinSecret(Network.Main), alice.Coin);
+
+ var req = new TransactionSignaturesRequest(round.Id, 0, aliceSignedCoinJoin.Inputs[0].WitScript);
+ await arena.SignTransactionAsync(req, CancellationToken.None);
+ Assert.True(round.Assert<SigningState>().IsFullySigned);
+ await arena.StopAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task RoundNotFoundAsync()
{

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -36,6 +36,12 @@ public class ArenaClientTests
await TestFullCoinjoinAsync(ScriptPubKeyType.Segwit, Constants.P2wpkhInputVirtualSize);
}
+ [Fact]
+ public async Task FullP2trCoinjoinTestAsync()
+ {
+ await TestFullCoinjoinAsync(ScriptPubKeyType.TaprootBIP86, Constants.P2trInputVirtualSize);
+ }
+
[Fact]
public async Task RemoveInputAsyncTestAsync()
{
@@ -138,7 +144,7 @@ public class ArenaClientTests
private async Task TestFullCoinjoinAsync(ScriptPubKeyType scriptPubKeyType, int inputVirtualSize)
{
- var config = new WabiSabiConfig { MaxInputCountByRound = 1 };
+ var config = new WabiSabiConfig { MaxInputCountByRound = 1, AllowP2trInputs = true, AllowP2trOutputs = true };
var round = WabiSabiFactory.CreateRound(WabiSabiFactory.CreateRoundParameters(config));
using var key = new Key();
var outpoint = BitcoinFactory.CreateOutPoint();

Add taproot tests