Implement basic Sapling v4 transaction parser

Details of Sapling datatypes will be filled in later; for now, they are treated
as binary blobs.

Includes code cherry-picked from upstream commit:
    7030d9eb47254499bba14f1c00abc6bf493efd91
    BIP144: Serialization, hashes, relay (sender side)
This commit is contained in:
Jack Grigg
2018-04-15 08:53:40 -06:00
parent 987b8ee60e
commit b7e75b17af
6 changed files with 257 additions and 31 deletions

View File

@@ -57,6 +57,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud
UniValue TxJoinSplitToJSON(const CTransaction& tx) {
bool useGroth = tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION;
UniValue vjoinsplit(UniValue::VARR);
for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) {
const JSDescription& jsdescription = tx.vjoinsplit[i];
@@ -95,7 +96,8 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) {
}
CDataStream ssProof(SER_NETWORK, PROTOCOL_VERSION);
ssProof << jsdescription.proof;
auto ps = SproutProofSerializer<CDataStream>(ssProof, useGroth);
boost::apply_visitor(ps, jsdescription.proof);
joinsplit.push_back(Pair("proof", HexStr(ssProof.begin(), ssProof.end())));
{