Make sure we never use other than segwit script for change outputs
MODIFY
WalletWasabi/Blockchain/Keys/KeyManager.cs
WalletWasabi/Blockchain/Keys/KeyManager.cs
@@ -359,6 +359,12 @@ public class KeyManager
return newKey;
}
+ public HdPubKey GetNextChangeKey() =>
+ GetKeys(x =>
+ x.KeyState == KeyState.Clean &&
+ x.IsInternal == true &&
+ x.FullKeyPath.GetScriptTypeFromKeyPath() == ScriptPubKeyType.Segwit).First();
+
public IEnumerable<HdPubKey> GetKeys(Func<HdPubKey, bool>? wherePredicate)
{
// BIP44-ish derivation scheme

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
@@ -140,7 +140,7 @@ public class TransactionFactory
}
else
{
- changeHdPubKey = KeyManager.GetKeys(KeyState.Clean, true).First();
+ changeHdPubKey = KeyManager.GetNextChangeKey();
builder.SetChange(changeHdPubKey.GetAssumedScriptPubKey());
}

Make sure we never use other than segwit script for change outputs