ELEMENTS ONLY
| 93 | |
| 94 | // ELEMENTS ONLY |
| 95 | uint256 CTransaction::GetWitnessOnlyHash() const |
| 96 | { |
| 97 | assert(g_con_elementsmode); |
| 98 | |
| 99 | std::vector<uint256> leaves; |
| 100 | leaves.reserve(std::max(vin.size(), vout.size())); |
| 101 | /* Inputs */ |
| 102 | for (size_t i = 0; i < vin.size(); ++i) { |
| 103 | // Input has no witness OR is null input(coinbase) |
| 104 | const CTxInWitness& txinwit = (witness.vtxinwit.size() <= i || vin[i].prevout.IsNull()) ? CTxInWitness() : witness.vtxinwit[i]; |
| 105 | leaves.push_back(txinwit.GetHash()); |
| 106 | } |
| 107 | uint256 hashIn = ComputeFastMerkleRoot(leaves); |
| 108 | leaves.clear(); |
| 109 | /* Outputs */ |
| 110 | for (size_t i = 0; i < vout.size(); ++i) { |
| 111 | const CTxOutWitness& txoutwit = witness.vtxoutwit.size() <= i ? CTxOutWitness() : witness.vtxoutwit[i]; |
| 112 | leaves.push_back(txoutwit.GetHash()); |
| 113 | } |
| 114 | uint256 hashOut = ComputeFastMerkleRoot(leaves); |
| 115 | leaves.clear(); |
| 116 | /* Combined */ |
| 117 | leaves.push_back(hashIn); |
| 118 | leaves.push_back(hashOut); |
| 119 | return ComputeFastMerkleRoot(leaves); |
| 120 | } |
| 121 | |
| 122 | CTransaction::CTransaction(const CMutableTransaction& tx) : |
| 123 | vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), witness(tx.witness), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {} |
no test coverage detected