Add `CreateTemplateTransaction`
MODIFY
WalletWasabi.Tests/UnitTests/TestWallet.cs
WalletWasabi.Tests/UnitTests/TestWallet.cs
@@ -41,7 +41,7 @@ public class TestWallet : IKeyChain, IDestinationProvider, IDisposable
}
}
- public Transaction CreateSelfTransfer(FeeRate feeRate)
+ public (Transaction, Coin) CreateTemplateTransaction()
{
ThrowIfDisposed();
var biggestUtxo = Utxos.MaxBy(x => x.Amount);
@@ -53,7 +53,14 @@ public class TestWallet : IKeyChain, IDestinationProvider, IDisposable
var tx = Rpc.Network.CreateTransaction();
tx.Inputs.Add(biggestUtxo.Outpoint);
- tx.Outputs.Add(biggestUtxo.Amount - feeRate.GetFee(Constants.P2wpkhOutputSizeInBytes), Address);
+ return (tx, biggestUtxo);
+ }
+
+ public Transaction CreateSelfTransfer(FeeRate feeRate)
+ {
+ ThrowIfDisposed();
+ var (tx, spendingCoin) = CreateTemplateTransaction();
+ tx.Outputs.Add(spendingCoin.Amount - feeRate.GetFee(Constants.P2wpkhOutputSizeInBytes), Address);
return tx;
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/Participant.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/Participant.cs
@@ -9,6 +9,7 @@ using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Models;
using WalletWasabi.WabiSabi.Client;
+using WalletWasabi.WabiSabi.Models;
using WalletWasabi.WebClients.Wasabi;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Integration;
@@ -38,9 +39,8 @@ internal class Participant: IDisposable
{
ThrowIfDisposed();
var feeRate = new FeeRate(4.0m);
- var splitTx = Wallet.CreateSelfTransfer(FeeRate.Zero);
- var satoshisAvailable = splitTx.Outputs[0].Value.Satoshi;
- splitTx.Outputs.Clear();
+ var (splitTx, spendingCoin) = Wallet.CreateTemplateTransaction();
+ var availableAmount = spendingCoin.EffectiveValue(feeRate, CoordinationFeeRate.Zero);
var rnd = new Random(seed);
double NextNotTooSmall() => 0.00001 + (rnd.NextDouble() * 0.99999);
@@ -54,7 +54,7 @@ internal class Participant: IDisposable
var amounts = sampling
.Zip(sampling.Skip(1), (x, y) => y - x)
- .Select(x => x * satoshisAvailable)
+ .Select(x => x * availableAmount.Satoshi)
.Select(x => Money.Satoshis((long)x));
var scriptPubKey = Wallet.ScriptPubKey;

Add `CreateTemplateTransaction`