]> Git Repo - VerusCoin.git/commitdiff
Reserve transfer fix
authormiketout <[email protected]>
Thu, 29 Apr 2021 00:11:33 +0000 (17:11 -0700)
committermiketout <[email protected]>
Thu, 29 Apr 2021 00:11:33 +0000 (17:11 -0700)
src/main.cpp
src/pbaas/reserves.cpp
src/rpc/pbaasrpc.cpp

index 40192b51a1398f3a1c6ad96f4d5e79c3da66b8f0..4a412404674efa8bc378512eac7085e18f54942d 100644 (file)
@@ -2899,9 +2899,9 @@ namespace Consensus {
         {
             fprintf(stderr,"spentheight.%d reservevaluein: %s\nis less than out: %s\n", nSpendHeight,
                     ReserveValueIn.ToUniValue().write(1, 2).c_str(), tx.GetReserveValueOut().ToUniValue().write(1, 2).c_str());
-            //UniValue jsonTx(UniValue::VOBJ);
-            //TxToUniv(tx, uint256(), jsonTx);
-            //fprintf(stderr,"%s\n", jsonTx.write(1,2).c_str());
+            UniValue jsonTx(UniValue::VOBJ);
+            TxToUniv(tx, uint256(), jsonTx);
+            fprintf(stderr,"%s\n", jsonTx.write(1,2).c_str());
             return state.DoS(100, error("CheckInputs(): reserve value in < reserve value out"), REJECT_INVALID, "bad-txns-reservein-belowout");
         }
 
index 1ff847e15bb69f6160ad176ad392f8c3822c6ea8..d44811b21b38de7746fbb54c5169ed28741b287c 100644 (file)
@@ -1366,7 +1366,7 @@ void CReserveTransactionDescriptor::AddReserveOutput(const CTokenOutput &ro)
 void CReserveTransactionDescriptor::AddReserveTransfer(const CReserveTransfer &rt)
 {
     flags |= IS_RESERVE;
-    for (auto &oneCur : rt.reserveValues.valueMap)
+    for (auto &oneCur : rt.TotalCurrencyOut().valueMap)
     {
         if (oneCur.first != ASSETCHAINS_CHAINID && oneCur.second)
         {
index 7026a2440e5a117ba13571d1e9d96056d7e0046b..0b42650c06255b5ce92c6ee6f771a2914fec661d 100644 (file)
@@ -3929,7 +3929,8 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
 
                         std::vector<CTxDestination> dests = std::vector<CTxDestination>({pk.GetID(), refundDestination});
 
-                        oneOutput.nAmount = sourceCurrencyID == thisChainID ? sourceAmount + fees : fees;
+                        oneOutput.nAmount = sourceCurrencyID == thisChainID ? sourceAmount : 0;
+                        oneOutput.nAmount += feeCurrencyID == thisChainID ? fees : 0;
                         oneOutput.scriptPubKey = MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt));
                     }
                     else // direct to another system paying with acceptable fee currency
@@ -3950,7 +3951,7 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
                         std::vector<CTxDestination> dests = std::vector<CTxDestination>({pk.GetID(), refundDestination});
 
                         oneOutput.nAmount = sourceCurrencyID == thisChainID ? sourceAmount : 0;
-                        assert(feeCurrencyID == destSystemID);
+                        oneOutput.nAmount += feeCurrencyID == thisChainID ? fees : 0;
                         oneOutput.scriptPubKey = MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt));
                     }
                 }
@@ -4145,15 +4146,15 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
     // Create operation and add to global queue
     CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), height + 1);
     std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
-    std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(tb, 
-                                                                                 contextualTx, 
-                                                                                 sourceAddress, 
-                                                                                 tOutputs, 
-                                                                                 zOutputs,
-                                                                                 hasZSource ? 1 : 0, 
-                                                                                 feeAmount, 
-                                                                                 uniOutputs,
-                                                                                 true) );
+    std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(tb, 
+                                                                                contextualTx, 
+                                                                                sourceAddress, 
+                                                                                tOutputs, 
+                                                                                zOutputs,
+                                                                                hasZSource ? 1 : 0, 
+                                                                                feeAmount, 
+                                                                                uniOutputs,
+                                                                                true) );
     q->addOperation(operation);
     AsyncRPCOperationId operationId = operation->getId();
     return operationId;
This page took 0.054484 seconds and 4 git commands to generate.