Use fee=0 if we do not have enough funds in this zaddr to pay a fee; track number of txs created

This commit is contained in:
Duke Leto
2020-04-07 21:17:58 -04:00
parent 941f983a9f
commit be4812bd29

View File

@@ -185,7 +185,9 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
LogPrint("zrpcunsafe", "%s: Added consolidation input %d\n", opid, i); LogPrint("zrpcunsafe", "%s: Added consolidation input %d\n", opid, i);
} }
builder.SetFee(fConsolidationTxFee); CAmount thisTxFee = amountToSend < fConsolidationTxFee ? 0 : fConsolidationTxFee;
LogPrint("zrpcunsafe", "%s: Using fee=%d\n", opid, thisTxFee);
builder.SetFee(thisTxFee);
// Add the actual consolidation tx // Add the actual consolidation tx
builder.AddSaplingOutput(extsk.expsk.ovk, addr, actualAmountToSend); builder.AddSaplingOutput(extsk.expsk.ovk, addr, actualAmountToSend);
@@ -231,13 +233,13 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
LogPrint("zrpcunsafe", "%s: Committed consolidation transaction with txid=%s\n",opid, tx.GetHash().ToString()); LogPrint("zrpcunsafe", "%s: Committed consolidation transaction with txid=%s\n",opid, tx.GetHash().ToString());
amountConsolidated += actualAmountToSend; amountConsolidated += actualAmountToSend;
consolidationTxIds.push_back(tx.GetHash().ToString()); consolidationTxIds.push_back(tx.GetHash().ToString());
numTxCreated++;
} else { } else {
LogPrint("zrpcunsafe", "%s: Consolidation transaction FAILED in CommitTransaction, txid=%s\n",opid , tx.GetHash().ToString()); LogPrint("zrpcunsafe", "%s: Consolidation transaction FAILED in CommitTransaction, txid=%s\n",opid , tx.GetHash().ToString());
setConsolidationResult(numTxCreated, amountConsolidated, consolidationTxIds); setConsolidationResult(numTxCreated, amountConsolidated, consolidationTxIds);
status = false; status = false;
break; break;
} }
} }
} }