From b4309fcef3f199441314321dcc1cfc4be513c646 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 8 Oct 2020 17:40:22 +0300
Subject: [PATCH 1/8] Fix extra line break in CommitTransaction log message

Introduced in #3680 https://github.com/dashpay/dash/commit/ebe7e80a4969bce494969e0e759d9edaaa765ad0#diff-b2bb174788c7409b671c46ccc86034bdR4113
---
 src/wallet/wallet.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 86d78be19eb8..a574aed746ab 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -4034,7 +4034,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
         wtxNew.fTimeReceivedIsTxTime = true;
         wtxNew.fFromMe = true;
 
-        LogPrintf("CommitTransaction:\n%s\n", wtxNew.tx->ToString());
+        LogPrintf("CommitTransaction:\n%s", wtxNew.tx->ToString()); /* Continued */
         {
             // Take key pair from key pool so it won't be used again
             reservekey.KeepKey();

From 9004d96717205195a6857061b5d60cd3b3657e99 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 25 Mar 2021 02:28:06 +0300
Subject: [PATCH 2/8] doc: Fix `quorum sign` help

---
 src/rpc/rpcquorums.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rpc/rpcquorums.cpp b/src/rpc/rpcquorums.cpp
index 8caaa28a81d1..2f21b50b9d2a 100644
--- a/src/rpc/rpcquorums.cpp
+++ b/src/rpc/rpcquorums.cpp
@@ -287,7 +287,7 @@ UniValue quorum_memberof(const JSONRPCRequest& request)
 void quorum_sign_help()
 {
     throw std::runtime_error(
-            "quorum sign llmqType \"id\" \"msgHash\" ( \"quorumHash\" )\n"
+            "quorum sign llmqType \"id\" \"msgHash\" ( \"quorumHash\" submit )\n"
             "Threshold-sign a message\n"
             "\nArguments:\n"
             "1. llmqType              (int, required) LLMQ type.\n"

From d1c89761077c795cf5dcff35ea891cd6fa17b401 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 25 Mar 2021 02:29:38 +0300
Subject: [PATCH 3/8] doc: Add `getdata` to quorum commands list help

---
 src/rpc/rpcquorums.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/rpc/rpcquorums.cpp b/src/rpc/rpcquorums.cpp
index 2f21b50b9d2a..2aea4e358256 100644
--- a/src/rpc/rpcquorums.cpp
+++ b/src/rpc/rpcquorums.cpp
@@ -616,6 +616,7 @@ UniValue quorum_getdata(const JSONRPCRequest& request)
             "  getrecsig         - Get a recovered signature\n"
             "  isconflicting     - Test if a conflict exists\n"
             "  selectquorum      - Return the quorum that would/should sign a request\n"
+            "  getdata           - Request quorum data from other masternodes in the quorum\n"
     );
 }
 

From 9e5d51f325d9cecbcd1c3e8a0fecd4c5cdefd616 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 25 Mar 2021 02:36:54 +0300
Subject: [PATCH 4/8] doc: Drop "P2WSH" from signrawtransactionwithkey help

---
 src/rpc/rawtransaction.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 6f409d287eb4..842a135b6dfd 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -908,7 +908,7 @@ UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
             "         \"txid\":\"id\",               (string, required) The transaction id\n"
             "         \"vout\":n,                  (numeric, required) The output number\n"
             "         \"scriptPubKey\": \"hex\",     (string, required) script key\n"
-            "         \"redeemScript\": \"hex\",     (string, required for P2SH or P2WSH) redeem script\n"
+            "         \"redeemScript\": \"hex\",     (string, required for P2SH) redeem script\n"
             "         \"amount\": value            (numeric, required) The amount spent\n"
             "       }\n"
             "       ,...\n"

From 3b054fe6c5d4706c75803e527d670137e6aa49ac Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 25 Mar 2021 02:38:50 +0300
Subject: [PATCH 5/8] trivial: Replace "push_back(Pair(..))" with "pushKV"

---
 src/rpc/coinjoin.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/rpc/coinjoin.cpp b/src/rpc/coinjoin.cpp
index aa1b601c409f..984023d6be08 100644
--- a/src/rpc/coinjoin.cpp
+++ b/src/rpc/coinjoin.cpp
@@ -150,8 +150,8 @@ UniValue getcoinjoininfo(const JSONRPCRequest& request)
     coinJoinClientManagers.at(pwallet->GetName())->GetJsonInfo(obj);
 
     obj.pushKV("keys_left",     pwallet->nKeysLeftSinceAutoBackup);
-    obj.push_back(Pair("warnings",      pwallet->nKeysLeftSinceAutoBackup < COINJOIN_KEYS_THRESHOLD_WARNING
-                                        ? "WARNING: keypool is almost depleted!" : ""));
+    obj.pushKV("warnings",      pwallet->nKeysLeftSinceAutoBackup < COINJOIN_KEYS_THRESHOLD_WARNING
+                                        ? "WARNING: keypool is almost depleted!" : "");
 #endif // ENABLE_WALLET
 
     return obj;

From 3f1ec10ed9a8feaeeac17bfb123231e5900396f0 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 25 Mar 2021 12:46:41 +0300
Subject: [PATCH 6/8] trivial: Reorder wallet cmd-line options

---
 src/wallet/init.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index dd4eb983f33c..1dc0d6e0399a 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -71,12 +71,12 @@ void WalletInit::AddWalletOptions() const
     gArgs.AddArg("-spendzeroconfchange", strprintf("Spend unconfirmed change when sending transactions (default: %u)", DEFAULT_SPEND_ZEROCONF_CHANGE), false, OptionsCategory::WALLET);
     gArgs.AddArg("-upgradewallet", "Upgrade wallet to latest format on startup", false, OptionsCategory::WALLET);
     gArgs.AddArg("-wallet=<path>", "Specify wallet database path. Can be specified multiple times to load multiple wallets. Path is interpreted relative to <walletdir> if it is not absolute, and will be created if it does not exist (as a directory containing a wallet.dat file and log files). For backwards compatibility this will also accept names of existing data files in <walletdir>.)", false, OptionsCategory::WALLET);
+    gArgs.AddArg("-walletbackupsdir=<dir>", "Specify full path to directory for automatic wallet backups (must exist)", false, OptionsCategory::WALLET);
     gArgs.AddArg("-walletbroadcast", strprintf("Make the wallet broadcast transactions (default: %u)", DEFAULT_WALLETBROADCAST), false, OptionsCategory::WALLET);
     gArgs.AddArg("-walletdir=<dir>", "Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)", false, OptionsCategory::WALLET);
     gArgs.AddArg("-walletnotify=<cmd>", "Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)", false, OptionsCategory::WALLET);
     gArgs.AddArg("-zapwallettxes=<mode>", "Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup"
                                                         " (1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET);
-    gArgs.AddArg("-walletbackupsdir=<dir>", "Specify full path to directory for automatic wallet backups (must exist)", false, OptionsCategory::WALLET);
 
     gArgs.AddArg("-discardfee=<amt>", strprintf("The fee rate (in %s/kB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). "
                                                                 "Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target",
@@ -96,9 +96,9 @@ void WalletInit::AddWalletOptions() const
 
     gArgs.AddArg("-keepass", strprintf("Use KeePass 2 integration using KeePassHttp plugin (default: %u)", 0), false, OptionsCategory::WALLET_KEEPASS);
     gArgs.AddArg("-keepassid=<id>", "KeePassHttp id for the established association", false, OptionsCategory::WALLET_KEEPASS);
+    gArgs.AddArg("-keepasskey=<key>", "KeePassHttp key for AES encrypted communication with KeePass", false, OptionsCategory::WALLET_KEEPASS);
     gArgs.AddArg("-keepassname=<name>", "Name to construct url for KeePass entry that stores the wallet passphrase", false, OptionsCategory::WALLET_KEEPASS);
     gArgs.AddArg("-keepassport=<port>", strprintf("Connect to KeePassHttp on port <port> (default: %u)", DEFAULT_KEEPASS_HTTP_PORT), false, OptionsCategory::WALLET_KEEPASS);
-    gArgs.AddArg("-keepasskey=<key>", "KeePassHttp key for AES encrypted communication with KeePass", false, OptionsCategory::WALLET_KEEPASS);
 
     gArgs.AddArg("-enablecoinjoin", strprintf("Enable use of CoinJoin for funds stored in this wallet (0-1, default: %u)", 0), false, OptionsCategory::WALLET_COINJOIN);
     gArgs.AddArg("-coinjoinamount=<n>", strprintf("Target CoinJoin balance (%u-%u, default: %u)", MIN_COINJOIN_AMOUNT, MAX_COINJOIN_AMOUNT, DEFAULT_COINJOIN_AMOUNT), false, OptionsCategory::WALLET_COINJOIN);

From 8cfaa187b157bcf05d59d19aece9bf7a58189e5f Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Fri, 26 Mar 2021 03:32:10 +0300
Subject: [PATCH 7/8] git: Add macos debug simbols to .gitignore

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index dee3fde7a49b..8406e38412dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -100,6 +100,7 @@ qrc_*.cpp
 # Mac specific
 .DS_Store
 build
+*.dSYM
 
 #lcov
 *.gcno

From 460dd1b5452f687c89dccf125d7a00a7a1e2e0b8 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Fri, 26 Mar 2021 04:10:12 +0300
Subject: [PATCH 8/8] trivial: Fix typos and whitespaces, drop unused stuff

---
 src/bench/bls.cpp               | 1 -
 src/init.cpp                    | 4 ++--
 src/llmq/quorums_chainlocks.cpp | 2 +-
 src/llmq/quorums_signing.cpp    | 2 +-
 src/net_processing.cpp          | 4 ++--
 src/validation.cpp              | 9 ++++-----
 src/wallet/wallet.cpp           | 4 ++--
 7 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/bench/bls.cpp b/src/bench/bls.cpp
index d36670d104c5..5d7b7b482771 100644
--- a/src/bench/bls.cpp
+++ b/src/bench/bls.cpp
@@ -96,7 +96,6 @@ static void BLS_Sign_Normal(benchmark::State& state)
 {
     CBLSSecretKey secKey;
     secKey.MakeNewKey();
-    CBLSPublicKey pubKey = secKey.GetPublicKey();
 
     // Benchmark.
     while (state.KeepRunning()) {
diff --git a/src/init.cpp b/src/init.cpp
index b8b10e46fc20..4f514e064911 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -841,7 +841,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
 
     {
         // Get all UTXOs for each MN collateral in one go so that we can fill coin cache early
-        // and reduce further locking overhead for cs_main in other parts of code inclluding GUI
+        // and reduce further locking overhead for cs_main in other parts of code including GUI
         LogPrintf("Filling coin cache with masternode UTXOs...\n");
         LOCK(cs_main);
         int64_t nStart = GetTimeMillis();
@@ -1461,7 +1461,7 @@ bool AppInitParameterInteraction()
     }
 
     if (gArgs.IsArgSet("-dip3params")) {
-        // Allow overriding budget parameters for testing
+        // Allow overriding dip3 parameters for testing
         if (!chainparams.MineBlocksOnDemand()) {
             return InitError("DIP3 parameters may only be overridden on regtest.");
         }
diff --git a/src/llmq/quorums_chainlocks.cpp b/src/llmq/quorums_chainlocks.cpp
index 69a94bb53650..915284c6daf5 100644
--- a/src/llmq/quorums_chainlocks.cpp
+++ b/src/llmq/quorums_chainlocks.cpp
@@ -316,7 +316,7 @@ void CChainLocksHandler::TrySignChainTip()
             }
             if (HasChainLock(pindexWalk->nHeight, pindexWalk->GetBlockHash())) {
                 // we don't care about islocks for TXs that are ChainLocked already
-                LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- chainlock at height %d \n", __func__, pindexWalk->nHeight);
+                LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- chainlock at height %d\n", __func__, pindexWalk->nHeight);
                 break;
             }
 
diff --git a/src/llmq/quorums_signing.cpp b/src/llmq/quorums_signing.cpp
index 4a9852db2503..0ad9e2bd9ef6 100644
--- a/src/llmq/quorums_signing.cpp
+++ b/src/llmq/quorums_signing.cpp
@@ -695,7 +695,7 @@ void CSigningManager::ProcessRecoveredSig(const std::shared_ptr<const CRecovered
         auto signHash = CLLMQUtils::BuildSignHash(*recoveredSig);
 
         LogPrint(BCLog::LLMQ, "CSigningManager::%s -- valid recSig. signHash=%s, id=%s, msgHash=%s\n", __func__,
-                signHash.ToString(), recoveredSig->id   .ToString(), recoveredSig->msgHash.ToString());
+                signHash.ToString(), recoveredSig->id.ToString(), recoveredSig->msgHash.ToString());
 
         if (db.HasRecoveredSigForId(llmqType, recoveredSig->id)) {
             CRecoveredSig otherRecoveredSig;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index ed1147937f56..f575a861095d 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3732,8 +3732,8 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
         else
         {
             PrintExceptionContinue(std::current_exception(), "ProcessMessages()");
-            }
-        } catch (...) {
+        }
+    } catch (...) {
         PrintExceptionContinue(std::current_exception(), "ProcessMessages()");
     }
 
diff --git a/src/validation.cpp b/src/validation.cpp
index 4690a3b9a781..c6e94ee0d9bb 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -246,7 +246,6 @@ uint64_t nPruneTarget = 0;
 int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
 
 std::atomic<bool> fDIP0001ActiveAtTip{false};
-std::atomic<bool> fDIP0003ActiveAtTip{false};
 
 uint256 hashAssumeValid;
 arith_uint256 nMinimumChainWork;
@@ -2532,7 +2531,7 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
         }
         int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
         int64_t cacheSize = pcoinsTip->DynamicMemoryUsage();
-    cacheSize += evoDb->GetMemoryUsage();
+        cacheSize += evoDb->GetMemoryUsage();
         int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0);
         // The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
         bool fCacheLarge = mode == FlushStateMode::PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE * 1024 * 1024);
@@ -2586,9 +2585,9 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
             // Flush the chainstate (which may refer to block index entries).
             if (!pcoinsTip->Flush())
                 return AbortNode(state, "Failed to write to coin database");
-        if (!evoDb->CommitRootTransaction()) {
-            return AbortNode(state, "Failed to commit EvoDB");
-        }
+            if (!evoDb->CommitRootTransaction()) {
+                return AbortNode(state, "Failed to commit EvoDB");
+            }
             nLastFlush = nNow;
         }
     }
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index a574aed746ab..3e577645ec7c 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -222,7 +222,7 @@ void CWallet::DeriveNewChildKey(WalletBatch &batch, const CKeyMetadata& metadata
     }
 
     if (!DecryptHDChain(hdChainTmp))
-        throw std::runtime_error(std::string(__func__) + ": DecryptHDChainSeed failed");
+        throw std::runtime_error(std::string(__func__) + ": DecryptHDChain failed");
     // make sure seed matches this chain
     if (hdChainTmp.GetID() != hdChainTmp.GetSeedHash())
         throw std::runtime_error(std::string(__func__) + ": Wrong HD chain!");
@@ -301,7 +301,7 @@ bool CWallet::GetKey(const CKeyID &address, CKey& keyOut) const
         if (!GetHDChain(hdChainCurrent))
             throw std::runtime_error(std::string(__func__) + ": GetHDChain failed");
         if (!DecryptHDChain(hdChainCurrent))
-            throw std::runtime_error(std::string(__func__) + ": DecryptHDChainSeed failed");
+            throw std::runtime_error(std::string(__func__) + ": DecryptHDChain failed");
         // make sure seed matches this chain
         if (hdChainCurrent.GetID() != hdChainCurrent.GetSeedHash())
             throw std::runtime_error(std::string(__func__) + ": Wrong HD chain!");
