Browse Source

Hide some logspam behind -zdebug

master
Duke Leto 3 years ago
parent
commit
f0e242632d
  1. 22
      src/transaction_builder.cpp

22
src/transaction_builder.cpp

@ -4,15 +4,14 @@
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include "transaction_builder.h" #include "transaction_builder.h"
#include "main.h" #include "main.h"
#include "pubkey.h" #include "pubkey.h"
#include "script/sign.h" #include "script/sign.h"
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <boost/optional/optional_io.hpp> #include <boost/optional/optional_io.hpp>
#include <librustzcash.h> #include <librustzcash.h>
#include "zcash/Note.hpp" #include "zcash/Note.hpp"
extern bool fZDebug;
SpendDescriptionInfo::SpendDescriptionInfo( SpendDescriptionInfo::SpendDescriptionInfo(
libzcash::SaplingExpandedSpendingKey expsk, libzcash::SaplingExpandedSpendingKey expsk,
@ -128,9 +127,7 @@ bool TransactionBuilder::SendChangeTo(CTxDestination& changeAddr)
boost::optional<CTransaction> TransactionBuilder::Build() boost::optional<CTransaction> TransactionBuilder::Build()
{ {
//
// Consistency checks // Consistency checks
//
// Valid change // Valid change
CAmount change = mtx.valueBalance - fee; CAmount change = mtx.valueBalance - fee;
@ -145,33 +142,31 @@ boost::optional<CTransaction> TransactionBuilder::Build()
return boost::none; return boost::none;
} }
//
// Change output // Change output
//
if (change > 0) { if (change > 0) {
// Send change to the specified change address. If no change address // Send change to the specified change address. If no change address
// was set, send change to the first Sapling address given as input. // was set, send change to the first Sapling address given as input.
if (zChangeAddr) { if (zChangeAddr) {
LogPrintf("%s: Adding specified Sapling change output: %s\n", __FUNCTION__, zChangeAddr->second.GetHash().ToString().c_str()); if(fZdebug)
LogPrintf("%s: Adding specified Sapling change output: %s\n", __FUNCTION__, zChangeAddr->second.GetHash().ToString().c_str());
AddSaplingOutput(zChangeAddr->first, zChangeAddr->second, change); AddSaplingOutput(zChangeAddr->first, zChangeAddr->second, change);
} else if (tChangeAddr) { } else if (tChangeAddr) {
// tChangeAddr has already been validated. // tChangeAddr has already been validated.
assert(AddTransparentOutput(tChangeAddr.value(), change)); assert(AddTransparentOutput(tChangeAddr.value(), change));
} else if (!spends.empty()) { } else if (!spends.empty()) {
auto fvk = spends[0].expsk.full_viewing_key(); auto fvk = spends[0].expsk.full_viewing_key();
auto note = spends[0].note; auto note = spends[0].note;
libzcash::SaplingPaymentAddress changeAddr(note.d, note.pk_d); libzcash::SaplingPaymentAddress changeAddr(note.d, note.pk_d);
AddSaplingOutput(fvk.ovk, changeAddr, change); AddSaplingOutput(fvk.ovk, changeAddr, change);
LogPrintf("%s: Adding Sapling change output from first zinput: %s\n", __FUNCTION__, changeAddr.GetHash().ToString().c_str() ); if(fZdebug)
LogPrintf("%s: Adding Sapling change output from first zinput: %s\n", __FUNCTION__, changeAddr.GetHash().ToString().c_str() );
} else { } else {
return boost::none; return boost::none;
} }
} }
//
// Sapling spends and outputs // Sapling spends and outputs
//
auto ctx = librustzcash_sapling_proving_ctx_init(); auto ctx = librustzcash_sapling_proving_ctx_init();
@ -212,7 +207,8 @@ boost::optional<CTransaction> TransactionBuilder::Build()
sdesc.anchor = spend.anchor; sdesc.anchor = spend.anchor;
sdesc.nullifier = *nf; sdesc.nullifier = *nf;
LogPrintf("%s: Created cm + nullifier=%s\n", __FUNCTION__, sdesc.nullifier.ToString().c_str() ); if(fZdebug)
LogPrintf("%s: Created cm + nullifier=%s\n", __FUNCTION__, sdesc.nullifier.ToString().c_str() );
mtx.vShieldedSpend.push_back(sdesc); mtx.vShieldedSpend.push_back(sdesc);
} }
@ -266,9 +262,7 @@ boost::optional<CTransaction> TransactionBuilder::Build()
// add op_return if there is one to add // add op_return if there is one to add
AddOpRetLast(); AddOpRetLast();
//
// Signatures // Signatures
//
auto consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); auto consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams);

Loading…
Cancel
Save