]> Git Repo - VerusCoin.git/commitdiff
Check mempooltxinputlimit when creating a transaction to avoid local
authorSimon <[email protected]>
Sat, 17 Jun 2017 21:41:25 +0000 (14:41 -0700)
committerSimon <[email protected]>
Sat, 17 Jun 2017 21:41:25 +0000 (14:41 -0700)
mempool rejection.

src/wallet/asyncrpcoperation_sendmany.cpp
src/wallet/wallet.cpp

index 1691452b892299b360b00d1378edfa6b8b2c6df2..3bbbfcc05aa71bace7944fcd178910f20037d4e6 100644 (file)
@@ -203,7 +203,18 @@ bool AsyncRPCOperation_sendmany::main_impl() {
     if (isfromzaddr_ && !find_unspent_notes()) {
         throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds, no unspent notes found for zaddr from address.");
     }
-    
+
+    // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects
+    if (isfromtaddr_) {
+        size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0);
+        if (limit > 0) {
+            size_t n = t_inputs_.size();
+            if (n > limit) {
+                throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Too many transparent inputs %zu > limit %zu", n, limit));
+            }
+        }
+    }
+
     CAmount t_inputs_total = 0;
     for (SendManyInputUTXO & t : t_inputs_) {
         t_inputs_total += std::get<2>(t);
index 98deedf64cac46e2db0f5ccec10d44cb3a4a3cb3..a61c1e2f7db1aeb7321f3730e0bd73a553b58e8d 100644 (file)
@@ -2717,6 +2717,16 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
                     txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
                                               std::numeric_limits<unsigned int>::max()-1));
 
+                // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects
+                size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0);
+                if (limit > 0) {
+                    size_t n = txNew.vin.size();
+                    if (n > limit) {
+                        strFailReason = _(strprintf("Too many transparent inputs %zu > limit %zu", n, limit).c_str());
+                        return false;
+                    }
+                }
+
                 // Sign
                 int nIn = 0;
                 CTransaction txNewConst(txNew);
This page took 0.03318 seconds and 4 git commands to generate.