Auto merge of #1790 - bitcartel:1779_send_multiple_zaddrs_logic_error, r=bitcartel

Fixes #1779 so that sending to multiple zaddrs no longer fails.

Closes #1779

Commit 2eeb6b randomized the order of input and output notes,
but this is now known to prevent the chaining of multiple joinsplits
in a single transaction.  The root cause has yet to be determined.

This patch is a temporary fix and disables the shuffling of input
and output notes.  It also adds a chained joinsplit test to the
python qa test suite.
This commit is contained in:
zkbot
2016-11-06 05:20:45 +00:00
6 changed files with 41 additions and 1 deletions

View File

@@ -24,4 +24,12 @@ TEST(Random, MappedShuffle) {
std::vector<int> em2 {0, 1, 2, 3, 4};
EXPECT_EQ(ea2, a2);
EXPECT_EQ(em2, m2);
auto a3 = a;
auto m3 = m;
MappedShuffle(a3.begin(), m3.begin(), a3.size(), GenIdentity);
std::vector<int> ea3 {8, 4, 6, 3, 5};
std::vector<int> em3 {0, 1, 2, 3, 4};
EXPECT_EQ(ea3, a3);
EXPECT_EQ(em3, m3);
}

View File

@@ -57,6 +57,9 @@ JSDescription JSDescription::Randomized(
// Randomize the order of the inputs and outputs
inputMap = {0, 1};
outputMap = {0, 1};
assert(gen);
MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen);
MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen);

View File

@@ -137,3 +137,8 @@ void seed_insecure_rand(bool fDeterministic)
insecure_rand_Rw = tmp;
}
}
int GenIdentity(int n)
{
return n-1;
}

View File

@@ -25,6 +25,11 @@ uint64_t GetRand(uint64_t nMax);
int GetRandInt(int nMax);
uint256 GetRandHash();
/**
* Identity function for MappedShuffle, so that elements retain their original order.
*/
int GenIdentity(int n);
/**
* Rearranges the elements in the range [first,first+len) randomly, assuming
* that gen is a uniform random number generator. Follows the same algorithm as

View File

@@ -885,7 +885,9 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit(
outputMap,
info.vpub_old,
info.vpub_new,
!this->testmode);
!this->testmode,
// Temporary fix for #1779 is to disable shuffling of inputs and outputs.
GenIdentity);
if (!(jsdesc.Verify(*pzcashParams, joinSplitPubKey_))) {
throw std::runtime_error("error verifying joinsplit");