Skip to content

Commit 02b7e83

Browse files
author
MarcoFalke
committed
Merge bitcoin#12709: [wallet] shuffle sendmany recipients ordering
6acb02d add release note for sendmany output shuffling (Gregory Sanders) cf6ef3c shuffle sendmany recipients ordering to shuffle tx outputs (Gregory Sanders) Pull request description: Unless there is something important I'm missing, we're just possible leaking information by preserving whatever ordering json object ordering is giving us (no guarantees at all). This is unneeded for `sendtoaddress` since there is only 1 or 2 outputs, and the change output is shuffled in. This will not effect `*raw` behavior by design, since users generally want full control using those apis. Further PRs could add optional args to over-ride that behavior. Alternative ideas would be to sort the outputs by some deterministic ordering. (this would require more refactoring since change outputs are created and handled by caller) related: bitcoin#12699 Tree-SHA512: afdd990dde6a4a9e7eef7bb2e3342a46d11900d7fe6e6e4eb0cc6b5deed89df989fa7931a4bdcbf49b7c2d7a13c90169af3a166466e5760948bacabe3490f572
2 parents cead84b + 6acb02d commit 02b7e83

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

doc/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ RPC changes
7373
- Wallet `listreceivedbylabel`, `listreceivedbyaccount` and `listunspent` RPCs
7474
add `label` fields to returned JSON objects that previously only had
7575
`account` fields.
76+
- `sendmany` now shuffles outputs to improve privacy, so any previously expected behavior with regards to output ordering can no longer be relied upon.
7677

7778
External wallet files
7879
---------------------

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ UniValue sendmany(const JSONRPCRequest& request)
11451145
if (totalAmount > nBalance)
11461146
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
11471147

1148+
// Shuffle recipient list
1149+
std::shuffle(vecSend.begin(), vecSend.end(), FastRandomContext());
1150+
11481151
// Send
11491152
CReserveKey keyChange(pwallet);
11501153
CAmount nFeeRequired = 0;

0 commit comments

Comments
 (0)