From 0c70df28544944809377dcd922a546256d21fab6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 31 Dec 2019 18:54:25 -0500 Subject: [PATCH] Make the order of zaddr recipients we give to z_sendmany internals non-deterministic --- src/wallet/rpcwallet.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fbafbf95a..a65f679f3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4543,17 +4543,27 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) string zdust1, zdust2; - // Which zaddr we send to is non-deterministically chosen... + // Which zaddr we send to is non-deterministically chosen from two zpools... zdust1 = randomSietchZaddr(); - zaddrRecipients.push_back( SendManyRecipient(zdust1, nAmount, memo) ); + // And their ordering when given to internals is also non-deterministic, which + // helps breaks assumptions blockchain analysts may use from z_sendmany internals + if (decider % 2) { + zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust1, nAmount, memo) ); + } else { + zaddrRecipients.push_back( SendManyRecipient(zdust1, nAmount, memo) ); + } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust1.c_str()); //50% chance of adding another zout if (decider % 2) { zdust2 = randomSietchZaddr(); - zaddrRecipients.push_back( SendManyRecipient(zdust2, nAmount, memo) ); + if(decider % 4 == 3) { + zaddrRecipients.push_back( SendManyRecipient(zdust2, nAmount, memo) ); + } else { + zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust2, nAmount, memo) ); + } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust2.c_str()); }