mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
partial serialization of tx wallet and transfer
This commit is contained in:
@@ -24,13 +24,14 @@ namespace monero {
|
||||
if (primaryAddress != boost::none) node.put("primaryAddress", *primaryAddress);
|
||||
if (balance != boost::none) node.put("balance", *balance);
|
||||
if (unlockedBalance != boost::none) node.put("unlockedBalance", *unlockedBalance);
|
||||
if (!subaddresses.empty()) {
|
||||
boost::property_tree::ptree subaddressesNode;
|
||||
for (const MoneroSubaddress& subaddress : subaddresses) {
|
||||
subaddressesNode.push_back(std::make_pair("", subaddress.toPropertyTree()));
|
||||
}
|
||||
node.add_child("subaddresses", subaddressesNode);
|
||||
}
|
||||
if (!subaddresses.empty()) node.add_child("subaddresses", MoneroUtils::toPropertyTree(subaddresses));
|
||||
// if (!subaddresses.empty()) {
|
||||
// boost::property_tree::ptree subaddressesNode;
|
||||
// for (const MoneroSubaddress& subaddress : subaddresses) {
|
||||
// subaddressesNode.push_back(std::make_pair("", subaddress.toPropertyTree()));
|
||||
// }
|
||||
// node.add_child("subaddresses", subaddressesNode);
|
||||
// }
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,13 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree MoneroTxWallet::toPropertyTree() const {
|
||||
cout << "MoneroTxWallet::toPropertyTree(node)" << endl;
|
||||
throw runtime_error("Not implemented");
|
||||
boost::property_tree::ptree node = MoneroTx::toPropertyTree();
|
||||
if (!vouts.empty()) throw runtime_error("vouts not implemented");
|
||||
if (!incomingTransfers.empty()) MoneroUtils::toPropertyTree(incomingTransfers);
|
||||
if (outgoingTransfer != boost::none) throw runtime_error("outgoingTransfers not implemented");
|
||||
if (numSuggestedConfirmations != boost::none) node.put("numSuggestedConfirmations", *numSuggestedConfirmations);
|
||||
if (note != boost::none) node.put("note", *note);
|
||||
return node;
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const {
|
||||
@@ -59,6 +66,31 @@ namespace monero {
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroTransfer::toPropertyTree() const {
|
||||
cout << "MoneroTransfer::toPropertyTree(node)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (amount != boost::none) node.put("amount", *amount);
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
return node;
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroIncomingTransfer::toPropertyTree() const {
|
||||
cout << "MoneroIncomingTransfer::toPropertyTree(node)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex);
|
||||
if (address != boost::none) node.put("address", *address);
|
||||
return node;
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroOutgoingTransfer::toPropertyTree() const {
|
||||
cout << "MoneroOutgoingTransfer::toPropertyTree(node)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (!subaddressIndices.empty()) throw runtime_error("subaddressIndices not implemented");
|
||||
if (!addresses.empty()) throw runtime_error("addresses not implemented");
|
||||
if (!destinations.empty()) throw runtime_error("destinations not implemented");
|
||||
return node;
|
||||
}
|
||||
|
||||
//boost::property_tree::ptree MoneroUtils::txWalletToPropertyTree(const MoneroTxWallet& tx) {
|
||||
// cout << "txWalletToPropertyTree(tx)" << endl;
|
||||
// boost::property_tree::ptree txNode = txToPropertyTree(tx);
|
||||
|
||||
@@ -93,11 +93,13 @@ namespace monero {
|
||||
/**
|
||||
* Models a base transfer of funds to or from the wallet.
|
||||
*/
|
||||
struct MoneroTransfer {
|
||||
struct MoneroTransfer : SerializableStruct {
|
||||
shared_ptr<MoneroTxWallet> tx;
|
||||
boost::optional<uint64_t> amount;
|
||||
boost::optional<uint32_t> accountIndex;
|
||||
boost::optional<bool> isIncoming;
|
||||
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -106,6 +108,8 @@ namespace monero {
|
||||
struct MoneroIncomingTransfer : public MoneroTransfer {
|
||||
boost::optional<uint32_t> subaddressIndex;
|
||||
boost::optional<string> address;
|
||||
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -115,6 +119,8 @@ namespace monero {
|
||||
vector<uint32_t> subaddressIndices;
|
||||
vector<string> addresses;
|
||||
vector<MoneroDestination> destinations;
|
||||
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user