From c5ceac8443e9c8e038c047055a96a8de5134c82c Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 17 Dec 2023 11:13:14 -0500 Subject: [PATCH] View transparent spends and shielded outputs in txs; Allow double clicking on a tx in tx tab to view tx --- src/mainwindow.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 31cbe36..ef52210 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -958,11 +958,89 @@ void MainWindow::viewTxid(QString txid) { property_value = props.toObject()[property_name].toBool() ? "true" : "false" ; } else if (props.toObject()[property_name].isArray()) { DEBUG( property_name << " is an array"); + // vin is the Vector of INputs of transparent spends + if( property_name == "vin" ) { + int index = 0; + auto vins = props.toObject()[property_name].toArray(); + for (const auto& vin : vins) { + QString this_vin = "vin " + QString::number(index); + auto vinObj = vin.toObject(); + + // Is this a normal input or coinbase input? + bool is_coinbase = vinObj["coinbase"].toString().length() > 0; + + if (is_coinbase) { + propsList.append( + QPair( this_vin + " coinbase", vinObj["coinbase"].toString() ) + ); + } else { + // the address of this spend + propsList.append( + QPair( this_vin + " address", vinObj["address"].toString() ) + ); + // the value of this spend + propsList.append( + QPair( this_vin + " value", QString::number(vinObj["value"].toDouble()) ) + ); + // the txid in which this UTXO was created + propsList.append( + QPair( this_vin + " txid", vinObj["txid"].toString() ) + ); + // the index of vout in the txid it was created + propsList.append( + QPair( this_vin + " vout", QString::number(vinObj["vout"].toInt()) ) + ); + } + // sequence number is part of both coinbase and non-coinbase vins + propsList.append( + QPair( this_vin + " sequence", QString::number(vinObj["sequence"].toDouble()) ) + ); + index++; + } + } else if (property_name == "vout") { + // vout = Vector of OUTputs of transparent sends + auto vouts = props.toObject()[property_name].toArray(); + if(vouts.size() == 0) { + propsList.append( QPair( "vout", "Empty") ); + } else { + //... + } + } else if (property_name == "vShieldedOutput") { + // the vector of shielded outputs + auto zouts = props.toObject()[property_name].toArray(); + if(zouts.size() == 0) { + propsList.append( QPair( property_name, "Empty")); + } else { + int index = 0; + QString property_value = ""; + for (const auto& zout : zouts) { + auto zoutObj = zout.toObject(); + auto properties = {"proof", "cv", "cmu", "encCiphertext", "outCiphertext", "ephemeralKey" }; + for(const auto& prop : properties ) { + propsList.append( + QPair( "vShieldedOutput " + QString::number(index) + " " + prop, zoutObj[prop].toString() ) + ); + } + index++; + } + } + } else if (property_name == "vShieldedSpend") { + // the vector of shielded spends + auto zins = props.toObject()[property_name].toArray(); + if(zins.size() == 0) { + propsList.append( QPair( property_name, "Empty")); + } else { + // TODO + } + } } else if (props.toObject()[property_name].isObject()) { DEBUG( property_name << " is an object"); } - propsList.append( QPair( property_name, property_value )); + if (property_name != "vin" && property_name != "vout" && + property_name != "vShieldedOutput" && property_name != "vShieldedSpend" ) { + propsList.append( QPair( property_name, property_value )); + } } ValidateAddressesModel model(vt.tblProps, propsList); @@ -2141,6 +2219,11 @@ void MainWindow::setupTransactionsTab() { mb.exec(); } } + } else { + // if no memo, show View Transaction + DEBUG("double clicked tx index=" << index); + QString txid = txModel->getTxId(index.row()); + viewTxid(txid); } });