When sending, do not create change if not needed
MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -977,8 +977,16 @@ namespace WalletWasabi.Services
}
HdPubKey changeHdPubKey = null;
+ try
+ {
+ // We try building without change, in some case, it is not needed
+ builder.SendEstimatedFees(feePerBytes);
+ }
+ catch (InvalidOperationException) // A change address should be specified
+ {
if (payments.ChangeStrategy == ChangeStrategy.Auto)
{
+ // Let's check is we need change by using a dummy
KeyManager.AssertCleanKeysIndexed(isInternal: true);
KeyManager.AssertLockedInternalKeysIndexed(14);
changeHdPubKey = KeyManager.GetKeys(KeyState.Clean, true).RandomElement();
@@ -994,8 +1002,8 @@ namespace WalletWasabi.Services
{
throw new NotSupportedException($"{nameof(payments.ChangeStrategy)} is not supported: {payments.ChangeStrategy}.");
}
-
builder.SendEstimatedFees(feePerBytes);
+ }
var psbt = builder.BuildPSBT(false);
string changeLabel = null;

When sending, do not create change if not needed