Update NBitcoin obsolate transactionbuilder creation
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -2021,14 +2021,14 @@ namespace WalletWasabi.Tests
var partSignedCj1 = Transaction.Parse(unsignedCoinJoin.ToHex(), network);
var partSignedCj2 = Transaction.Parse(unsignedCoinJoin.ToHex(), network);
- var builder = new TransactionBuilder();
+ var builder = Network.RegTest.CreateTransactionBuilder();
partSignedCj1 = builder
.ContinueToBuild(partSignedCj1)
.AddKeys(key1)
.AddCoins(new Coin(tx1, input1.N))
.BuildTransaction(true);
- builder = new TransactionBuilder();
+ builder = Network.RegTest.CreateTransactionBuilder();
partSignedCj2 = builder
.ContinueToBuild(partSignedCj2)
.AddKeys(key2)
@@ -2355,7 +2355,7 @@ namespace WalletWasabi.Tests
foreach (var user in users)
{
var partSignedCj = Transaction.Parse(unsignedCoinJoin.ToHex(), network);
- partSignedCj = new TransactionBuilder()
+ partSignedCj = Network.RegTest.CreateTransactionBuilder()
.ContinueToBuild(partSignedCj)
.AddKeys(user.userInputData.Select(x => x.key).ToArray())
.AddCoins(user.userInputData.Select(x => new Coin(x.tx, x.input.N)))

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
@@ -18,6 +18,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
public long RoundId { get; }
public RPCClient RpcClient { get; }
+ public Network Network => RpcClient.Network;
public Money Denomination { get; }
public int ConfirmationTarget { get; }
@@ -248,7 +249,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
// 1. Set new denomination: minor optimization.
Money newDenomination = Alices.Min(x => x.OutputSumWithoutCoordinatorFeeAndDenomination);
- var transaction = RpcClient.Network.Consensus.ConsensusFactory.CreateTransaction();
+ var transaction = Network.Consensus.ConsensusFactory.CreateTransaction();
// 2. Add Bob outputs.
foreach (Bob bob in Bobs)
@@ -256,7 +257,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
transaction.AddOutput(newDenomination, bob.ActiveOutputAddress.ScriptPubKey);
}
- BitcoinWitPubKeyAddress coordinatorAddress = Constants.GetCoordinatorAddress(RpcClient.Network);
+ BitcoinWitPubKeyAddress coordinatorAddress = Constants.GetCoordinatorAddress(Network);
// 3. If there are less Bobs than Alices, then add our own address. The malicious Alice, who will refuse to sign.
for (int i = 0; i < Alices.Count - Bobs.Count; i++)
{
@@ -304,7 +305,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
// 7. Create the unsigned transaction.
- var builder = new TransactionBuilder();
+ var builder = Network.CreateTransactionBuilder();
UnsignedCoinJoin = builder
.ContinueToBuild(transaction)
.Shuffle()
@@ -365,7 +366,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
Logger.LogWarning<CcjRound>(ex);
}
- SignedCoinJoin = Transaction.Parse(UnsignedCoinJoin.ToHex(), RpcClient.Network);
+ SignedCoinJoin = Transaction.Parse(UnsignedCoinJoin.ToHex(), Network);
Phase = CcjRoundPhase.Signing;
}
@@ -726,7 +727,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
Coin[] spentCoins = Alices.SelectMany(x => x.Inputs.Select(y => new Coin(y.OutPoint, y.Output))).ToArray();
Money networkFee = SignedCoinJoin.GetFee(spentCoins);
Logger.LogInfo<CcjRound>($"Round ({RoundId}): Network Fee: {networkFee.ToString(false, false)} BTC.");
- Logger.LogInfo<CcjRound>($"Round ({RoundId}): Coordinator Fee: {SignedCoinJoin.Outputs.SingleOrDefault(x => x.ScriptPubKey == Constants.GetCoordinatorAddress(RpcClient.Network).ScriptPubKey)?.Value?.ToString(false, false) ?? "0"} BTC.");
+ Logger.LogInfo<CcjRound>($"Round ({RoundId}): Coordinator Fee: {SignedCoinJoin.Outputs.SingleOrDefault(x => x.ScriptPubKey == Constants.GetCoordinatorAddress(Network).ScriptPubKey)?.Value?.ToString(false, false) ?? "0"} BTC.");
FeeRate feeRate = SignedCoinJoin.GetFeeRate(spentCoins);
Logger.LogInfo<CcjRound>($"Round ({RoundId}): Network Fee Rate: {feeRate.FeePerK.ToDecimal(MoneyUnit.Satoshi) / 1000} satoshi/byte.");
Logger.LogInfo<CcjRound>($"Round ({RoundId}): Number of inputs: {SignedCoinJoin.Inputs.Count}.");

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -310,7 +310,7 @@ namespace WalletWasabi.Services
throw new NotSupportedException("Coordinator did not add enough value to our outputs in the coinjoin.");
}
- var builder = new TransactionBuilder();
+ var builder = Network.CreateTransactionBuilder();
var signedCoinJoin = builder
.ContinueToBuild(unsignedCoinJoin)
.AddKeys(ongoingRound.CoinsRegistered.Select(x => x.Secret = x.Secret ?? KeyManager.GetSecrets(OnePiece, x.ScriptPubKey).Single()).ToArray())

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -932,7 +932,7 @@ namespace WalletWasabi.Services
// 9. Build the transaction
Logger.LogInfo<WalletService>("Signing transaction...");
- var builder = new TransactionBuilder();
+ var builder = Network.CreateTransactionBuilder();
builder = builder
.AddCoins(coinsToSpend.Select(x => x.GetCoin()))
.AddKeys(signingKeys.ToArray());

Update NBitcoin obsolate transactionbuilder creation