Improved logging and error checking in consolidation and sweeping
This commit is contained in:
@@ -82,7 +82,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
auto consensusParams = Params().GetConsensus();
|
||||
auto nextActivationHeight = NextActivationHeight(targetHeight_, consensusParams);
|
||||
if (nextActivationHeight && targetHeight_ + CONSOLIDATION_EXPIRY_DELTA >= nextActivationHeight.get()) {
|
||||
LogPrint("zrpcunsafe", "%s: Consolidation txs would be created before a NU activation but may expire after. Skipping this round.\n",opid);
|
||||
LogPrintf("%s: Consolidation txs would be created before a NU activation but may expire after. Skipping this round.\n",opid);
|
||||
setConsolidationResult(0, 0, std::vector<std::string>());
|
||||
return status;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
pwalletMain->GetFilteredNotes(saplingEntries, "", 11);
|
||||
|
||||
if(saplingEntries.size() == 0) {
|
||||
LogPrint("zrpcunsafe", "%s: Nothing to consolidate, done.\n",opid);
|
||||
LogPrintf("%s: Nothing to consolidate, done.\n",opid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
libzcash::SaplingPaymentAddress saplingAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddress);
|
||||
addresses.insert(saplingAddress);
|
||||
} else {
|
||||
LogPrint("zrpcunsafe", "%s: Invalid zaddr, exiting\n", opid);
|
||||
LogPrintf("%s: Invalid zaddr, exiting\n", opid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -176,14 +176,14 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
std::vector<boost::optional<SaplingWitness>> witnesses;
|
||||
{
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
LogPrint("zrpcunsafe", "%s: Fetching note witnesses\n", opid);
|
||||
// LogPrint("zrpcunsafe", "%s: Fetching note witnesses\n", opid);
|
||||
pwalletMain->GetSaplingNoteWitnesses(ops, witnesses, anchor);
|
||||
}
|
||||
|
||||
// Add Sapling spends
|
||||
for (size_t i = 0; i < notes.size(); i++) {
|
||||
if (!witnesses[i]) {
|
||||
LogPrint("zrpcunsafe", "%s: Missing Witnesses. Stopping.\n", opid);
|
||||
LogPrintf("%s: Missing Witnesses! Stopping.\n", opid);
|
||||
status=false;
|
||||
break;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
// actually add our sietch zoutput, the new way
|
||||
builder.AddSaplingOutput(extsk.expsk.ovk, sietchZoutput, amount);
|
||||
} else {
|
||||
LogPrint("zrpcunsafe", "%s: Invalid payment address %s! Stopping.\n", opid, zdust);
|
||||
LogPrintf("%s: Invalid payment address %s! Stopping.\n", opid, zdust);
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
@@ -223,25 +223,25 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
|
||||
auto maybe_tx = builder.Build();
|
||||
if (!maybe_tx) {
|
||||
LogPrint("zrpcunsafe", "%s: Failed to build transaction.\n",opid);
|
||||
LogPrintf("%s: Failed to build transaction.\n",opid);
|
||||
status=false;
|
||||
break;
|
||||
}
|
||||
CTransaction tx = maybe_tx.get();
|
||||
|
||||
if (isCancelled()) {
|
||||
LogPrint("zrpcunsafe", "%s: Canceled. Stopping.\n", opid);
|
||||
LogPrintf("%s: Canceled. Stopping.\n", opid);
|
||||
status=false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(pwalletMain->CommitAutomatedTx(tx)) {
|
||||
LogPrint("zrpcunsafe", "%s: Committed consolidation transaction with txid=%s\n",opid, tx.GetHash().ToString());
|
||||
LogPrintf("%s: Committed consolidation transaction with txid=%s\n",opid, tx.GetHash().ToString());
|
||||
amountConsolidated += actualAmountToSend;
|
||||
consolidationTxIds.push_back(tx.GetHash().ToString());
|
||||
numTxCreated++;
|
||||
} else {
|
||||
LogPrint("zrpcunsafe", "%s: Consolidation transaction FAILED in CommitTransaction, txid=%s\n",opid , tx.GetHash().ToString());
|
||||
LogPrintf("%s: Consolidation transaction FAILED in CommitTransaction, txid=%s\n",opid , tx.GetHash().ToString());
|
||||
setConsolidationResult(numTxCreated, amountConsolidated, consolidationTxIds);
|
||||
status = false;
|
||||
break;
|
||||
@@ -249,7 +249,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
||||
}
|
||||
}
|
||||
|
||||
LogPrint("zrpcunsafe", "%s: Created %d transactions with total Sapling output amount=%s,status=%d\n",opid , numTxCreated, FormatMoney(amountConsolidated), (int)status);
|
||||
LogPrintf("%s: Created %d transactions with total Sapling output amount=%s,status=%d\n",opid , numTxCreated, FormatMoney(amountConsolidated), (int)status);
|
||||
setConsolidationResult(numTxCreated, amountConsolidated, consolidationTxIds);
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user