From 036f13697a045f1e993169354c3a030ca272e245 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 5 Jun 2019 11:27:04 -0400 Subject: [PATCH] defined tx/WalletToPropertyTree() to re-serialize given tx request --- src/utils/MoneroUtils.cpp | 33 +++++++++++++++++++++++++++++++++ src/utils/MoneroUtils.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/src/utils/MoneroUtils.cpp b/src/utils/MoneroUtils.cpp index 20abaed..5e25345 100644 --- a/src/utils/MoneroUtils.cpp +++ b/src/utils/MoneroUtils.cpp @@ -145,3 +145,36 @@ boost::property_tree::ptree MoneroUtils::toPropertyTree(const MoneroSubaddress& if (subaddress.numBlocksToUnlock != nullptr) subaddressNode.put("numBlocksToUnlock", *subaddress.numBlocksToUnlock); return subaddressNode; } + +// blockToPropertyTree + +boost::property_tree::ptree MoneroUtils::txToPropertyTree(const MoneroTx& tx) { + cout << "txToPropertyTree(tx)" << endl; + boost::property_tree::ptree txNode; + if (tx.id != nullptr) txNode.put("id", *tx.id); +// if (subaddress.accountIndex != nullptr) subaddressNode.put("accountIndex", *subaddress.accountIndex); +// if (subaddress.index != nullptr) subaddressNode.put("index", *subaddress.index); +// if (subaddress.address != nullptr) subaddressNode.put("address", *subaddress.address); +// if (subaddress.label != nullptr) subaddressNode.put("label", *subaddress.label); +// if (subaddress.balance != nullptr) subaddressNode.put("balance", *subaddress.balance); +// if (subaddress.unlockedBalance != nullptr) subaddressNode.put("unlockedBalance", *subaddress.unlockedBalance); +// if (subaddress.numUnspentOutputs != nullptr) subaddressNode.put("numUnspentOutputs", *subaddress.numUnspentOutputs); +// if (subaddress.isUsed != nullptr) subaddressNode.put("isUsed", *subaddress.isUsed); +// if (subaddress.numBlocksToUnlock != nullptr) subaddressNode.put("numBlocksToUnlock", *subaddress.numBlocksToUnlock); + return txNode; +} + +boost::property_tree::ptree MoneroUtils::txWalletToPropertyTree(const MoneroTxWallet& tx) { + cout << "txWalletToPropertyTree(tx)" << endl; + boost::property_tree::ptree txNode = txToPropertyTree(tx); +// if (subaddress.accountIndex != nullptr) subaddressNode.put("accountIndex", *subaddress.accountIndex); +// if (subaddress.index != nullptr) subaddressNode.put("index", *subaddress.index); +// if (subaddress.address != nullptr) subaddressNode.put("address", *subaddress.address); +// if (subaddress.label != nullptr) subaddressNode.put("label", *subaddress.label); +// if (subaddress.balance != nullptr) subaddressNode.put("balance", *subaddress.balance); +// if (subaddress.unlockedBalance != nullptr) subaddressNode.put("unlockedBalance", *subaddress.unlockedBalance); +// if (subaddress.numUnspentOutputs != nullptr) subaddressNode.put("numUnspentOutputs", *subaddress.numUnspentOutputs); +// if (subaddress.isUsed != nullptr) subaddressNode.put("isUsed", *subaddress.isUsed); +// if (subaddress.numBlocksToUnlock != nullptr) subaddressNode.put("numBlocksToUnlock", *subaddress.numBlocksToUnlock); + return txNode; +} diff --git a/src/utils/MoneroUtils.h b/src/utils/MoneroUtils.h index 8da5a10..011e838 100644 --- a/src/utils/MoneroUtils.h +++ b/src/utils/MoneroUtils.h @@ -66,6 +66,10 @@ namespace MoneroUtils boost::property_tree::ptree toPropertyTree(const MoneroSubaddress& subaddress); + boost::property_tree::ptree txToPropertyTree(const MoneroTx& tx); + + boost::property_tree::ptree txWalletToPropertyTree(const MoneroTxWallet& tx); + // // TODO: template implementation here, could move to MoneroUtils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation template boost::property_tree::ptree toPropertyTree(const vector types) { cout << "toPropertyTree(types)" << endl;