]> Git Repo - VerusCoin.git/commitdiff
Add logging for Sprout to Sapling migration transaction generation
authorEirik0 <[email protected]>
Thu, 9 May 2019 21:13:10 +0000 (15:13 -0600)
committerEirik0 <[email protected]>
Fri, 10 May 2019 23:22:08 +0000 (17:22 -0600)
src/wallet/asyncrpcoperation_saplingmigration.cpp

index 465e18ee5991820ed08adea775d4fc579bce4ec4..21eddcfecd35c6ff4f04f2788921a8f398b37240 100644 (file)
@@ -68,6 +68,7 @@ void AsyncRPCOperation_saplingmigration::main() {
 }
 
 bool AsyncRPCOperation_saplingmigration::main_impl() {
+    LogPrint("zrpcunsafe", "Beginning AsyncRPCOperation_saplingmigration. id=%s\n", getId());
     std::vector<CSproutNotePlaintextEntry> sproutEntries;
     std::vector<SaplingNoteEntry> saplingEntries;
     {
@@ -83,6 +84,8 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
     }
     // If the remaining amount to be migrated is less than 0.01 ZEC, end the migration.
     if (availableFunds < CENT) {
+        LogPrint("zrpcunsafe", "%s: Available Sprout balance (%s) less than required minimum (%s). Stopping.\n",
+            getId(), FormatMoney(availableFunds), FormatMoney(CENT));
         setMigrationResult(0, 0, std::vector<std::string>());
         return true;
     }
@@ -102,6 +105,7 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
         CAmount amountToSend = chooseAmount(availableFunds);
         auto builder = TransactionBuilder(consensusParams, targetHeight_, MIGRATION_EXPIRY_DELTA, pwalletMain, pzcashParams,
                                           &coinsView, &cs_main);
+        LogPrint("zrpcunsafe", "%s: Beginning creating transaction with Sapling output amount=%s\n", getId(), amountToSend - FEE);
         std::vector<CSproutNotePlaintextEntry> fromNotes;
         CAmount fromNoteAmount = 0;
         while (fromNoteAmount < amountToSend) {
@@ -111,6 +115,15 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
         }
         availableFunds -= fromNoteAmount;
         for (const CSproutNotePlaintextEntry& sproutEntry : fromNotes) {
+            std::string data(sproutEntry.plaintext.memo().begin(), sproutEntry.plaintext.memo().end());
+            LogPrint("zrpcunsafe", "%s: Adding Sprout note input (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, memo=%s)\n",
+                getId(),
+                sproutEntry.jsop.hash.ToString().substr(0, 10),
+                sproutEntry.jsop.js,
+                int(sproutEntry.jsop.n),  // uint8_t
+                FormatMoney(sproutEntry.plaintext.value()),
+                HexStr(data).substr(0, 10)
+                );
             libzcash::SproutNote sproutNote = sproutEntry.plaintext.note(sproutEntry.address);
             libzcash::SproutSpendingKey sproutSk;
             pwalletMain->GetSproutSpendingKey(sproutEntry.address, sproutSk);
@@ -129,14 +142,17 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
         builder.AddSaplingOutput(ovkForShieldingFromTaddr(seed), migrationDestAddress, amountToSend - FEE);
         CTransaction tx = builder.Build().GetTxOrThrow();
         if (isCancelled()) {
+            LogPrint("zrpcunsafe", "%s: Canceled. Stopping.\n");
             break;
         }
         pwalletMain->AddPendingSaplingMigrationTx(tx);
+        LogPrint("zrpcunsafe", "%s: Added pending migration transaction with txid=%s\n", getId(), tx.GetHash().ToString());
         ++numTxCreated;
         amountMigrated += amountToSend - FEE;
         migrationTxIds.push_back(tx.GetHash().ToString());
     } while (numTxCreated < 5 && availableFunds > CENT);
 
+    LogPrint("zrpcunsafe", "%s: Created %d transactions with total Sapling output amount=%s\n", getId(), numTxCreated, FormatMoney(amountMigrated));
     setMigrationResult(numTxCreated, amountMigrated, migrationTxIds);
     return true;
 }
This page took 0.027356 seconds and 4 git commands to generate.