Skip to content

Commit 9b51d22

Browse files
Merge #6870: refactor: allow wallet to select fresh change address to prevent address reuse in coinjoin createdenoms
efc689c Apply suggestions from code review (PastaPastaPasta) cfae1e6 refactor: update CoinJoin change address handling to respect wallet's avoid_reuse setting (pasta) 4800e2f chore: run clang-format (pasta) d4044d4 feat: introduce -coinjoinfreshchange option to enhance CoinJoin change address handling (pasta) 6ca08f6 docs: add release notes for CoinJoin change address improvement in wallet (pasta) 739d9f1 refactor: allow wallet to select fresh change address to prevent address reuse in coinjoin createdenoms (pasta) Pull request description: ## Issue being fixed or feature implemented Coinjoin CreateDenoms will currently intentionally re-use the input address for change; I see no reason to do this, and it can be non-ideal for certain instances such as if you receive on X and are tracking that address X for further receipts. Say every time you receive on X you send to Y as a part of an exchange or something. The only time I can image where it's not ideal is if you receive to X multiple times, maybe you receive 1.9 and 0.1 (contrived) in this case, say your first create denoms makes 1.9 -> 1 and 0.9; because that 0.9 is kept in address X, the second 0.1 can be combined with the 0.9 to make another 1 Dash denom. ## What was done? Use fresh change address instead of re-using ## How Has This Been Tested? NOT TESTED (@kwvg please test and confirm functionality of createdenoms) ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK efc689c Tree-SHA512: cd6e79b7a699253832181235da171501e153e26177e584d7bea62f7849133ad65bbc439b99664b90b7300e63cbce74da36d611ac46a3ee32637369685e6262ce
2 parents 58acea6 + efc689c commit 9b51d22

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

doc/release-notes-6870.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Wallet
2+
------
3+
4+
- CoinJoin denomination creation now respects the wallet's "avoid_reuse"
5+
setting. When the wallet has `avoid_reuse` enabled, change is sent to a
6+
fresh change address to avoid address/public key reuse. Otherwise, change
7+
goes back to the source address (legacy behavior). (#6870)
8+
9+

src/coinjoin/util.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <wallet/fees.h>
1010
#include <wallet/spend.h>
1111
#include <wallet/wallet.h>
12+
#include <wallet/walletutil.h>
1213

1314
#include <numeric>
1415

@@ -125,8 +126,13 @@ CTransactionBuilder::CTransactionBuilder(CWallet& wallet, const CompactTallyItem
125126
coinControl.m_discard_feerate = ::GetDiscardRate(m_wallet);
126127
// Generate a feerate which will be used by calculations of this class and also by CWallet::CreateTransaction
127128
coinControl.m_feerate = std::max(GetRequiredFeeRate(m_wallet), m_wallet.m_pay_tx_fee);
128-
// Change always goes back to origin
129-
coinControl.destChange = tallyItemIn.txdest;
129+
// If wallet does not have the avoid-reuse feature enabled, keep legacy
130+
// behavior: force change to go back to the origin address. When
131+
// WALLET_FLAG_AVOID_REUSE is enabled, let the wallet select a fresh
132+
// change destination to avoid address reuse.
133+
if (!m_wallet.IsWalletFlagSet(wallet::WALLET_FLAG_AVOID_REUSE)) {
134+
coinControl.destChange = tallyItemIn.txdest;
135+
}
130136
// Only allow tallyItems inputs for tx creation
131137
coinControl.m_allow_other_inputs = false;
132138
// Create dummy tx to calculate the exact required fees upfront for accurate amount and fee calculations

0 commit comments

Comments
 (0)