LCOV - code coverage report
Current view: top level - src/rpc - rawtransaction_util.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 94.9 % 196 186
Test Date: 2024-07-04 05:05:02 Functions: 100.0 % 9 9
Branches: 59.6 % 460 274

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2010 Satoshi Nakamoto
       2                 :             : // Copyright (c) 2009-2022 The Bitcoin Core developers
       3                 :             : // Distributed under the MIT software license, see the accompanying
       4                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5                 :             : 
       6                 :             : #include <rpc/rawtransaction_util.h>
       7                 :             : 
       8                 :             : #include <coins.h>
       9                 :             : #include <consensus/amount.h>
      10                 :             : #include <core_io.h>
      11                 :             : #include <key_io.h>
      12                 :             : #include <policy/policy.h>
      13                 :             : #include <primitives/transaction.h>
      14                 :             : #include <rpc/request.h>
      15                 :             : #include <rpc/util.h>
      16                 :             : #include <script/sign.h>
      17                 :             : #include <script/signingprovider.h>
      18                 :             : #include <tinyformat.h>
      19                 :             : #include <univalue.h>
      20                 :             : #include <util/rbf.h>
      21                 :             : #include <util/strencodings.h>
      22                 :             : #include <util/translation.h>
      23                 :             : 
      24                 :        1663 : void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, std::optional<bool> rbf)
      25                 :             : {
      26         [ +  + ]:        1663 :     UniValue inputs;
      27         [ +  + ]:        1663 :     if (inputs_in.isNull()) {
      28                 :         446 :         inputs = UniValue::VARR;
      29                 :             :     } else {
      30   [ +  -  +  - ]:        1217 :         inputs = inputs_in.get_array();
      31                 :             :     }
      32                 :             : 
      33         [ +  + ]:        7941 :     for (unsigned int idx = 0; idx < inputs.size(); idx++) {
      34         [ +  - ]:        6287 :         const UniValue& input = inputs[idx];
      35         [ +  + ]:        6287 :         const UniValue& o = input.get_obj();
      36                 :             : 
      37         [ +  + ]:        6286 :         Txid txid = Txid::FromUint256(ParseHashO(o, "txid"));
      38                 :             : 
      39         [ +  - ]:        6283 :         const UniValue& vout_v = o.find_value("vout");
      40         [ +  + ]:        6283 :         if (!vout_v.isNum())
      41   [ +  -  +  - ]:           4 :             throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
      42         [ +  - ]:        6281 :         int nOutput = vout_v.getInt<int>();
      43         [ +  + ]:        6281 :         if (nOutput < 0)
      44   [ +  -  +  - ]:           2 :             throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
      45                 :             : 
      46                 :        6280 :         uint32_t nSequence;
      47                 :             : 
      48   [ +  +  +  + ]:        6280 :         if (rbf.value_or(true)) {
      49                 :             :             nSequence = MAX_BIP125_RBF_SEQUENCE; /* CTxIn::SEQUENCE_FINAL - 2 */
      50         [ +  + ]:         439 :         } else if (rawTx.nLockTime) {
      51                 :             :             nSequence = CTxIn::MAX_SEQUENCE_NONFINAL; /* CTxIn::SEQUENCE_FINAL - 1 */
      52                 :             :         } else {
      53                 :         435 :             nSequence = CTxIn::SEQUENCE_FINAL;
      54                 :             :         }
      55                 :             : 
      56                 :             :         // set the sequence number if passed in the parameters object
      57         [ +  - ]:        6280 :         const UniValue& sequenceObj = o.find_value("sequence");
      58         [ +  + ]:        6280 :         if (sequenceObj.isNum()) {
      59         [ +  - ]:          81 :             int64_t seqNr64 = sequenceObj.getInt<int64_t>();
      60         [ +  + ]:          81 :             if (seqNr64 < 0 || seqNr64 > CTxIn::SEQUENCE_FINAL) {
      61   [ +  -  +  - ]:           4 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence number is out of range");
      62                 :             :             } else {
      63                 :          79 :                 nSequence = (uint32_t)seqNr64;
      64                 :             :             }
      65                 :             :         }
      66                 :             : 
      67         [ +  - ]:        6278 :         CTxIn in(COutPoint(txid, nOutput), CScript(), nSequence);
      68                 :             : 
      69         [ +  - ]:        6278 :         rawTx.vin.push_back(in);
      70                 :        6278 :     }
      71                 :        1663 : }
      72                 :             : 
      73                 :        2449 : UniValue NormalizeOutputs(const UniValue& outputs_in)
      74                 :             : {
      75         [ -  + ]:        2449 :     if (outputs_in.isNull()) {
      76   [ #  #  #  # ]:           0 :         throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, output argument must be non-null");
      77                 :             :     }
      78                 :             : 
      79                 :        2449 :     const bool outputs_is_obj = outputs_in.isObject();
      80         [ +  + ]:        2449 :     UniValue outputs = outputs_is_obj ? outputs_in.get_obj() : outputs_in.get_array();
      81                 :             : 
      82         [ +  + ]:        2448 :     if (!outputs_is_obj) {
      83                 :             :         // Translate array of key-value pairs into dict
      84                 :        1364 :         UniValue outputs_dict = UniValue(UniValue::VOBJ);
      85         [ +  + ]:       14764 :         for (size_t i = 0; i < outputs.size(); ++i) {
      86         [ +  - ]:       13402 :             const UniValue& output = outputs[i];
      87         [ +  + ]:       13402 :             if (!output.isObject()) {
      88   [ +  -  +  - ]:           2 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, key-value pair not an object as expected");
      89                 :             :             }
      90         [ +  + ]:       13401 :             if (output.size() != 1) {
      91   [ +  -  +  - ]:           2 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, key-value pair must contain exactly one key");
      92                 :             :             }
      93   [ +  -  +  - ]:       13400 :             outputs_dict.pushKVs(output);
      94                 :             :         }
      95                 :        1362 :         outputs = std::move(outputs_dict);
      96                 :        1364 :     }
      97                 :        2446 :     return outputs;
      98                 :           2 : }
      99                 :             : 
     100                 :        4971 : std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs)
     101                 :             : {
     102                 :             :     // Duplicate checking
     103         [ +  - ]:        4971 :     std::set<CTxDestination> destinations;
     104                 :        4971 :     std::vector<std::pair<CTxDestination, CAmount>> parsed_outputs;
     105                 :        4971 :     bool has_data{false};
     106   [ +  -  +  + ]:       34371 :     for (const std::string& name_ : outputs.getKeys()) {
     107         [ +  + ]:       29423 :         if (name_ == "data") {
     108         [ +  + ]:          33 :             if (has_data) {
     109   [ +  -  +  - ]:           8 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, duplicate key: data");
     110                 :             :             }
     111                 :          29 :             has_data = true;
     112   [ +  -  +  -  :          29 :             std::vector<unsigned char> data = ParseHexV(outputs[name_].getValStr(), "Data");
                   +  + ]
     113         [ +  - ]:          24 :             CTxDestination destination{CNoDestination{CScript() << OP_RETURN << data}};
     114                 :          24 :             CAmount amount{0};
     115         [ +  - ]:          24 :             parsed_outputs.emplace_back(destination, amount);
     116                 :          24 :         } else {
     117         [ +  - ]:       29390 :             CTxDestination destination{DecodeDestination(name_)};
     118   [ +  -  +  + ]:       29390 :             CAmount amount{AmountFromValue(outputs[name_])};
     119   [ +  -  +  + ]:       29383 :             if (!IsValidDestination(destination)) {
     120   [ +  -  +  -  :           2 :                 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + name_);
                   +  - ]
     121                 :             :             }
     122                 :             : 
     123   [ +  -  +  + ]:       29382 :             if (!destinations.insert(destination).second) {
     124   [ +  -  +  -  :          12 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
                   +  - ]
     125                 :             :             }
     126         [ +  - ]:       29376 :             parsed_outputs.emplace_back(destination, amount);
     127                 :       29390 :         }
     128                 :             :     }
     129                 :        4948 :     return parsed_outputs;
     130                 :        4971 : }
     131                 :             : 
     132                 :        1674 : void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
     133                 :             : {
     134                 :        1674 :     UniValue outputs(UniValue::VOBJ);
     135         [ +  + ]:        1674 :     outputs = NormalizeOutputs(outputs_in);
     136                 :             : 
     137         [ +  + ]:        1671 :     std::vector<std::pair<CTxDestination, CAmount>> parsed_outputs = ParseOutputs(outputs);
     138   [ +  -  +  + ]:       10241 :     for (const auto& [destination, nAmount] : parsed_outputs) {
     139         [ +  - ]:        8587 :         CScript scriptPubKey = GetScriptForDestination(destination);
     140                 :             : 
     141         [ +  - ]:        8587 :         CTxOut out(nAmount, scriptPubKey);
     142         [ +  - ]:        8587 :         rawTx.vout.push_back(out);
     143                 :        8587 :     }
     144                 :        1674 : }
     145                 :             : 
     146                 :        1665 : CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf)
     147                 :             : {
     148                 :        1665 :     CMutableTransaction rawTx;
     149                 :             : 
     150         [ +  + ]:        1665 :     if (!locktime.isNull()) {
     151         [ +  - ]:         252 :         int64_t nLockTime = locktime.getInt<int64_t>();
     152         [ +  + ]:         252 :         if (nLockTime < 0 || nLockTime > LOCKTIME_MAX)
     153   [ +  -  +  - ]:           4 :             throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range");
     154                 :         250 :         rawTx.nLockTime = nLockTime;
     155                 :             :     }
     156                 :             : 
     157         [ +  + ]:        1663 :     AddInputs(rawTx, inputs_in, rbf);
     158         [ +  + ]:        1654 :     AddOutputs(rawTx, outputs_in);
     159                 :             : 
     160   [ +  +  +  +  :        1852 :     if (rbf.has_value() && rbf.value() && rawTx.vin.size() > 0 && !SignalsOptInRBF(CTransaction(rawTx))) {
          +  +  +  -  +  
             -  +  +  +  
                      + ]
     161   [ +  -  +  - ]:           2 :         throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number(s) contradict replaceable option");
     162                 :             :     }
     163                 :             : 
     164                 :        1637 :     return rawTx;
     165                 :          28 : }
     166                 :             : 
     167                 :             : /** Pushes a JSON object for script verification or signing errors to vErrorsRet. */
     168                 :          85 : static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage)
     169                 :             : {
     170                 :          85 :     UniValue entry(UniValue::VOBJ);
     171   [ +  -  +  -  :         170 :     entry.pushKV("txid", txin.prevout.hash.ToString());
             +  -  +  - ]
     172   [ +  -  +  -  :         170 :     entry.pushKV("vout", (uint64_t)txin.prevout.n);
                   +  - ]
     173                 :          85 :     UniValue witness(UniValue::VARR);
     174         [ +  + ]:         491 :     for (unsigned int i = 0; i < txin.scriptWitness.stack.size(); i++) {
     175   [ +  -  +  -  :         406 :         witness.push_back(HexStr(txin.scriptWitness.stack[i]));
                   +  - ]
     176                 :             :     }
     177   [ +  -  +  - ]:         170 :     entry.pushKV("witness", std::move(witness));
     178   [ +  +  +  -  :         255 :     entry.pushKV("scriptSig", HexStr(txin.scriptSig));
          +  -  +  -  +  
                      - ]
     179   [ +  -  +  -  :         170 :     entry.pushKV("sequence", (uint64_t)txin.nSequence);
                   +  - ]
     180   [ +  -  +  -  :         170 :     entry.pushKV("error", strMessage);
                   +  - ]
     181         [ +  - ]:          85 :     vErrorsRet.push_back(std::move(entry));
     182                 :          85 : }
     183                 :             : 
     184                 :         683 : void ParsePrevouts(const UniValue& prevTxsUnival, FlatSigningProvider* keystore, std::map<COutPoint, Coin>& coins)
     185                 :             : {
     186         [ +  + ]:         683 :     if (!prevTxsUnival.isNull()) {
     187                 :         209 :         const UniValue& prevTxs = prevTxsUnival.get_array();
     188         [ +  + ]:         323 :         for (unsigned int idx = 0; idx < prevTxs.size(); ++idx) {
     189                 :         212 :             const UniValue& p = prevTxs[idx];
     190         [ -  + ]:         212 :             if (!p.isObject()) {
     191   [ #  #  #  # ]:           0 :                 throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
     192                 :             :             }
     193                 :             : 
     194                 :         212 :             const UniValue& prevOut = p.get_obj();
     195                 :             : 
     196   [ +  +  +  +  :        1078 :             RPCTypeCheckObj(prevOut,
                   +  + ]
     197                 :             :                 {
     198         [ +  - ]:         212 :                     {"txid", UniValueType(UniValue::VSTR)},
     199         [ +  - ]:         212 :                     {"vout", UniValueType(UniValue::VNUM)},
     200         [ +  - ]:         212 :                     {"scriptPubKey", UniValueType(UniValue::VSTR)},
     201                 :             :                 });
     202                 :             : 
     203                 :         194 :             Txid txid = Txid::FromUint256(ParseHashO(prevOut, "txid"));
     204                 :             : 
     205                 :         194 :             int nOut = prevOut.find_value("vout").getInt<int>();
     206         [ -  + ]:         194 :             if (nOut < 0) {
     207   [ #  #  #  # ]:           0 :                 throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout cannot be negative");
     208                 :             :             }
     209                 :             : 
     210                 :         194 :             COutPoint out(txid, nOut);
     211                 :         194 :             std::vector<unsigned char> pkData(ParseHexO(prevOut, "scriptPubKey"));
     212                 :         194 :             CScript scriptPubKey(pkData.begin(), pkData.end());
     213                 :             : 
     214                 :         194 :             {
     215                 :         194 :                 auto coin = coins.find(out);
     216   [ +  -  +  +  :         194 :                 if (coin != coins.end() && !coin->second.IsSpent() && coin->second.out.scriptPubKey != scriptPubKey) {
                   -  + ]
     217         [ #  # ]:           0 :                     std::string err("Previous output scriptPubKey mismatch:\n");
     218   [ #  #  #  #  :           0 :                     err = err + ScriptToAsmStr(coin->second.out.scriptPubKey) + "\nvs:\n"+
                   #  # ]
     219         [ #  # ]:           0 :                         ScriptToAsmStr(scriptPubKey);
     220         [ #  # ]:           0 :                     throw JSONRPCError(RPC_DESERIALIZATION_ERROR, err);
     221                 :           0 :                 }
     222                 :         194 :                 Coin newcoin;
     223                 :         194 :                 newcoin.out.scriptPubKey = scriptPubKey;
     224                 :         194 :                 newcoin.out.nValue = MAX_MONEY;
     225   [ +  -  +  + ]:         388 :                 if (prevOut.exists("amount")) {
     226   [ +  -  +  - ]:         176 :                     newcoin.out.nValue = AmountFromValue(prevOut.find_value("amount"));
     227                 :             :                 }
     228                 :         194 :                 newcoin.nHeight = 1;
     229         [ +  - ]:         194 :                 coins[out] = std::move(newcoin);
     230                 :           0 :             }
     231                 :             : 
     232                 :             :             // if redeemScript and private keys were given, add redeemScript to the keystore so it can be signed
     233         [ +  - ]:         194 :             const bool is_p2sh = scriptPubKey.IsPayToScriptHash();
     234         [ +  - ]:         194 :             const bool is_p2wsh = scriptPubKey.IsPayToWitnessScriptHash();
     235   [ +  +  +  + ]:         194 :             if (keystore && (is_p2sh || is_p2wsh)) {
     236   [ +  -  +  +  :         676 :                 RPCTypeCheckObj(prevOut,
                   -  - ]
     237                 :             :                     {
     238         [ +  - ]:         169 :                         {"redeemScript", UniValueType(UniValue::VSTR)},
     239         [ +  - ]:         169 :                         {"witnessScript", UniValueType(UniValue::VSTR)},
     240                 :             :                     }, true);
     241         [ +  - ]:         169 :                 const UniValue& rs{prevOut.find_value("redeemScript")};
     242         [ +  - ]:         169 :                 const UniValue& ws{prevOut.find_value("witnessScript")};
     243   [ +  +  +  + ]:         169 :                 if (rs.isNull() && ws.isNull()) {
     244   [ +  -  +  - ]:          40 :                     throw JSONRPCError(RPC_INVALID_PARAMETER, "Missing redeemScript/witnessScript");
     245                 :             :                 }
     246                 :             : 
     247                 :             :                 // work from witnessScript when possible
     248   [ +  +  +  -  :         149 :                 std::vector<unsigned char> scriptData(!ws.isNull() ? ParseHexV(ws, "witnessScript") : ParseHexV(rs, "redeemScript"));
                   +  - ]
     249                 :         149 :                 CScript script(scriptData.begin(), scriptData.end());
     250   [ +  -  +  - ]:         149 :                 keystore->scripts.emplace(CScriptID(script), script);
     251                 :             :                 // Automatically also add the P2WSH wrapped version of the script (to deal with P2SH-P2WSH).
     252                 :             :                 // This is done for redeemScript only for compatibility, it is encouraged to use the explicit witnessScript field instead.
     253   [ +  -  +  - ]:         149 :                 CScript witness_output_script{GetScriptForDestination(WitnessV0ScriptHash(script))};
     254   [ +  -  +  - ]:         149 :                 keystore->scripts.emplace(CScriptID(witness_output_script), witness_output_script);
     255                 :             : 
     256   [ +  +  +  + ]:         149 :                 if (!ws.isNull() && !rs.isNull()) {
     257                 :             :                     // if both witnessScript and redeemScript are provided,
     258                 :             :                     // they should either be the same (for backwards compat),
     259                 :             :                     // or the redeemScript should be the encoded form of
     260                 :             :                     // the witnessScript (ie, for p2sh-p2wsh)
     261   [ +  -  +  -  :          43 :                     if (ws.get_str() != rs.get_str()) {
                   +  + ]
     262         [ +  - ]:          23 :                         std::vector<unsigned char> redeemScriptData(ParseHexV(rs, "redeemScript"));
     263                 :          23 :                         CScript redeemScript(redeemScriptData.begin(), redeemScriptData.end());
     264         [ +  + ]:          23 :                         if (redeemScript != witness_output_script) {
     265   [ +  -  +  - ]:          40 :                             throw JSONRPCError(RPC_INVALID_PARAMETER, "redeemScript does not correspond to witnessScript");
     266                 :             :                         }
     267                 :          43 :                     }
     268                 :             :                 }
     269                 :             : 
     270         [ +  + ]:         129 :                 if (is_p2sh) {
     271         [ +  - ]:          87 :                     const CTxDestination p2sh{ScriptHash(script)};
     272         [ +  - ]:          87 :                     const CTxDestination p2sh_p2wsh{ScriptHash(witness_output_script)};
     273   [ +  -  +  + ]:          87 :                     if (scriptPubKey == GetScriptForDestination(p2sh)) {
     274                 :             :                         // traditional p2sh; arguably an error if
     275                 :             :                         // we got here with rs.IsNull(), because
     276                 :             :                         // that means the p2sh script was specified
     277                 :             :                         // via witnessScript param, but for now
     278                 :             :                         // we'll just quietly accept it
     279   [ +  -  +  + ]:          58 :                     } else if (scriptPubKey == GetScriptForDestination(p2sh_p2wsh)) {
     280                 :             :                         // p2wsh encoded as p2sh; ideally the witness
     281                 :             :                         // script was specified in the witnessScript
     282                 :             :                         // param, but also support specifying it via
     283                 :             :                         // redeemScript param for backwards compat
     284                 :             :                         // (in which case ws.IsNull() == true)
     285                 :             :                     } else {
     286                 :             :                         // otherwise, can't generate scriptPubKey from
     287                 :             :                         // either script, so we got unusable parameters
     288   [ +  -  +  - ]:          52 :                         throw JSONRPCError(RPC_INVALID_PARAMETER, "redeemScript/witnessScript does not match scriptPubKey");
     289                 :             :                     }
     290         [ +  - ]:         155 :                 } else if (is_p2wsh) {
     291                 :             :                     // plain p2wsh; could throw an error if script
     292                 :             :                     // was specified by redeemScript rather than
     293                 :             :                     // witnessScript (ie, ws.IsNull() == true), but
     294                 :             :                     // accept it for backwards compat
     295         [ +  - ]:          42 :                     const CTxDestination p2wsh{WitnessV0ScriptHash(script)};
     296   [ +  -  +  + ]:          84 :                     if (scriptPubKey != GetScriptForDestination(p2wsh)) {
     297   [ +  -  +  - ]:          28 :                         throw JSONRPCError(RPC_INVALID_PARAMETER, "redeemScript/witnessScript does not match scriptPubKey");
     298                 :             :                     }
     299                 :          42 :                 }
     300                 :         269 :             }
     301                 :         194 :         }
     302                 :             :     }
     303   [ +  -  +  -  :         984 : }
          +  -  +  -  +  
          -  +  -  +  -  
             -  +  -  - ]
     304                 :             : 
     305                 :         100 : void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result)
     306                 :             : {
     307                 :         100 :     int nHashType = ParseSighashString(hashType);
     308                 :             : 
     309                 :             :     // Script verification errors
     310         [ +  - ]:          99 :     std::map<int, bilingual_str> input_errors;
     311                 :             : 
     312         [ +  - ]:          99 :     bool complete = SignTransaction(mtx, keystore, coins, nHashType, input_errors);
     313         [ +  - ]:          99 :     SignTransactionResultToJSON(mtx, complete, coins, input_errors, result);
     314                 :             : }
     315                 :             : 
     316                 :         582 : void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, const std::map<int, bilingual_str>& input_errors, UniValue& result)
     317                 :             : {
     318                 :             :     // Make errors UniValue
     319                 :         582 :     UniValue vErrors(UniValue::VARR);
     320         [ +  + ]:         667 :     for (const auto& err_pair : input_errors) {
     321         [ +  + ]:          89 :         if (err_pair.second.original == "Missing amount") {
     322                 :             :             // This particular error needs to be an exception for some reason
     323   [ +  -  +  -  :           8 :             throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing amount for %s", coins.at(mtx.vin.at(err_pair.first).prevout).out.ToString()));
          +  -  +  -  +  
                      - ]
     324                 :             :         }
     325   [ +  -  +  - ]:          85 :         TxInErrorToJSON(mtx.vin.at(err_pair.first), vErrors, err_pair.second.original);
     326                 :             :     }
     327                 :             : 
     328   [ +  -  +  -  :        1156 :     result.pushKV("hex", EncodeHexTx(CTransaction(mtx)));
          +  -  +  -  +  
                      - ]
     329   [ +  -  +  -  :        1156 :     result.pushKV("complete", complete);
                   +  - ]
     330         [ +  + ]:         578 :     if (!vErrors.empty()) {
     331   [ +  -  -  + ]:         162 :         if (result.exists("errors")) {
     332   [ #  #  #  #  :           0 :             vErrors.push_backV(result["errors"].getValues());
             #  #  #  # ]
     333                 :             :         }
     334   [ +  -  +  - ]:         162 :         result.pushKV("errors", std::move(vErrors));
     335                 :             :     }
     336                 :         582 : }
        

Generated by: LCOV version 2.0-1