diff --git a/doc/release-notes-6870.md b/doc/release-notes-6870.md new file mode 100644 index 0000000000000..dd2eede82adcf --- /dev/null +++ b/doc/release-notes-6870.md @@ -0,0 +1,9 @@ +Wallet +------ + +- CoinJoin denomination creation now respects the wallet's "avoid_reuse" + setting. When the wallet has `avoid_reuse` enabled, change is sent to a + fresh change address to avoid address/public key reuse. Otherwise, change + goes back to the source address (legacy behavior). (#6870) + + diff --git a/src/coinjoin/util.cpp b/src/coinjoin/util.cpp index dd4c27281217d..a494b8755d0de 100644 --- a/src/coinjoin/util.cpp +++ b/src/coinjoin/util.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -125,8 +126,13 @@ CTransactionBuilder::CTransactionBuilder(CWallet& wallet, const CompactTallyItem coinControl.m_discard_feerate = ::GetDiscardRate(m_wallet); // Generate a feerate which will be used by calculations of this class and also by CWallet::CreateTransaction coinControl.m_feerate = std::max(GetRequiredFeeRate(m_wallet), m_wallet.m_pay_tx_fee); - // Change always goes back to origin - coinControl.destChange = tallyItemIn.txdest; + // If wallet does not have the avoid-reuse feature enabled, keep legacy + // behavior: force change to go back to the origin address. When + // WALLET_FLAG_AVOID_REUSE is enabled, let the wallet select a fresh + // change destination to avoid address reuse. + if (!m_wallet.IsWalletFlagSet(wallet::WALLET_FLAG_AVOID_REUSE)) { + coinControl.destChange = tallyItemIn.txdest; + } // Only allow tallyItems inputs for tx creation coinControl.m_allow_other_inputs = false; // Create dummy tx to calculate the exact required fees upfront for accurate amount and fee calculations