Reduce use of global pzcashParams with private member variable

This commit is contained in:
Simon 2016-09-06 22:59:14 -07:00
parent 485145ea78
commit 4b32c16ba5
2 changed files with 8 additions and 6 deletions

View File

@ -71,6 +71,8 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("runtime error: ") + e.what()); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("runtime error: ") + e.what());
} }
} }
zcashParams_ = pzcashParams; // global
} }
AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() { AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() {
@ -447,7 +449,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
// 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());
auto hSig = prevJoinSplit.h_sig(*pzcashParams, tx_.joinSplitPubKey); auto hSig = prevJoinSplit.h_sig(*zcashParams_, tx_.joinSplitPubKey);
try { try {
NotePlaintext plaintext = NotePlaintext::decrypt( NotePlaintext plaintext = NotePlaintext::decrypt(
decryptor, decryptor,
@ -729,7 +731,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() {
} }
// determine amount of funds in the note // determine amount of funds in the note
auto hSig = wtx.vjoinsplit[i].h_sig(*pzcashParams, wtx.joinSplitPubKey); auto hSig = wtx.vjoinsplit[i].h_sig(*zcashParams_, wtx.joinSplitPubKey);
try { try {
NotePlaintext plaintext = NotePlaintext::decrypt( NotePlaintext plaintext = NotePlaintext::decrypt(
decryptor, decryptor,
@ -832,7 +834,7 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit(
); );
// Generate the proof, this can take over a minute. // Generate the proof, this can take over a minute.
JSDescription jsdesc(*pzcashParams, JSDescription jsdesc(*zcashParams_,
joinSplitPubKey_, joinSplitPubKey_,
anchor, anchor,
{info.vjsin[0], info.vjsin[1]}, {info.vjsin[0], info.vjsin[1]},
@ -883,7 +885,7 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit(
ss2 << ((unsigned char) 0x00); ss2 << ((unsigned char) 0x00);
ss2 << jsdesc.ephemeralKey; ss2 << jsdesc.ephemeralKey;
ss2 << jsdesc.ciphertexts[0]; ss2 << jsdesc.ciphertexts[0];
ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); ss2 << jsdesc.h_sig(*zcashParams_, joinSplitPubKey_);
encryptedNote1 = HexStr(ss2.begin(), ss2.end()); encryptedNote1 = HexStr(ss2.begin(), ss2.end());
} }
@ -892,7 +894,7 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit(
ss2 << ((unsigned char) 0x01); ss2 << ((unsigned char) 0x01);
ss2 << jsdesc.ephemeralKey; ss2 << jsdesc.ephemeralKey;
ss2 << jsdesc.ciphertexts[1]; ss2 << jsdesc.ciphertexts[1];
ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); ss2 << jsdesc.h_sig(*zcashParams_, joinSplitPubKey_);
encryptedNote2 = HexStr(ss2.begin(), ss2.end()); encryptedNote2 = HexStr(ss2.begin(), ss2.end());
} }

View File

@ -69,7 +69,7 @@ private:
uint256 joinSplitPubKey_; uint256 joinSplitPubKey_;
unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES]; unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES];
ZCJoinSplit *zcashParams_;
std::vector<SendManyRecipient> t_outputs_; std::vector<SendManyRecipient> t_outputs_;
std::vector<SendManyRecipient> z_outputs_; std::vector<SendManyRecipient> z_outputs_;