Add feature to disable the signing in tx builder.
MODIFY
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
@@ -17,7 +17,7 @@ namespace WalletWasabi.Fluent.Helpers;
public static class TransactionHelpers
{
- public static BuildTransactionResult BuildChangelessTransaction(Wallet wallet, BitcoinAddress address, SmartLabel labels, FeeRate feeRate, IEnumerable<SmartCoin> coins)
+ public static BuildTransactionResult BuildChangelessTransaction(Wallet wallet, BitcoinAddress address, SmartLabel labels, FeeRate feeRate, IEnumerable<SmartCoin> coins, bool tryToSign = true)
{
var intent = new PaymentIntent(
address,
@@ -29,12 +29,13 @@ public static class TransactionHelpers
intent,
FeeStrategy.CreateFromFeeRate(feeRate),
allowUnconfirmed: true,
- coins.Select(coin => coin.OutPoint));
+ coins.Select(coin => coin.OutPoint),
+ tryToSign: tryToSign);
return txRes;
}
- public static BuildTransactionResult BuildTransaction(Wallet wallet, BitcoinAddress address, Money amount, SmartLabel labels, FeeRate feeRate, IEnumerable<SmartCoin> coins, bool subtractFee, IPayjoinClient? payJoinClient = null)
+ public static BuildTransactionResult BuildTransaction(Wallet wallet, BitcoinAddress address, Money amount, SmartLabel labels, FeeRate feeRate, IEnumerable<SmartCoin> coins, bool subtractFee, IPayjoinClient? payJoinClient = null, bool tryToSign = true)
{
if (payJoinClient is { } && subtractFee)
{
@@ -53,12 +54,13 @@ public static class TransactionHelpers
feeStrategy: FeeStrategy.CreateFromFeeRate(feeRate),
allowUnconfirmed: true,
allowedInputs: coins.Select(coin => coin.OutPoint),
- payjoinClient: payJoinClient);
+ payjoinClient: payJoinClient,
+ tryToSign: tryToSign);
return txRes;
}
- public static BuildTransactionResult BuildTransaction(Wallet wallet, TransactionInfo transactionInfo, bool isPayJoin = false)
+ public static BuildTransactionResult BuildTransaction(Wallet wallet, TransactionInfo transactionInfo, bool isPayJoin = false, bool tryToSign = true)
{
if (transactionInfo.IsOptimized)
{
@@ -67,7 +69,8 @@ public static class TransactionHelpers
transactionInfo.Address,
transactionInfo.UserLabels,
transactionInfo.FeeRate,
- transactionInfo.ChangelessCoins);
+ transactionInfo.ChangelessCoins,
+ tryToSign: tryToSign);
}
if (isPayJoin && transactionInfo.SubtractFee)
@@ -83,17 +86,17 @@ public static class TransactionHelpers
transactionInfo.FeeRate,
transactionInfo.Coins,
transactionInfo.SubtractFee,
- isPayJoin ? transactionInfo.PayJoinClient : null);
-
+ isPayJoin ? transactionInfo.PayJoinClient : null,
+ tryToSign: tryToSign);
}
- public static bool TryBuildTransaction(Wallet wallet, TransactionInfo transactionInfo, [NotNullWhen(true)] out BuildTransactionResult? transaction, bool isPayJoin = false)
+ public static bool TryBuildTransaction(Wallet wallet, TransactionInfo transactionInfo, [NotNullWhen(true)] out BuildTransactionResult? transaction, bool isPayJoin = false, bool tryToSign = true)
{
transaction = null;
try
{
- transaction = BuildTransaction(wallet, transactionInfo, isPayJoin);
+ transaction = BuildTransaction(wallet, transactionInfo, isPayJoin, tryToSign: tryToSign);
}
catch (Exception)
{

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -246,7 +246,7 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
{
IsBusy = true;
- return await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, _info));
+ return await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, _info, tryToSign: false));
}
catch (TransactionFeeOverpaymentException ex)
{

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
@@ -55,7 +55,8 @@ public class TransactionFactory
Func<FeeRate> feeRateFetcher,
IEnumerable<OutPoint>? allowedInputs = null,
Func<LockTime>? lockTimeSelector = null,
- IPayjoinClient? payjoinClient = null)
+ IPayjoinClient? payjoinClient = null,
+ bool tryToSign = true)
{
lockTimeSelector ??= () => LockTime.Zero;
@@ -221,7 +222,7 @@ public class TransactionFactory
psbt.AddPrevTxs(TransactionStore);
Transaction tx;
- if (KeyManager.IsWatchOnly)
+ if (KeyManager.IsWatchOnly || !tryToSign)
{
tx = psbt.GetGlobalTransaction();
}

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -215,7 +215,8 @@ public class Wallet : BackgroundService
FeeStrategy feeStrategy,
bool allowUnconfirmed = false,
IEnumerable<OutPoint>? allowedInputs = null,
- IPayjoinClient? payjoinClient = null)
+ IPayjoinClient? payjoinClient = null,
+ bool tryToSign = true)
{
var builder = new TransactionFactory(Network, KeyManager, Coins, BitcoinStore.TransactionStore, password, allowUnconfirmed);
return builder.BuildTransaction(
@@ -241,7 +242,8 @@ public class Wallet : BackgroundService
var currentTipHeight = BitcoinStore.SmartHeaderChain.TipHeight;
return LockTimeSelector.Instance.GetLockTimeBasedOnDistribution(currentTipHeight);
},
- payjoinClient);
+ payjoinClient,
+ tryToSign: tryToSign);
}
/// <inheritdoc/>

Add feature to disable the signing in tx builder.