LCOV - code coverage report
Current view: top level - src/sapling - sapling_core_write.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 37 37 100.0 %
Date: 2026-08-09 10:51:41 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2015-2020 The Zcash developers
       2             : // Copyright (c) 2020-2021 The PIVX Core developers
       3             : // Distributed under the MIT software license, see the accompanying
       4             : // file COPYING or https://www.opensource.org/licenses/mit-license.php.
       5             : 
       6             : #include "sapling/sapling_core_write.h"
       7             : #include "utilstrencodings.h"
       8             : #include "utilmoneystr.h"
       9             : 
      10          22 : static UniValue TxShieldedSpendsToJSON(const CTransaction& tx) {
      11          22 :     UniValue vdesc(UniValue::VARR);
      12          22 :     if (tx.sapData) {
      13          45 :         for (const SpendDescription& spendDesc : tx.sapData->vShieldedSpend) {
      14          46 :             UniValue obj(UniValue::VOBJ);
      15          46 :             obj.pushKV("cv", spendDesc.cv.GetHex());
      16          46 :             obj.pushKV("anchor", spendDesc.anchor.GetHex());
      17          46 :             obj.pushKV("nullifier", spendDesc.nullifier.GetHex());
      18          46 :             obj.pushKV("rk", spendDesc.rk.GetHex());
      19          46 :             obj.pushKV("proof", HexStr(spendDesc.zkproof));
      20          46 :             obj.pushKV("spendAuthSig", HexStr(spendDesc.spendAuthSig));
      21          23 :             vdesc.push_back(obj);
      22             :         }
      23             :     }
      24          22 :     return vdesc;
      25             : }
      26             : 
      27          22 : static UniValue TxShieldedOutputsToJSON(const CTransaction& tx) {
      28          22 :     UniValue vdesc(UniValue::VARR);
      29          22 :     if (tx.sapData) {
      30          46 :         for (const OutputDescription& outputDesc : tx.sapData->vShieldedOutput) {
      31          48 :             UniValue obj(UniValue::VOBJ);
      32          48 :             obj.pushKV("cv", outputDesc.cv.GetHex());
      33          48 :             obj.pushKV("cmu", outputDesc.cmu.GetHex());
      34          48 :             obj.pushKV("ephemeralKey", outputDesc.ephemeralKey.GetHex());
      35          48 :             obj.pushKV("encCiphertext", HexStr(outputDesc.encCiphertext));
      36          48 :             obj.pushKV("outCiphertext", HexStr(outputDesc.outCiphertext));
      37          48 :             obj.pushKV("proof", HexStr(outputDesc.zkproof));
      38          24 :             vdesc.push_back(obj);
      39             :         }
      40             :     }
      41          22 :     return vdesc;
      42             : }
      43             : 
      44         937 : void TxSaplingToJSON(const CTransaction& tx, UniValue& entry) {
      45         937 :     if (tx.IsShieldedTx()) {
      46          44 :         entry.pushKV("valueBalance", FormatMoney(tx.sapData->valueBalance));
      47          22 :         entry.pushKV("valueBalanceSat", tx.sapData->valueBalance);
      48          44 :         UniValue vspenddesc = TxShieldedSpendsToJSON(tx);
      49          22 :         entry.pushKV("vShieldSpend", vspenddesc);
      50          44 :         UniValue voutputdesc = TxShieldedOutputsToJSON(tx);
      51          22 :         entry.pushKV("vShieldOutput", voutputdesc);
      52          22 :         if (tx.sapData->hasBindingSig()) {
      53          66 :             entry.pushKV("bindingSig", HexStr(tx.sapData->bindingSig));
      54             :         }
      55             :     }
      56         937 : }

Generated by: LCOV version 1.14