Track the correct change witness across chained joinsplits
This commit is contained in:
@@ -500,15 +500,23 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Could not find previous JoinSplit anchor");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Could not find previous JoinSplit anchor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(changeOutputIndex != -1);
|
||||||
|
boost::optional<ZCIncrementalWitness> changeWitness;
|
||||||
|
int n = 0;
|
||||||
for (const uint256& commitment : prevJoinSplit.commitments) {
|
for (const uint256& commitment : prevJoinSplit.commitments) {
|
||||||
tree.append(commitment);
|
tree.append(commitment);
|
||||||
previousCommitments.push_back(commitment);
|
previousCommitments.push_back(commitment);
|
||||||
|
if (!changeWitness && changeOutputIndex == n++) {
|
||||||
|
changeWitness = tree.witness();
|
||||||
|
} else if (changeWitness) {
|
||||||
|
changeWitness.get().append(commitment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ZCIncrementalWitness changeWitness = tree.witness();
|
if (changeWitness) {
|
||||||
jsAnchor = changeWitness.root();
|
witnesses.push_back(changeWitness);
|
||||||
uint256 changeCommitment = prevJoinSplit.commitments[changeOutputIndex];
|
}
|
||||||
intermediates.insert(std::make_pair(tree.root(), tree));
|
jsAnchor = tree.root();
|
||||||
witnesses.push_back(changeWitness);
|
intermediates.insert(std::make_pair(tree.root(), tree)); // chained js are interstitial (found in between block boundaries)
|
||||||
|
|
||||||
// Decrypt the change note's ciphertext to retrieve some data we need
|
// Decrypt the change note's ciphertext to retrieve some data we need
|
||||||
ZCNoteDecryption decryptor(spendingkey_.viewing_key());
|
ZCNoteDecryption decryptor(spendingkey_.viewing_key());
|
||||||
@@ -891,9 +899,7 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit(
|
|||||||
outputMap,
|
outputMap,
|
||||||
info.vpub_old,
|
info.vpub_old,
|
||||||
info.vpub_new,
|
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_))) {
|
if (!(jsdesc.Verify(*pzcashParams, joinSplitPubKey_))) {
|
||||||
throw std::runtime_error("error verifying joinsplit");
|
throw std::runtime_error("error verifying joinsplit");
|
||||||
|
|||||||
Reference in New Issue
Block a user