diff --git a/src/daemon/MoneroDaemon.cpp b/src/daemon/monero_daemon.cpp similarity index 100% rename from src/daemon/MoneroDaemon.cpp rename to src/daemon/monero_daemon.cpp diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/monero_daemon.h similarity index 98% rename from src/daemon/MoneroDaemon.h rename to src/daemon/monero_daemon.h index 2c31e50..a9c0486 100644 --- a/src/daemon/MoneroDaemon.h +++ b/src/daemon/monero_daemon.h @@ -52,7 +52,7 @@ #pragma once -#include "MoneroDaemonModel.h" +#include "monero_daemon_model.h" using namespace std; diff --git a/src/daemon/MoneroDaemonModel.cpp b/src/daemon/monero_daemon_model.cpp similarity index 61% rename from src/daemon/MoneroDaemonModel.cpp rename to src/daemon/monero_daemon_model.cpp index 3a9b997..7dc5d67 100644 --- a/src/daemon/MoneroDaemonModel.cpp +++ b/src/daemon/monero_daemon_model.cpp @@ -50,9 +50,9 @@ * Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers */ -#include "MoneroDaemonModel.h" +#include "monero_daemon_model.h" -#include "utils/MoneroUtils.h" +#include "utils/monero_utils.h" #include "include_base_utils.h" #include "common/util.h" @@ -63,8 +63,8 @@ namespace monero { // ----------------------- UNDECLARED PRIVATE HELPERS ----------------------- - void mergeTx(vector>& txs, const shared_ptr& tx) { - for (const shared_ptr& aTx : txs) { + void merge_tx(vector>& txs, const shared_ptr& tx) { + for (const shared_ptr& aTx : txs) { if (aTx->id.get() == tx->id.get()) { aTx->merge(aTx, tx); return; @@ -75,17 +75,17 @@ namespace monero { // ------------------------- INITIALIZE CONSTANTS --------------------------- - const string MoneroTx::DEFAULT_PAYMENT_ID = string("0000000000000000"); + const string monero_tx::DEFAULT_PAYMENT_ID = string("0000000000000000"); // ------------------------- SERIALIZABLE STRUCT ---------------------------- - string SerializableStruct::serialize() const { - return MoneroUtils::serialize(toPropertyTree()); + string serializable_struct::serialize() const { + return monero_utils::serialize(to_property_tree()); } // ------------------------- MONERO BLOCK HEADER ---------------------------- - boost::property_tree::ptree MoneroBlockHeader::toPropertyTree() const { + boost::property_tree::ptree monero_block_header::to_property_tree() const { boost::property_tree::ptree node; if (id != boost::none) node.put("id", *id); if (height != boost::none) node.put("height", *height); @@ -108,54 +108,54 @@ namespace monero { return node; } - void MoneroBlockHeader::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_block_header::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; - id = MoneroUtils::reconcile(id, other->id); - height = MoneroUtils::reconcile(height, other->height, boost::none, boost::none, true, "block height"); // height can increase - timestamp = MoneroUtils::reconcile(timestamp, other->timestamp, boost::none, boost::none, true, "block header timestamp"); // timestamp can increase - size = MoneroUtils::reconcile(size, other->size, "block header size"); - weight = MoneroUtils::reconcile(weight, other->weight, "block header weight"); - longTermWeight = MoneroUtils::reconcile(longTermWeight, other->longTermWeight, "block header long term weight"); - depth = MoneroUtils::reconcile(depth, other->depth, "block header depth"); - difficulty = MoneroUtils::reconcile(difficulty, other->difficulty, "difficulty"); - cumulativeDifficulty = MoneroUtils::reconcile(cumulativeDifficulty, other->cumulativeDifficulty, "cumulativeDifficulty"); - majorVersion = MoneroUtils::reconcile(majorVersion, other->majorVersion, "majorVersion"); - minorVersion = MoneroUtils::reconcile(minorVersion, other->minorVersion, "minorVersion"); - nonce = MoneroUtils::reconcile(nonce, other->nonce, "nonce"); - minerTxId = MoneroUtils::reconcile(minerTxId, other->minerTxId); - numTxs = MoneroUtils::reconcile(numTxs, other->numTxs, "block header numTxs"); - orphanStatus = MoneroUtils::reconcile(orphanStatus, other->orphanStatus); - prevId = MoneroUtils::reconcile(prevId, other->prevId); - reward = MoneroUtils::reconcile(reward, other->reward, "block header reward"); - powHash = MoneroUtils::reconcile(powHash, other->powHash); + id = monero_utils::reconcile(id, other->id); + height = monero_utils::reconcile(height, other->height, boost::none, boost::none, true, "block height"); // height can increase + timestamp = monero_utils::reconcile(timestamp, other->timestamp, boost::none, boost::none, true, "block header timestamp"); // timestamp can increase + size = monero_utils::reconcile(size, other->size, "block header size"); + weight = monero_utils::reconcile(weight, other->weight, "block header weight"); + longTermWeight = monero_utils::reconcile(longTermWeight, other->longTermWeight, "block header long term weight"); + depth = monero_utils::reconcile(depth, other->depth, "block header depth"); + difficulty = monero_utils::reconcile(difficulty, other->difficulty, "difficulty"); + cumulativeDifficulty = monero_utils::reconcile(cumulativeDifficulty, other->cumulativeDifficulty, "cumulativeDifficulty"); + majorVersion = monero_utils::reconcile(majorVersion, other->majorVersion, "majorVersion"); + minorVersion = monero_utils::reconcile(minorVersion, other->minorVersion, "minorVersion"); + nonce = monero_utils::reconcile(nonce, other->nonce, "nonce"); + minerTxId = monero_utils::reconcile(minerTxId, other->minerTxId); + numTxs = monero_utils::reconcile(numTxs, other->numTxs, "block header numTxs"); + orphanStatus = monero_utils::reconcile(orphanStatus, other->orphanStatus); + prevId = monero_utils::reconcile(prevId, other->prevId); + reward = monero_utils::reconcile(reward, other->reward, "block header reward"); + powHash = monero_utils::reconcile(powHash, other->powHash); } // ----------------------------- MONERO BLOCK ------------------------------- - boost::property_tree::ptree MoneroBlock::toPropertyTree() const { - boost::property_tree::ptree node = MoneroBlockHeader::toPropertyTree(); + boost::property_tree::ptree monero_block::to_property_tree() const { + boost::property_tree::ptree node = monero_block_header::to_property_tree(); if (hex != boost::none) node.put("hex", *hex); - if (minerTx != boost::none) node.add_child("minerTx", (*minerTx)->toPropertyTree()); - if (!txs.empty()) node.add_child("txs", MoneroUtils::toPropertyTree(txs)); - if (!txIds.empty()) node.add_child("txIds", MoneroUtils::toPropertyTree(txIds)); + if (minerTx != boost::none) node.add_child("minerTx", (*minerTx)->to_property_tree()); + if (!txs.empty()) node.add_child("txs", monero_utils::to_property_tree(txs)); + if (!txIds.empty()) node.add_child("txIds", monero_utils::to_property_tree(txIds)); return node; } - void MoneroBlock::merge(const shared_ptr& self, const shared_ptr& other) { - merge(static_pointer_cast(self), static_pointer_cast(other)); + void monero_block::merge(const shared_ptr& self, const shared_ptr& other) { + merge(static_pointer_cast(self), static_pointer_cast(other)); } - void MoneroBlock::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_block::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; // merge header fields - MoneroBlockHeader::merge(self, other); + monero_block_header::merge(self, other); // merge reconcilable block extensions - hex = MoneroUtils::reconcile(hex, other->hex); - txIds = MoneroUtils::reconcile(txIds, other->txIds); + hex = monero_utils::reconcile(hex, other->hex); + txIds = monero_utils::reconcile(txIds, other->txIds); // merge miner tx if (minerTx == boost::none) minerTx = other->minerTx; @@ -166,17 +166,17 @@ namespace monero { // merge non-miner txs if (!other->txs.empty()) { - for (const shared_ptr otherTx : other->txs) { // NOTE: not using reference so shared_ptr is not deleted when block is dereferenced + for (const shared_ptr otherTx : other->txs) { // NOTE: not using reference so shared_ptr is not deleted when block is dereferenced otherTx->block = self; - mergeTx(self->txs, otherTx); + merge_tx(self->txs, otherTx); } } } // ------------------------------- MONERO TX -------------------------------- - shared_ptr MoneroTx::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroTx::copy(const shared_ptr& src, const shared_ptr& tgt)"); + shared_ptr monero_tx::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_tx::copy(const shared_ptr& src, const shared_ptr& tgt)"); tgt->id = src->id; tgt->version = src->version; tgt->isMinerTx = src->isMinerTx; @@ -200,17 +200,17 @@ namespace monero { tgt->size = src->size; tgt->weight = src->weight; if (!src->vins.empty()) { - tgt->vins = vector>(); - for (const shared_ptr& vin : src->vins) { - shared_ptr vinCopy = vin->copy(vin, make_shared()); + tgt->vins = vector>(); + for (const shared_ptr& vin : src->vins) { + shared_ptr vinCopy = vin->copy(vin, make_shared()); vinCopy->tx = tgt; tgt->vins.push_back(vinCopy); } } if (!src->vouts.empty()) { - tgt->vouts = vector>(); - for (const shared_ptr& vout : src->vouts) { - shared_ptr voutCopy = vout->copy(vout, make_shared()); + tgt->vouts = vector>(); + for (const shared_ptr& vout : src->vouts) { + shared_ptr voutCopy = vout->copy(vout, make_shared()); voutCopy->tx = tgt; tgt->vouts.push_back(voutCopy); } @@ -231,7 +231,7 @@ namespace monero { return tgt; } - boost::property_tree::ptree MoneroTx::toPropertyTree() const { + boost::property_tree::ptree monero_tx::to_property_tree() const { boost::property_tree::ptree node; if (id != boost::none) node.put("id", *id); if (version != boost::none) node.put("version", *version); @@ -255,12 +255,12 @@ namespace monero { if (prunableHash != boost::none) node.put("prunableHash", *prunableHash); if (size != boost::none) node.put("size", *size); if (weight != boost::none) node.put("weight", *weight); - if (!vins.empty()) node.add_child("vins", MoneroUtils::toPropertyTree(vins)); - if (!vouts.empty()) node.add_child("vouts", MoneroUtils::toPropertyTree(vouts)); + if (!vins.empty()) node.add_child("vins", monero_utils::to_property_tree(vins)); + if (!vouts.empty()) node.add_child("vouts", monero_utils::to_property_tree(vouts)); if (!outputIndices.empty()) throw runtime_error("outputIndices not implemented"); if (metadata != boost::none) node.put("metadata", *metadata); if (commonTxSets != boost::none) throw runtime_error("commonTxSets not implemented"); - if (!extra.empty()) node.add_child("extra", MoneroUtils::toPropertyTree(extra)); + if (!extra.empty()) node.add_child("extra", monero_utils::to_property_tree(extra)); if (rctSignatures != boost::none) throw runtime_error("rctSignatures not implemented"); if (rctSigPrunable != boost::none) throw runtime_error("rctSigPrunable not implemented"); if (isKeptByBlock != boost::none) node.put("isKeptByBlock", *isKeptByBlock); @@ -273,70 +273,70 @@ namespace monero { return node; } - boost::optional MoneroTx::getHeight() const { + boost::optional monero_tx::get_height() const { if (block == boost::none) return boost::none; return *((*block)->height); } - void MoneroTx::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_tx::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; // merge blocks if they're different which comes back to merging txs if (block != other->block) { if (block == boost::none) { - block = make_shared(); + block = make_shared(); block.get()->txs.push_back(self); - block.get()->height = other->getHeight(); + block.get()->height = other->get_height(); } if (other->block == boost::none) { - other->block = make_shared(); + other->block = make_shared(); other->block.get()->txs.push_back(other); - other->block.get()->height = self->getHeight(); + other->block.get()->height = self->get_height(); } block.get()->merge(block.get(), other->block.get()); return; } // otherwise merge tx fields - id = MoneroUtils::reconcile(id, other->id); - version = MoneroUtils::reconcile(version, other->version); - paymentId = MoneroUtils::reconcile(paymentId, other->paymentId); - fee = MoneroUtils::reconcile(fee, other->fee, "tx fee"); - mixin = MoneroUtils::reconcile(mixin, other->mixin, "tx mixin"); - isConfirmed = MoneroUtils::reconcile(isConfirmed, other->isConfirmed); - doNotRelay = MoneroUtils::reconcile(doNotRelay, other->doNotRelay); - isRelayed = MoneroUtils::reconcile(isRelayed, other->isRelayed); - isDoubleSpendSeen = MoneroUtils::reconcile(isDoubleSpendSeen, other->isDoubleSpendSeen); - key = MoneroUtils::reconcile(key, other->key); - fullHex = MoneroUtils::reconcile(fullHex, other->fullHex); - prunedHex = MoneroUtils::reconcile(prunedHex, other->prunedHex); - prunableHex = MoneroUtils::reconcile(prunableHex, other->prunableHex); - prunableHash = MoneroUtils::reconcile(prunableHash, other->prunableHash); - size = MoneroUtils::reconcile(size, other->size, "tx size"); - weight = MoneroUtils::reconcile(weight, other->weight, "tx weight"); - //outputIndices = MoneroUtils::reconcile(outputIndices, other->outputIndices); // TODO - metadata = MoneroUtils::reconcile(metadata, other->metadata); - commonTxSets = MoneroUtils::reconcile(commonTxSets, other->commonTxSets); - //extra = MoneroUtils::reconcile(extra, other->extra); // TODO - rctSignatures = MoneroUtils::reconcile(rctSignatures, other->rctSignatures); - rctSigPrunable = MoneroUtils::reconcile(rctSigPrunable, other->rctSigPrunable); - isKeptByBlock = MoneroUtils::reconcile(isKeptByBlock, other->isKeptByBlock); - isFailed = MoneroUtils::reconcile(isFailed, other->isFailed); - lastFailedHeight = MoneroUtils::reconcile(lastFailedHeight, other->lastFailedHeight, "lastFailedHeight"); - lastFailedId = MoneroUtils::reconcile(lastFailedId, other->lastFailedId); - maxUsedBlockHeight = MoneroUtils::reconcile(maxUsedBlockHeight, other->maxUsedBlockHeight, "maxUsedBlockHeight"); - maxUsedBlockId = MoneroUtils::reconcile(maxUsedBlockId, other->maxUsedBlockId); - //signatures = MoneroUtils::reconcile(signatures, other->signatures); // TODO - unlockTime = MoneroUtils::reconcile(unlockTime, other->unlockTime, "unlockTime"); - numConfirmations = MoneroUtils::reconcile(numConfirmations, other->numConfirmations, "numConfirmations"); + id = monero_utils::reconcile(id, other->id); + version = monero_utils::reconcile(version, other->version); + paymentId = monero_utils::reconcile(paymentId, other->paymentId); + fee = monero_utils::reconcile(fee, other->fee, "tx fee"); + mixin = monero_utils::reconcile(mixin, other->mixin, "tx mixin"); + isConfirmed = monero_utils::reconcile(isConfirmed, other->isConfirmed); + doNotRelay = monero_utils::reconcile(doNotRelay, other->doNotRelay); + isRelayed = monero_utils::reconcile(isRelayed, other->isRelayed); + isDoubleSpendSeen = monero_utils::reconcile(isDoubleSpendSeen, other->isDoubleSpendSeen); + key = monero_utils::reconcile(key, other->key); + fullHex = monero_utils::reconcile(fullHex, other->fullHex); + prunedHex = monero_utils::reconcile(prunedHex, other->prunedHex); + prunableHex = monero_utils::reconcile(prunableHex, other->prunableHex); + prunableHash = monero_utils::reconcile(prunableHash, other->prunableHash); + size = monero_utils::reconcile(size, other->size, "tx size"); + weight = monero_utils::reconcile(weight, other->weight, "tx weight"); + //outputIndices = monero_utils::reconcile(outputIndices, other->outputIndices); // TODO + metadata = monero_utils::reconcile(metadata, other->metadata); + commonTxSets = monero_utils::reconcile(commonTxSets, other->commonTxSets); + //extra = monero_utils::reconcile(extra, other->extra); // TODO + rctSignatures = monero_utils::reconcile(rctSignatures, other->rctSignatures); + rctSigPrunable = monero_utils::reconcile(rctSigPrunable, other->rctSigPrunable); + isKeptByBlock = monero_utils::reconcile(isKeptByBlock, other->isKeptByBlock); + isFailed = monero_utils::reconcile(isFailed, other->isFailed); + lastFailedHeight = monero_utils::reconcile(lastFailedHeight, other->lastFailedHeight, "lastFailedHeight"); + lastFailedId = monero_utils::reconcile(lastFailedId, other->lastFailedId); + maxUsedBlockHeight = monero_utils::reconcile(maxUsedBlockHeight, other->maxUsedBlockHeight, "maxUsedBlockHeight"); + maxUsedBlockId = monero_utils::reconcile(maxUsedBlockId, other->maxUsedBlockId); + //signatures = monero_utils::reconcile(signatures, other->signatures); // TODO + unlockTime = monero_utils::reconcile(unlockTime, other->unlockTime, "unlockTime"); + numConfirmations = monero_utils::reconcile(numConfirmations, other->numConfirmations, "numConfirmations"); // merge vins if (!other->vins.empty()) { - for (const shared_ptr& merger : other->vins) { + for (const shared_ptr& merger : other->vins) { bool merged = false; merger->tx = self; - for (const shared_ptr& mergee : vins) { + for (const shared_ptr& mergee : vins) { if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) { mergee->merge(mergee, merger); merged = true; @@ -349,19 +349,19 @@ namespace monero { // merge vouts if (!other->vouts.empty()) { - for (const shared_ptr& vout : other->vouts) vout->tx = self; + for (const shared_ptr& vout : other->vouts) vout->tx = self; if (vouts.empty()) vouts = other->vouts; else { // determine if key images present int numKeyImages = 0; - for (const shared_ptr vout : vouts) { + for (const shared_ptr vout : vouts) { if (vout->keyImage != boost::none) { if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null"); numKeyImages++; } } - for (const shared_ptr& vout : other->vouts) { + for (const shared_ptr& vout : other->vouts) { if (vout->keyImage != boost::none) { if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null"); numKeyImages++; @@ -371,10 +371,10 @@ namespace monero { // merge by key images if (numKeyImages > 0) { - for (const shared_ptr& merger : other->vouts) { + for (const shared_ptr& merger : other->vouts) { bool merged = false; merger->tx = self; - for (const shared_ptr& mergee : vouts) { + for (const shared_ptr& mergee : vouts) { if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) { mergee->merge(mergee, merger); merged = true; @@ -401,38 +401,38 @@ namespace monero { receivedTimestamp = boost::none; lastRelayedTimestamp = boost::none; } else { - inTxPool = MoneroUtils::reconcile(inTxPool, other->inTxPool, boost::none, true, boost::none); // unrelayed -> tx pool - receivedTimestamp = MoneroUtils::reconcile(receivedTimestamp, other->receivedTimestamp, boost::none, boost::none, false, "receivedTimestamp"); // take earliest receive time - lastRelayedTimestamp = MoneroUtils::reconcile(lastRelayedTimestamp, other->lastRelayedTimestamp, boost::none, boost::none, true, "lastRelayedTimestamp"); // take latest relay time + inTxPool = monero_utils::reconcile(inTxPool, other->inTxPool, boost::none, true, boost::none); // unrelayed -> tx pool + receivedTimestamp = monero_utils::reconcile(receivedTimestamp, other->receivedTimestamp, boost::none, boost::none, false, "receivedTimestamp"); // take earliest receive time + lastRelayedTimestamp = monero_utils::reconcile(lastRelayedTimestamp, other->lastRelayedTimestamp, boost::none, boost::none, true, "lastRelayedTimestamp"); // take latest relay time } } // --------------------------- MONERO KEY IMAGE ----------------------------- - shared_ptr MoneroKeyImage::copy(const shared_ptr& src, const shared_ptr& tgt) const { + shared_ptr monero_key_image::copy(const shared_ptr& src, const shared_ptr& tgt) const { if (this != src.get()) throw runtime_error("this != src"); tgt->hex = src->hex; tgt->signature = src->signature; return tgt; } - boost::property_tree::ptree MoneroKeyImage::toPropertyTree() const { + boost::property_tree::ptree monero_key_image::to_property_tree() const { boost::property_tree::ptree node; if (hex != boost::none) node.put("hex", *hex); if (signature != boost::none) node.put("signature", *signature); return node; } - void MoneroKeyImage::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_key_image::merge(const shared_ptr& self, const shared_ptr& other) { throw runtime_error("Not implemented"); } // ------------------------------ MONERO OUTPUT ----------------------------- - shared_ptr MoneroOutput::copy(const shared_ptr& src, const shared_ptr& tgt) const { + shared_ptr monero_output::copy(const shared_ptr& src, const shared_ptr& tgt) const { if (this != src.get()) throw runtime_error("this != src"); tgt->tx = src->tx; // reference same parent tx by default - if (src->keyImage != boost::none) tgt->keyImage = src->keyImage.get()->copy(src->keyImage.get(), make_shared()); + if (src->keyImage != boost::none) tgt->keyImage = src->keyImage.get()->copy(src->keyImage.get(), make_shared()); tgt->amount = src->amount; tgt->index = src->index; if (!src->ringOutputIndices.empty()) tgt->ringOutputIndices = vector(src->ringOutputIndices); @@ -440,17 +440,17 @@ namespace monero { return tgt; } - boost::property_tree::ptree MoneroOutput::toPropertyTree() const { + boost::property_tree::ptree monero_output::to_property_tree() const { boost::property_tree::ptree node; - if (keyImage != boost::none) node.add_child("keyImage", (*keyImage)->toPropertyTree()); + if (keyImage != boost::none) node.add_child("keyImage", (*keyImage)->to_property_tree()); if (amount != boost::none) node.put("amount", *amount); if (index != boost::none) node.put("index", *index); - if (!ringOutputIndices.empty()) node.add_child("ringOutputIndices", MoneroUtils::toPropertyTree(ringOutputIndices)); + if (!ringOutputIndices.empty()) node.add_child("ringOutputIndices", monero_utils::to_property_tree(ringOutputIndices)); if (stealthPublicKey != boost::none) node.put("stealthPublicKey", *stealthPublicKey); return node; } - void MoneroOutput::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_output::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; @@ -463,7 +463,7 @@ namespace monero { // otherwise merge output fields if (keyImage == boost::none) keyImage = other->keyImage; else if (other->keyImage != boost::none) keyImage.get()->merge(keyImage.get(), other->keyImage.get()); - amount = MoneroUtils::reconcile(amount, other->amount, "output amount"); - index = MoneroUtils::reconcile(index, other->index, "output index"); + amount = monero_utils::reconcile(amount, other->amount, "output amount"); + index = monero_utils::reconcile(index, other->index, "output index"); } } diff --git a/src/daemon/MoneroDaemonModel.h b/src/daemon/monero_daemon_model.h similarity index 74% rename from src/daemon/MoneroDaemonModel.h rename to src/daemon/monero_daemon_model.h index 3fe4abb..088000a 100644 --- a/src/daemon/MoneroDaemonModel.h +++ b/src/daemon/monero_daemon_model.h @@ -65,7 +65,7 @@ namespace monero { /** * Base struct which can be serialized. */ - struct SerializableStruct { + struct serializable_struct { /** * Serializes the struct to a json string. @@ -79,7 +79,7 @@ namespace monero { * * @return the converted property tree */ - virtual boost::property_tree::ptree toPropertyTree() const = 0; + virtual boost::property_tree::ptree to_property_tree() const = 0; }; /** @@ -96,23 +96,23 @@ namespace monero { * * TODO: switch to boost::optional */ - struct MoneroRpcConnection { + struct monero_rpc_connection { string uri; boost::optional username; boost::optional password; - MoneroRpcConnection(const string& uri = "", const boost::optional& username = boost::none, const boost::optional& password = boost::none) : uri(uri), username(username), password(password) {} + monero_rpc_connection(const string& uri = "", const boost::optional& username = boost::none, const boost::optional& password = boost::none) : uri(uri), username(username), password(password) {} }; // forward declarations - struct MoneroTx; - struct MoneroOutput; + struct monero_tx; + struct monero_output; /** * Models a Monero block header which contains information about the block. * * TODO: a header that is transmitted may have fewer fields like cryptonote::block_header; separate? */ - struct MoneroBlockHeader : public SerializableStruct { + struct monero_block_header : public serializable_struct { boost::optional id; boost::optional height; boost::optional timestamp; @@ -132,30 +132,30 @@ namespace monero { boost::optional reward; boost::optional powHash; - boost::property_tree::ptree toPropertyTree() const; - virtual void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + virtual void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models a Monero block in the blockchain. */ - struct MoneroBlock : public MoneroBlockHeader { + struct monero_block : public monero_block_header { boost::optional hex; - boost::optional> minerTx; - vector> txs; + boost::optional> minerTx; + vector> txs; vector txIds; - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); - void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); + void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models a Monero transaction on the blockchain. */ - struct MoneroTx : public SerializableStruct { + struct monero_tx : public serializable_struct { static const string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000" - boost::optional> block; + boost::optional> block; boost::optional id; boost::optional version; boost::optional isMinerTx; @@ -178,8 +178,8 @@ namespace monero { boost::optional prunableHash; boost::optional size; boost::optional weight; - vector> vins; - vector> vouts; + vector> vins; + vector> vouts; vector outputIndices; boost::optional metadata; boost::optional commonTxSets; @@ -194,37 +194,37 @@ namespace monero { boost::optional maxUsedBlockId; vector signatures; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; - virtual void merge(const shared_ptr& self, const shared_ptr& other); - boost::optional getHeight() const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; + virtual void merge(const shared_ptr& self, const shared_ptr& other); + boost::optional get_height() const; }; /** * Models a Monero key image. */ - struct MoneroKeyImage : public SerializableStruct { + struct monero_key_image : public serializable_struct { boost::optional hex; boost::optional signature; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models a Monero transaction output. */ - struct MoneroOutput : public SerializableStruct { - shared_ptr tx; - boost::optional> keyImage; + struct monero_output : public serializable_struct { + shared_ptr tx; + boost::optional> keyImage; boost::optional amount; boost::optional index; vector ringOutputIndices; boost::optional stealthPublicKey; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; - virtual void merge(const shared_ptr& self, const shared_ptr& other); + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; + virtual void merge(const shared_ptr& self, const shared_ptr& other); }; } diff --git a/src/utils/MoneroUtils.cpp b/src/utils/monero_utils.cpp similarity index 84% rename from src/utils/MoneroUtils.cpp rename to src/utils/monero_utils.cpp index 0ca129b..c45eb9c 100644 --- a/src/utils/MoneroUtils.cpp +++ b/src/utils/monero_utils.cpp @@ -50,18 +50,18 @@ * Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers */ -#include "MoneroUtils.h" +#include "monero_utils.h" #include "rpc/core_rpc_server_commands_defs.h" #include "storages/portable_storage_template_helper.h" #include "cryptonote_basic/cryptonote_format_utils.h" using namespace std; using namespace cryptonote; -using namespace MoneroUtils; +using namespace monero_utils; // ------------------------------- INNER HELPERS ------------------------------ -void nodeToTransfer(const boost::property_tree::ptree& node, shared_ptr transfer) { +void nodeToTransfer(const boost::property_tree::ptree& node, shared_ptr transfer) { // initialize transfer from node for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { @@ -70,8 +70,8 @@ void nodeToTransfer(const boost::property_tree::ptree& node, shared_ptr nodeToTransferRequest(const boost::property_tree::ptree& node) { - shared_ptr transferRequest = make_shared(); +shared_ptr nodeToTransferRequest(const boost::property_tree::ptree& node) { + shared_ptr transferRequest = make_shared(); nodeToTransfer(node, transferRequest); // initialize request from node @@ -94,10 +94,10 @@ shared_ptr nodeToTransferRequest(const boost::property_tr return transferRequest; } -shared_ptr nodeToKeyImage(const boost::property_tree::ptree& node) { +shared_ptr nodeToKeyImage(const boost::property_tree::ptree& node) { // initialize key image from node - shared_ptr keyImage = make_shared(); + shared_ptr keyImage = make_shared(); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; if (key == string("hex")) keyImage->hex = it->second.data(); @@ -107,7 +107,7 @@ shared_ptr nodeToKeyImage(const boost::property_tree::ptree& nod return keyImage; } -void nodeToOutput(const boost::property_tree::ptree& node, shared_ptr output) { +void nodeToOutput(const boost::property_tree::ptree& node, shared_ptr output) { // initialize output from node for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { @@ -120,7 +120,7 @@ void nodeToOutput(const boost::property_tree::ptree& node, shared_ptr outputWallet) { +void nodeToOutputWallet(const boost::property_tree::ptree& node, shared_ptr outputWallet) { nodeToOutput(node, outputWallet); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; @@ -132,8 +132,8 @@ void nodeToOutputWallet(const boost::property_tree::ptree& node, shared_ptr nodeToOutputRequest(const boost::property_tree::ptree& node) { - shared_ptr outputRequest = make_shared(); +shared_ptr nodeToOutputRequest(const boost::property_tree::ptree& node) { + shared_ptr outputRequest = make_shared(); nodeToOutputWallet(node, outputRequest); // initialize request from node @@ -146,7 +146,7 @@ shared_ptr nodeToOutputRequest(const boost::property_tree:: return outputRequest; } -void nodeToTx(const boost::property_tree::ptree& node, shared_ptr tx) { +void nodeToTx(const boost::property_tree::ptree& node, shared_ptr tx) { // initialize tx from node for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { @@ -192,7 +192,7 @@ void nodeToTx(const boost::property_tree::ptree& node, shared_ptr tx) } // TODO: fill this out -void nodeToTxWallet(const boost::property_tree::ptree& node, shared_ptr txWallet) { +void nodeToTxWallet(const boost::property_tree::ptree& node, shared_ptr txWallet) { nodeToTx(node, txWallet); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { @@ -201,8 +201,8 @@ void nodeToTxWallet(const boost::property_tree::ptree& node, shared_ptr nodeToTxRequest(const boost::property_tree::ptree& node) { - shared_ptr txRequest = make_shared(); +shared_ptr nodeToTxRequest(const boost::property_tree::ptree& node) { + shared_ptr txRequest = make_shared(); nodeToTxWallet(node, txRequest); // initialize request from node @@ -224,8 +224,8 @@ shared_ptr nodeToTxRequest(const boost::property_tree::ptree& n return txRequest; } -shared_ptr nodeToBlockRequest(const boost::property_tree::ptree& node) { - shared_ptr block = make_shared(); +shared_ptr nodeToBlockRequest(const boost::property_tree::ptree& node) { + shared_ptr block = make_shared(); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; if (key == string("txs")) { @@ -238,8 +238,8 @@ shared_ptr nodeToBlockRequest(const boost::property_tree::ptree& no return block; } -shared_ptr nodeToDestination(const boost::property_tree::ptree& node) { - shared_ptr destination = make_shared(); +shared_ptr nodeToDestination(const boost::property_tree::ptree& node) { + shared_ptr destination = make_shared(); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; if (key == string("address")) destination->address = it->second.data(); @@ -250,19 +250,19 @@ shared_ptr nodeToDestination(const boost::property_tree::ptre // ------------------------- PUBLIC STATIC UTILITIES -------------------------- -void MoneroUtils::jsonToBinary(const std::string &json, std::string &bin) { +void monero_utils::jsonToBinary(const std::string &json, std::string &bin) { epee::serialization::portable_storage ps; ps.load_from_json(json); ps.store_to_binary(bin); } -void MoneroUtils::binaryToJson(const std::string &bin, std::string &json) { +void monero_utils::binaryToJson(const std::string &bin, std::string &json) { epee::serialization::portable_storage ps; ps.load_from_binary(bin); ps.dump_as_json(json); } -void MoneroUtils::binaryBlocksToJson(const std::string &bin, std::string &json) { +void monero_utils::binaryBlocksToJson(const std::string &bin, std::string &json) { // load binary rpc response to struct cryptonote::COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::response resp_struct; @@ -294,8 +294,8 @@ void MoneroUtils::binaryBlocksToJson(const std::string &bin, std::string &json) // add tx node to txs node boost::property_tree::ptree txNode; - MTRACE("PRUNED:\n" << MoneroUtils::get_pruned_tx_json(tx)); - txNode.put("", MoneroUtils::get_pruned_tx_json(tx)); // TODO: no pretty print + MTRACE("PRUNED:\n" << monero_utils::get_pruned_tx_json(tx)); + txNode.put("", monero_utils::get_pruned_tx_json(tx)); // TODO: no pretty print txsNode.push_back(std::make_pair("", txNode)); } else { throw std::runtime_error("failed to parse tx blob at index " + std::to_string(txIdx)); @@ -314,7 +314,7 @@ void MoneroUtils::binaryBlocksToJson(const std::string &bin, std::string &json) json = ss.str(); } -shared_ptr MoneroUtils::deserializeTxRequest(const string& txRequestStr) { +shared_ptr monero_utils::deserializeTxRequest(const string& txRequestStr) { // deserialize tx request string to property rooted at block std::istringstream iss = txRequestStr.empty() ? std::istringstream() : std::istringstream(txRequestStr); @@ -322,16 +322,16 @@ shared_ptr MoneroUtils::deserializeTxRequest(const string& txRe boost::property_tree::read_json(iss, blockNode); // convert request property tree to block - shared_ptr block = nodeToBlockRequest(blockNode); + shared_ptr block = nodeToBlockRequest(blockNode); // get tx request - shared_ptr txRequest = static_pointer_cast(block->txs[0]); + shared_ptr txRequest = static_pointer_cast(block->txs[0]); // return deserialized request return txRequest; } -shared_ptr MoneroUtils::deserializeTransferRequest(const string& transferRequestStr) { +shared_ptr monero_utils::deserializeTransferRequest(const string& transferRequestStr) { // deserialize transfer request string to property rooted at block std::istringstream iss = transferRequestStr.empty() ? std::istringstream() : std::istringstream(transferRequestStr); @@ -339,16 +339,16 @@ shared_ptr MoneroUtils::deserializeTransferRequest(const boost::property_tree::read_json(iss, blockNode); // convert request property tree to block - shared_ptr block = nodeToBlockRequest(blockNode); + shared_ptr block = nodeToBlockRequest(blockNode); // return mpty request if no txs - if (block->txs.empty()) return make_shared(); + if (block->txs.empty()) return make_shared(); // get tx request - shared_ptr txRequest = static_pointer_cast(block->txs[0]); + shared_ptr txRequest = static_pointer_cast(block->txs[0]); // get / create transfer request - shared_ptr transferRequest = txRequest->transferRequest == boost::none ? make_shared() : *txRequest->transferRequest; + shared_ptr transferRequest = txRequest->transferRequest == boost::none ? make_shared() : *txRequest->transferRequest; // transfer request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias() transferRequest->txRequest = txRequest; @@ -358,7 +358,7 @@ shared_ptr MoneroUtils::deserializeTransferRequest(const return transferRequest; } -shared_ptr MoneroUtils::deserializeOutputRequest(const string& outputRequestStr) { +shared_ptr monero_utils::deserializeOutputRequest(const string& outputRequestStr) { // deserialize output request string to property rooted at block std::istringstream iss = outputRequestStr.empty() ? std::istringstream() : std::istringstream(outputRequestStr); @@ -366,16 +366,16 @@ shared_ptr MoneroUtils::deserializeOutputRequest(const stri boost::property_tree::read_json(iss, blockNode); // convert request property tree to block - shared_ptr block = nodeToBlockRequest(blockNode); + shared_ptr block = nodeToBlockRequest(blockNode); // empty request if no txs - if (block->txs.empty()) return make_shared(); + if (block->txs.empty()) return make_shared(); // get tx request - shared_ptr txRequest = static_pointer_cast(block->txs[0]); + shared_ptr txRequest = static_pointer_cast(block->txs[0]); // get / create output request - shared_ptr outputRequest = txRequest->outputRequest == boost::none ? make_shared() : *txRequest->outputRequest; + shared_ptr outputRequest = txRequest->outputRequest == boost::none ? make_shared() : *txRequest->outputRequest; // output request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias() outputRequest->txRequest = txRequest; @@ -385,15 +385,15 @@ shared_ptr MoneroUtils::deserializeOutputRequest(const stri return outputRequest; } -shared_ptr MoneroUtils::deserializeSendRequest(const string& sendRequestStr) { +shared_ptr monero_utils::deserializeSendRequest(const string& sendRequestStr) { // deserialize send request json to property node std::istringstream iss = sendRequestStr.empty() ? std::istringstream() : std::istringstream(sendRequestStr); boost::property_tree::ptree node; boost::property_tree::read_json(iss, node); - // convert request property tree to MoneroSendRequest - shared_ptr sendRequest = make_shared(); + // convert request property tree to monero_send_request + shared_ptr sendRequest = make_shared(); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; if (key == string("destinations")) { @@ -422,7 +422,7 @@ shared_ptr MoneroUtils::deserializeSendRequest(const string& return sendRequest; } -vector> MoneroUtils::deserializeKeyImages(const string& keyImagesJson) { +vector> monero_utils::deserializeKeyImages(const string& keyImagesJson) { // deserialize json to property node std::istringstream iss = keyImagesJson.empty() ? std::istringstream() : std::istringstream(keyImagesJson); @@ -430,7 +430,7 @@ vector> MoneroUtils::deserializeKeyImages(const strin boost::property_tree::read_json(iss, node); // convert property tree to key images - vector> keyImages; + vector> keyImages; for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; if (key == string("keyImages")) { @@ -443,14 +443,14 @@ vector> MoneroUtils::deserializeKeyImages(const strin return keyImages; } -string MoneroUtils::serialize(const boost::property_tree::ptree& node) { +string monero_utils::serialize(const boost::property_tree::ptree& node) { std::stringstream ss; boost::property_tree::write_json(ss, node, false); string str = ss.str(); return str.substr(0, str.size() - 1); // strip newline } -boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& strs) { +boost::property_tree::ptree monero_utils::to_property_tree(const vector& strs) { boost::property_tree::ptree strsNode; for (const auto& str : strs) { boost::property_tree::ptree strNode; @@ -460,7 +460,7 @@ boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& st return strsNode; } -boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& nums) { +boost::property_tree::ptree monero_utils::to_property_tree(const vector& nums) { boost::property_tree::ptree numsNode; for (const auto& num : nums) { boost::property_tree::ptree numNode; @@ -471,7 +471,7 @@ boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& n } // TODO: remove these redundant implementations for different sizes? -boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& nums) { +boost::property_tree::ptree monero_utils::to_property_tree(const vector& nums) { boost::property_tree::ptree numsNode; for (const auto& num : nums) { boost::property_tree::ptree numNode; @@ -481,7 +481,7 @@ boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& return numsNode; } -boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& nums) { +boost::property_tree::ptree monero_utils::to_property_tree(const vector& nums) { boost::property_tree::ptree numsNode; for (const auto& num : nums) { boost::property_tree::ptree numNode; @@ -491,24 +491,24 @@ boost::property_tree::ptree MoneroUtils::toPropertyTree(const vector& return numsNode; } -shared_ptr MoneroUtils::cnBlockToBlock(const cryptonote::block& cnBlock) { +shared_ptr monero_utils::cnBlockToBlock(const cryptonote::block& cnBlock) { cryptonote::block temp = cnBlock; cout << cryptonote::obj_to_json_str(temp) << endl; - shared_ptr block = make_shared(); + shared_ptr block = make_shared(); block->majorVersion = cnBlock.major_version; block->minorVersion = cnBlock.minor_version; block->timestamp = cnBlock.timestamp; block->prevId = epee::string_tools::pod_to_hex(cnBlock.prev_id); block->nonce = cnBlock.nonce; - block->minerTx = MoneroUtils::cnTxToTx(cnBlock.miner_tx); + block->minerTx = monero_utils::cnTxToTx(cnBlock.miner_tx); for (const crypto::hash& txHash : cnBlock.tx_hashes) { block->txIds.push_back(epee::string_tools::pod_to_hex(txHash)); } return block; } -shared_ptr MoneroUtils::cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet) { - shared_ptr tx = initAsTxWallet ? make_shared() : make_shared(); +shared_ptr monero_utils::cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet) { + shared_ptr tx = initAsTxWallet ? make_shared() : make_shared(); tx->version = cnTx.version; tx->unlockTime = cnTx.unlock_time; tx->id = epee::string_tools::pod_to_hex(cnTx.hash); @@ -519,20 +519,20 @@ shared_ptr MoneroUtils::cnTxToTx(const cryptonote::transaction& cnTx, if (cnVin.which() != 0 && cnVin.which() != 3) throw runtime_error("Unsupported variant type"); if (tx->isMinerTx == boost::none) tx->isMinerTx = cnVin.which() == 0; if (cnVin.which() != 3) continue; // only process txin_to_key of variant TODO: support other types, like 0 "gen" which is miner tx? - shared_ptr vin = initAsTxWallet ? make_shared() : make_shared(); + shared_ptr vin = initAsTxWallet ? make_shared() : make_shared(); vin->tx = tx; tx->vins.push_back(vin); const txin_to_key& txin = boost::get(cnVin); vin->amount = txin.amount; vin->ringOutputIndices = txin.key_offsets; crypto::key_image cnKeyImage = txin.k_image; - vin->keyImage = make_shared(); + vin->keyImage = make_shared(); vin->keyImage.get()->hex = epee::string_tools::pod_to_hex(cnKeyImage); } // init vouts for (const tx_out& cnVout : cnTx.vout) { - shared_ptr vout = initAsTxWallet ? make_shared() : make_shared(); + shared_ptr vout = initAsTxWallet ? make_shared() : make_shared(); vout->tx = tx; tx->vouts.push_back(vout); vout->amount = cnVout.amount; diff --git a/src/utils/MoneroUtils.h b/src/utils/monero_utils.h similarity index 83% rename from src/utils/MoneroUtils.h rename to src/utils/monero_utils.h index 3e9d158..bef6b94 100644 --- a/src/utils/MoneroUtils.h +++ b/src/utils/monero_utils.h @@ -53,7 +53,7 @@ #ifndef MoneroUtils_h #define MoneroUtils_h -#include "wallet/MoneroWallet.h" +#include "wallet/monero_wallet.h" #include "cryptonote_basic/cryptonote_basic.h" #include "serialization/keyvalue_serialization.h" // TODO: consolidate with other binary deps? #include "storages/portable_storage.h" @@ -61,7 +61,7 @@ /** * Collection of utilities for working with Monero's binary portable storage format. */ -namespace MoneroUtils +namespace monero_utils { using namespace std; using namespace cryptonote; @@ -72,15 +72,15 @@ namespace MoneroUtils void binaryBlocksToJson(const std::string &bin, std::string &json); - shared_ptr deserializeTxRequest(const string& txRequestStr); + shared_ptr deserializeTxRequest(const string& txRequestStr); - shared_ptr deserializeTransferRequest(const string& transferRequestStr); + shared_ptr deserializeTransferRequest(const string& transferRequestStr); - shared_ptr deserializeOutputRequest(const string& outputRequestStr); + shared_ptr deserializeOutputRequest(const string& outputRequestStr); - shared_ptr deserializeSendRequest(const string& sendRequestStr); + shared_ptr deserializeSendRequest(const string& sendRequestStr); - vector> deserializeKeyImages(const string& keyImagesJson); + vector> deserializeKeyImages(const string& keyImagesJson); string serialize(const boost::property_tree::ptree& node); @@ -90,7 +90,7 @@ namespace MoneroUtils * @param cnBlock is the Core block to convert * @return a block in this library's native model */ - shared_ptr cnBlockToBlock(const cryptonote::block& cnBlock); + shared_ptr cnBlockToBlock(const cryptonote::block& cnBlock); /** @@ -98,9 +98,9 @@ namespace MoneroUtils * native model. * * @param cnTx is the Core transaction to convert - * @param initAsTxWallet specifies if a MoneroTx xor MoneroTxWallet should be initialized + * @param initAsTxWallet specifies if a monero_tx xor monero_tx_wallet should be initialized */ - shared_ptr cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet = false); + shared_ptr cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet = false); /** * Modified from core_rpc_server.cpp to return a string. @@ -118,28 +118,28 @@ namespace MoneroUtils // ----------------------------- PROPERTY TREE ------------------------------ - // 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) { + // TODO: template implementation here, could move to monero_utils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation + template boost::property_tree::ptree to_property_tree(const vector>& types) { boost::property_tree::ptree typeNodes; for (const auto& type : types) { - typeNodes.push_back(std::make_pair("", type->toPropertyTree())); + typeNodes.push_back(std::make_pair("", type->to_property_tree())); } return typeNodes; } - // 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) { + // TODO: template implementation here, could move to monero_utils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation + template boost::property_tree::ptree to_property_tree(const vector& types) { boost::property_tree::ptree typeNodes; for (const auto& type : types) { - typeNodes.push_back(std::make_pair("", type.toPropertyTree())); + typeNodes.push_back(std::make_pair("", type.to_property_tree())); } return typeNodes; } - boost::property_tree::ptree toPropertyTree(const vector& strs); - boost::property_tree::ptree toPropertyTree(const vector& nums); - boost::property_tree::ptree toPropertyTree(const vector& nums); - boost::property_tree::ptree toPropertyTree(const vector& nums); + boost::property_tree::ptree to_property_tree(const vector& strs); + boost::property_tree::ptree to_property_tree(const vector& nums); + boost::property_tree::ptree to_property_tree(const vector& nums); + boost::property_tree::ptree to_property_tree(const vector& nums); // ------------------------- VALUE RECONCILATION- --------------------------- diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/monero_wallet.cpp similarity index 76% rename from src/wallet/MoneroWallet.cpp rename to src/wallet/monero_wallet.cpp index c31b6f8..f57a649 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -50,9 +50,9 @@ * Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers */ -#include "MoneroWallet.h" +#include "monero_wallet.h" -#include "utils/MoneroUtils.h" +#include "utils/monero_utils.h" #include #include #include @@ -86,21 +86,21 @@ namespace monero { return optVal == boost::none ? false : val == *optVal; } - shared_ptr buildTxWithIncomingTransfer(const tools::wallet2& wallet2, uint64_t height, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) { + shared_ptr buildTxWithIncomingTransfer(const tools::wallet2& wallet2, uint64_t height, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) { // construct block - shared_ptr block = make_shared(); + shared_ptr block = make_shared(); block->height = pd.m_block_height; block->timestamp = pd.m_timestamp; // construct tx - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); tx->block = block; block->txs.push_back(tx); tx->id = string_tools::pod_to_hex(pd.m_tx_hash); tx->paymentId = string_tools::pod_to_hex(payment_id); if (tx->paymentId->substr(16).find_first_not_of('0') == std::string::npos) tx->paymentId = tx->paymentId->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->paymentId == MoneroTx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id + if (tx->paymentId == monero_tx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id tx->unlockTime = pd.m_unlock_time; tx->fee = pd.m_fee; tx->note = wallet2.get_tx_note(pd.m_tx_hash); @@ -119,7 +119,7 @@ namespace monero { else tx->numConfirmations = height - *block->height; // construct transfer - shared_ptr incomingTransfer = make_shared(); + shared_ptr incomingTransfer = make_shared(); incomingTransfer->tx = tx; tx->incomingTransfers.push_back(incomingTransfer); incomingTransfer->amount = pd.m_amount; @@ -137,21 +137,21 @@ namespace monero { return tx; } - shared_ptr buildTxWithOutgoingTransfer(const tools::wallet2& wallet2, uint64_t height, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd) { + shared_ptr buildTxWithOutgoingTransfer(const tools::wallet2& wallet2, uint64_t height, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd) { // construct block - shared_ptr block = make_shared(); + shared_ptr block = make_shared(); block->height = pd.m_block_height; block->timestamp = pd.m_timestamp; // construct tx - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); tx->block = block; block->txs.push_back(tx); tx->id = string_tools::pod_to_hex(txid); tx->paymentId = string_tools::pod_to_hex(pd.m_payment_id); if (tx->paymentId->substr(16).find_first_not_of('0') == std::string::npos) tx->paymentId = tx->paymentId->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->paymentId == MoneroTx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id + if (tx->paymentId == monero_tx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id tx->unlockTime = pd.m_unlock_time; tx->fee = pd.m_amount_in - pd.m_amount_out; tx->note = wallet2.get_tx_note(txid); @@ -169,7 +169,7 @@ namespace monero { else tx->numConfirmations = height - *block->height; // construct transfer - shared_ptr outgoingTransfer = make_shared(); + shared_ptr outgoingTransfer = make_shared(); outgoingTransfer->tx = tx; tx->outgoingTransfer = outgoingTransfer; uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known @@ -186,7 +186,7 @@ namespace monero { // initialize destinations for (const auto &d: pd.m_dests) { - shared_ptr destination = make_shared(); + shared_ptr destination = make_shared(); destination->amount = d.amount; destination->address = d.original.empty() ? cryptonote::get_account_address_as_str(wallet2.nettype(), d.is_subaddress, d.addr) : d.original; outgoingTransfer->destinations.push_back(destination); @@ -196,7 +196,7 @@ namespace monero { // TODO monero core: confirmed tx from/to same account has amount 0 but cached transfer destinations if (*outgoingTransfer->amount == 0 && !outgoingTransfer->destinations.empty()) { uint64_t amount = 0; - for (const shared_ptr& destination : outgoingTransfer->destinations) amount += *destination->amount; + for (const shared_ptr& destination : outgoingTransfer->destinations) amount += *destination->amount; outgoingTransfer->amount = amount; } @@ -209,15 +209,15 @@ namespace monero { return tx; } - shared_ptr buildTxWithIncomingTransferUnconfirmed(const tools::wallet2& wallet2, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &ppd) { + shared_ptr buildTxWithIncomingTransferUnconfirmed(const tools::wallet2& wallet2, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &ppd) { // construct tx const tools::wallet2::payment_details &pd = ppd.m_pd; - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); tx->id = string_tools::pod_to_hex(pd.m_tx_hash); tx->paymentId = string_tools::pod_to_hex(payment_id); if (tx->paymentId->substr(16).find_first_not_of('0') == std::string::npos) tx->paymentId = tx->paymentId->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->paymentId == MoneroTx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id + if (tx->paymentId == monero_tx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id tx->unlockTime = pd.m_unlock_time; tx->fee = pd.m_fee; tx->note = wallet2.get_tx_note(pd.m_tx_hash); @@ -232,7 +232,7 @@ namespace monero { tx->numConfirmations = 0; // construct transfer - shared_ptr incomingTransfer = make_shared(); + shared_ptr incomingTransfer = make_shared(); incomingTransfer->tx = tx; tx->incomingTransfers.push_back(incomingTransfer); incomingTransfer->amount = pd.m_amount; @@ -249,15 +249,15 @@ namespace monero { return tx; } - shared_ptr buildTxWithOutgoingTransferUnconfirmed(const tools::wallet2& wallet2, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd) { + shared_ptr buildTxWithOutgoingTransferUnconfirmed(const tools::wallet2& wallet2, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd) { // construct tx - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); tx->isFailed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed; tx->id = string_tools::pod_to_hex(txid); tx->paymentId = string_tools::pod_to_hex(pd.m_payment_id); if (tx->paymentId->substr(16).find_first_not_of('0') == std::string::npos) tx->paymentId = tx->paymentId->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->paymentId == MoneroTx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id + if (tx->paymentId == monero_tx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id tx->unlockTime = pd.m_tx.unlock_time; tx->fee = pd.m_amount_in - pd.m_amount_out; tx->note = wallet2.get_tx_note(txid); @@ -271,7 +271,7 @@ namespace monero { tx->numConfirmations = 0; // construct transfer - shared_ptr outgoingTransfer = make_shared(); + shared_ptr outgoingTransfer = make_shared(); outgoingTransfer->tx = tx; tx->outgoingTransfer = outgoingTransfer; outgoingTransfer->amount = pd.m_amount_in - pd.m_change - tx->fee.get(); @@ -287,7 +287,7 @@ namespace monero { // initialize destinations for (const auto &d: pd.m_dests) { - shared_ptr destination = make_shared(); + shared_ptr destination = make_shared(); destination->amount = d.amount; destination->address = d.original.empty() ? cryptonote::get_account_address_as_str(wallet2.nettype(), d.is_subaddress, d.addr) : d.original; outgoingTransfer->destinations.push_back(destination); @@ -297,7 +297,7 @@ namespace monero { // TODO monero core: confirmed tx from/to same account has amount 0 but cached transfer destinations if (*outgoingTransfer->amount == 0 && !outgoingTransfer->destinations.empty()) { uint64_t amount = 0; - for (const shared_ptr& destination : outgoingTransfer->destinations) amount += *destination->amount; + for (const shared_ptr& destination : outgoingTransfer->destinations) amount += *destination->amount; outgoingTransfer->amount = amount; } @@ -310,14 +310,14 @@ namespace monero { return tx; } - shared_ptr buildTxWithVout(const tools::wallet2& wallet2, const tools::wallet2::transfer_details& td) { + shared_ptr buildTxWithVout(const tools::wallet2& wallet2, const tools::wallet2::transfer_details& td) { // construct block - shared_ptr block = make_shared(); + shared_ptr block = make_shared(); block->height = td.m_block_height; // construct tx - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); tx->block = block; block->txs.push_back(tx); tx->id = epee::string_tools::pod_to_hex(td.m_txid); @@ -329,7 +329,7 @@ namespace monero { tx->isDoubleSpendSeen = false; // construct vout - shared_ptr vout = make_shared(); + shared_ptr vout = make_shared(); vout->tx = tx; tx->vouts.push_back(vout); vout->amount = td.amount(); @@ -340,7 +340,7 @@ namespace monero { vout->isUnlocked = wallet2.is_transfer_unlocked(td); vout->isFrozen = td.m_frozen; if (td.m_key_image_known) { - vout->keyImage = make_shared(); + vout->keyImage = make_shared(); vout->keyImage.get()->hex = epee::string_tools::pod_to_hex(td.m_key_image); } @@ -359,11 +359,11 @@ namespace monero { * @param blockMap maps block heights to blocks * @param skipIfAbsent specifies if the tx should not be added if it doesn't already exist */ - void mergeTx(const shared_ptr& tx, map>& txMap, map>& blockMap, bool skipIfAbsent) { + void merge_tx(const shared_ptr& tx, map>& txMap, map>& blockMap, bool skipIfAbsent) { if (tx->id == boost::none) throw runtime_error("Tx id is not initialized"); // if tx doesn't exist, add it (unless skipped) - map>::const_iterator txIter = txMap.find(*tx->id); + map>::const_iterator txIter = txMap.find(*tx->id); if (txIter == txMap.end()) { if (!skipIfAbsent) { txMap[*tx->id] = tx; @@ -374,17 +374,17 @@ namespace monero { // otherwise merge with existing tx else { - shared_ptr& aTx = txMap[*tx->id]; + shared_ptr& aTx = txMap[*tx->id]; aTx->merge(aTx, tx); } // if confirmed, merge tx's block - if (tx->getHeight() != boost::none) { - map>::const_iterator blockIter = blockMap.find(tx->getHeight().get()); + if (tx->get_height() != boost::none) { + map>::const_iterator blockIter = blockMap.find(tx->get_height().get()); if (blockIter == blockMap.end()) { - blockMap[tx->getHeight().get()] = tx->block.get(); + blockMap[tx->get_height().get()] = tx->block.get(); } else { - shared_ptr& aBlock = blockMap[tx->getHeight().get()]; + shared_ptr& aBlock = blockMap[tx->get_height().get()]; aBlock->merge(aBlock, tx->block.get()); } } @@ -393,8 +393,8 @@ namespace monero { /** * Returns true iff tx1's height is known to be less than tx2's height for sorting. */ - bool txHeightLessThan(const shared_ptr& tx1, const shared_ptr& tx2) { - if (tx1->block != boost::none && tx2->block != boost::none) return tx1->getHeight() < tx2->getHeight(); + bool txHeightLessThan(const shared_ptr& tx1, const shared_ptr& tx2) { + if (tx1->block != boost::none && tx2->block != boost::none) return tx1->get_height() < tx2->get_height(); else if (tx1->block == boost::none) return false; else return true; } @@ -402,7 +402,7 @@ namespace monero { /** * Returns true iff transfer1 is ordered before transfer2 by ascending account and subaddress indices. */ - bool incomingTransferBefore(const shared_ptr& transfer1, const shared_ptr& transfer2) { + bool incomingTransferBefore(const shared_ptr& transfer1, const shared_ptr& transfer2) { // compare by height if (txHeightLessThan(transfer1->tx, transfer2->tx)) return true; @@ -416,9 +416,9 @@ namespace monero { /** * Returns true iff wallet vout1 is ordered before vout2 by ascending account and subaddress indices then index. */ - bool voutBefore(const shared_ptr& o1, const shared_ptr& o2) { - shared_ptr ow1 = static_pointer_cast(o1); - shared_ptr ow2 = static_pointer_cast(o2); + bool voutBefore(const shared_ptr& o1, const shared_ptr& o2) { + shared_ptr ow1 = static_pointer_cast(o1); + shared_ptr ow2 = static_pointer_cast(o2); // compare by height if (txHeightLessThan(ow1->tx, ow2->tx)) return true; @@ -665,7 +665,7 @@ namespace monero { * @param wallet provides context to inform external notifications * @param wallet2 provides source notifications which this listener propagates to external listeners */ - Wallet2Listener(MoneroWallet& wallet, tools::wallet2& wallet2) : wallet(wallet), wallet2(wallet2) { + Wallet2Listener(monero_wallet& wallet, tools::wallet2& wallet2) : wallet(wallet), wallet2(wallet2) { this->listener = boost::none; this->syncStartHeight = boost::none; this->syncEndHeight = boost::none; @@ -681,7 +681,7 @@ namespace monero { updateListening(); } - void onSyncStart(uint64_t startHeight, boost::optional syncListener) { + void onSyncStart(uint64_t startHeight, boost::optional syncListener) { if (syncStartHeight != boost::none || syncEndHeight != boost::none) throw runtime_error("Sync start or end height should not already be allocated, is previous sync in progress?"); syncStartHeight = startHeight; syncEndHeight = wallet.getChainHeight(); @@ -699,15 +699,15 @@ namespace monero { virtual void on_new_block(uint64_t height, const cryptonote::block& cnBlock) { // notify listener of block - if (listener != boost::none) listener->onNewBlock(height); + if (listener != boost::none) listener->on_new_block(height); // notify listeners of sync progress if (syncStartHeight != boost::none && height >= *syncStartHeight) { if (height >= *syncEndHeight) syncEndHeight = height + 1; // increase end height if necessary double percentDone = (double) (height - *syncStartHeight + 1) / (double) (*syncEndHeight - *syncStartHeight); string message = string("Synchronizing"); - if (listener != boost::none) listener.get().onSyncProgress(height, *syncStartHeight, *syncEndHeight, percentDone, message); - if (syncListener != boost::none) syncListener.get().onSyncProgress(height, *syncStartHeight, *syncEndHeight, percentDone, message); + if (listener != boost::none) listener.get().on_sync_progress(height, *syncStartHeight, *syncEndHeight, percentDone, message); + if (syncListener != boost::none) syncListener.get().on_sync_progress(height, *syncStartHeight, *syncEndHeight, percentDone, message); } } @@ -716,14 +716,14 @@ namespace monero { if (listener == boost::none) return; // create native library tx - shared_ptr block = make_shared(); + shared_ptr block = make_shared(); block->height = height; - shared_ptr tx = static_pointer_cast(MoneroUtils::cnTxToTx(cnTx, true)); + shared_ptr tx = static_pointer_cast(monero_utils::cnTxToTx(cnTx, true)); block->txs.push_back(tx); tx->block = block; tx->id = epee::string_tools::pod_to_hex(txid); tx->unlockTime = unlock_time; - shared_ptr output = make_shared(); + shared_ptr output = make_shared(); tx->vouts.push_back(output); output->tx = tx; output->amount = amount; @@ -731,7 +731,7 @@ namespace monero { output->subaddressIndex = subaddr_index.minor; // notify listener of output - listener->onOutputReceived(*output); + listener->on_output_received(*output); } virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cnTxIn, uint64_t amount, const cryptonote::transaction& cnTxOut, const cryptonote::subaddress_index& subaddr_index) { @@ -739,13 +739,13 @@ namespace monero { if (&cnTxIn != &cnTxOut) throw runtime_error("on_money_spent() in tx is different than out tx"); // create native library tx - shared_ptr block = make_shared(); + shared_ptr block = make_shared(); block->height = height; - shared_ptr tx = static_pointer_cast(MoneroUtils::cnTxToTx(cnTxIn, true)); + shared_ptr tx = static_pointer_cast(monero_utils::cnTxToTx(cnTxIn, true)); block->txs.push_back(tx); tx->block = block; tx->id = epee::string_tools::pod_to_hex(txid); - shared_ptr output = make_shared(); + shared_ptr output = make_shared(); tx->vins.push_back(output); output->tx = tx; output->amount = amount; @@ -753,7 +753,7 @@ namespace monero { output->subaddressIndex = subaddr_index.minor; // notify listener of output - listener->onOutputSpent(*output); + listener->on_output_spent(*output); // TODO **: to notify or not to notify? // std::string tx_hash = epee::string_tools::pod_to_hex(txid); @@ -769,10 +769,10 @@ namespace monero { } private: - MoneroWallet& wallet; // wallet to provide context for notifications + monero_wallet& wallet; // wallet to provide context for notifications tools::wallet2& wallet2; // internal wallet implementation to listen to boost::optional listener; // target listener to invoke with notifications - boost::optional syncListener; + boost::optional syncListener; boost::optional syncStartHeight; boost::optional syncEndHeight; @@ -783,7 +783,7 @@ namespace monero { // ---------------------------- WALLET MANAGEMENT --------------------------- - bool MoneroWallet::walletExists(const string& path) { + bool monero_wallet::walletExists(const string& path) { MTRACE("walletExists(" << path << ")"); bool keyFileExists; bool walletFileExists; @@ -791,9 +791,9 @@ namespace monero { return walletFileExists; } - MoneroWallet* MoneroWallet::openWallet(const string& path, const string& password, const MoneroNetworkType networkType) { - MTRACE("openWallet(" << path << ", " << password << ", " << networkType << ")"); - MoneroWallet* wallet = new MoneroWallet(); + monero_wallet* monero_wallet::open_wallet(const string& path, const string& password, const MoneroNetworkType networkType) { + MTRACE("open_wallet(" << path << ", " << password << ", " << networkType << ")"); + monero_wallet* wallet = new monero_wallet(); wallet->wallet2 = unique_ptr(new tools::wallet2(static_cast(networkType), 1, true)); wallet->wallet2->load(path, password); wallet->wallet2->init(""); @@ -801,16 +801,16 @@ namespace monero { return wallet; } - MoneroWallet* MoneroWallet::createWalletRandom(const string& path, const string& password) { - MTRACE("createWalletRandom(path, password)"); + monero_wallet* monero_wallet::create_wallet_random(const string& path, const string& password) { + MTRACE("create_wallet_random(path, password)"); throw runtime_error("Not implemented"); } - MoneroWallet* MoneroWallet::createWalletRandom(const string& path, const string& password, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language) { - MTRACE("createWalletRandom(path, password, networkType, daemonConnection, language)"); - MoneroWallet* wallet = new MoneroWallet(); + monero_wallet* monero_wallet::create_wallet_random(const string& path, const string& password, const MoneroNetworkType networkType, const monero_rpc_connection& daemonConnection, const string& language) { + MTRACE("create_wallet_random(path, password, networkType, daemonConnection, language)"); + monero_wallet* wallet = new monero_wallet(); wallet->wallet2 = unique_ptr(new tools::wallet2(static_cast(networkType), 1, true)); - wallet->setDaemonConnection(daemonConnection); + wallet->set_daemon_connection(daemonConnection); wallet->wallet2->set_seed_language(language); crypto::secret_key secret_key; wallet->wallet2->generate(path, password, secret_key, false, false); @@ -818,14 +818,14 @@ namespace monero { return wallet; } - MoneroWallet* MoneroWallet::createWalletFromMnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic) { - MTRACE("createWalletFromMnemonic(path, password, networkType, mnemonic)"); + monero_wallet* monero_wallet::create_wallet_from_mnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic) { + MTRACE("create_wallet_from_mnemonic(path, password, networkType, mnemonic)"); throw runtime_error("Not implemented"); } - MoneroWallet* MoneroWallet::createWalletFromMnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight) { - MTRACE("createWalletFromMnemonic(path, password, mnemonic, networkType, daemonConnection, restoreHeight)"); - MoneroWallet* wallet = new MoneroWallet(); + monero_wallet* monero_wallet::create_wallet_from_mnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic, const monero_rpc_connection& daemonConnection, uint64_t restoreHeight) { + MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, networkType, daemonConnection, restoreHeight)"); + monero_wallet* wallet = new monero_wallet(); // validate mnemonic and get recovery key and language crypto::secret_key recoveryKey; @@ -836,7 +836,7 @@ namespace monero { // initialize wallet wallet->wallet2 = unique_ptr(new tools::wallet2(static_cast(networkType), 1, true)); - wallet->setDaemonConnection(daemonConnection); + wallet->set_daemon_connection(daemonConnection); wallet->wallet2->set_seed_language(language); wallet->wallet2->generate(path, password, recoveryKey, true, false); wallet->wallet2->set_refresh_from_block_height(restoreHeight); @@ -844,19 +844,19 @@ namespace monero { return wallet; } - MoneroWallet* MoneroWallet::createWalletFromKeys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey) { - MTRACE("createWalletFromKeys(path, password, address, viewKey, spendKey, networkType)"); + monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey) { + MTRACE("create_wallet_from_keys(path, password, address, viewKey, spendKey, networkType)"); throw runtime_error("Not implemented"); } - MoneroWallet* MoneroWallet::createWalletFromKeys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight) { - MTRACE("createWalletFromKeys(path, password, address, viewKey, spendKey, networkType, daemonConnection, restoreHeight)"); + monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const monero_rpc_connection& daemonConnection, uint64_t restoreHeight) { + MTRACE("create_wallet_from_keys(path, password, address, viewKey, spendKey, networkType, daemonConnection, restoreHeight)"); throw runtime_error("Not implemented"); } - MoneroWallet* MoneroWallet::createWalletFromKeys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight, const string& language) { - MTRACE("createWalletFromKeys(path, password, address, viewKey, spendKey, networkType, daemonConnection, restoreHeight, language)"); - MoneroWallet* wallet = new MoneroWallet(); + monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const monero_rpc_connection& daemonConnection, uint64_t restoreHeight, const string& language) { + MTRACE("create_wallet_from_keys(path, password, address, viewKey, spendKey, networkType, daemonConnection, restoreHeight, language)"); + monero_wallet* wallet = new monero_wallet(); // validate and parse address cryptonote::address_parse_info info; @@ -905,22 +905,22 @@ namespace monero { if (hasSpendKey && hasViewKey) wallet->wallet2->generate(path, password, info.address, spendKeySK, viewKeySK); if (!hasSpendKey && hasViewKey) wallet->wallet2->generate(path, password, info.address, viewKeySK); if (hasSpendKey && !hasViewKey) wallet->wallet2->generate(path, password, spendKeySK, true, false); - wallet->setDaemonConnection(daemonConnection); + wallet->set_daemon_connection(daemonConnection); wallet->wallet2->set_refresh_from_block_height(restoreHeight); wallet->wallet2->set_seed_language(language); wallet->initCommon(); return wallet; } - MoneroWallet::~MoneroWallet() { - MTRACE("~MoneroWallet()"); + monero_wallet::~monero_wallet() { + MTRACE("~monero_wallet()"); close(); } // ----------------------------- WALLET METHODS ----------------------------- - void MoneroWallet::setDaemonConnection(const string& uri, const string& username, const string& password) { - MTRACE("setDaemonConnection(" << uri << ", " << username << ", " << password << ")"); + void monero_wallet::set_daemon_connection(const string& uri, const string& username, const string& password) { + MTRACE("set_daemon_connection(" << uri << ", " << username << ", " << password << ")"); // prepare uri, login, and isTrusted for wallet2 boost::optional login{}; @@ -931,17 +931,17 @@ namespace monero { // init wallet2 and set daemon connection if (!wallet2->init(uri, login)) throw runtime_error("Failed to initialize wallet with daemon connection"); - getIsConnected(); // update isConnected cache // TODO: better naming? + get_is_connected(); // update isConnected cache // TODO: better naming? } - void MoneroWallet::setDaemonConnection(const MoneroRpcConnection& connection) { - setDaemonConnection(connection.uri, connection.username == boost::none ? "" : connection.username.get(), connection.password == boost::none ? "" : connection.password.get()); + void monero_wallet::set_daemon_connection(const monero_rpc_connection& connection) { + set_daemon_connection(connection.uri, connection.username == boost::none ? "" : connection.username.get(), connection.password == boost::none ? "" : connection.password.get()); } - shared_ptr MoneroWallet::getDaemonConnection() const { - MTRACE("MoneroWallet::getDaemonConnection()"); + shared_ptr monero_wallet::get_daemon_connection() const { + MTRACE("monero_wallet::get_daemon_connection()"); if (wallet2->get_daemon_address().empty()) return nullptr; - shared_ptr connection = make_shared(); + shared_ptr connection = make_shared(); if (!wallet2->get_daemon_address().empty()) connection->uri = wallet2->get_daemon_address(); if (wallet2->get_daemon_login()) { if (!wallet2->get_daemon_login()->username.empty()) connection->username = wallet2->get_daemon_login()->username; @@ -953,7 +953,7 @@ namespace monero { } // TODO: could return Wallet::ConnectionStatus_Disconnected, Wallet::ConnectionStatus_WrongVersion, Wallet::ConnectionStatus_Connected like wallet.cpp::connected() - bool MoneroWallet::getIsConnected() const { + bool monero_wallet::get_is_connected() const { uint32_t version = 0; isConnected = wallet2->check_connection(&version, NULL, DEFAULT_CONNECTION_TIMEOUT_MILLIS); // TODO: should this be updated elsewhere? if (!isConnected) return false; @@ -961,7 +961,7 @@ namespace monero { return isConnected; } - uint64_t MoneroWallet::getDaemonHeight() const { + uint64_t monero_wallet::get_daemon_height() const { if (!isConnected) throw runtime_error("wallet is not connected to daemon"); std::string err; uint64_t result = wallet2->get_daemon_blockchain_height(err); @@ -969,38 +969,38 @@ namespace monero { return result; } - uint64_t MoneroWallet::getDaemonTargetHeight() const { + uint64_t monero_wallet::get_daemon_target_height() const { if (!isConnected) throw runtime_error("wallet is not connected to daemon"); std::string err; uint64_t result = wallet2->get_daemon_blockchain_target_height(err); if (!err.empty()) throw runtime_error(err); - if (result == 0) result = getDaemonHeight(); // TODO monero core: target height can be 0 when daemon is synced. Use blockchain height instead + if (result == 0) result = get_daemon_height(); // TODO monero core: target height can be 0 when daemon is synced. Use blockchain height instead return result; } - bool MoneroWallet::getIsDaemonSynced() const { + bool monero_wallet::get_is_daemon_synced() const { if (!isConnected) throw runtime_error("wallet is not connected to daemon"); - uint64_t daemonHeight = getDaemonHeight(); - return daemonHeight >= getDaemonTargetHeight() && daemonHeight > 1; + uint64_t daemonHeight = get_daemon_height(); + return daemonHeight >= get_daemon_target_height() && daemonHeight > 1; } - bool MoneroWallet::getIsSynced() const { + bool monero_wallet::get_is_synced() const { return isSynced; } - string MoneroWallet::getPath() const { + string monero_wallet::get_path() const { return wallet2->path(); } - MoneroNetworkType MoneroWallet::getNetworkType() const { + MoneroNetworkType monero_wallet::get_network_type() const { return static_cast(wallet2->nettype()); } - string MoneroWallet::getLanguage() const { + string monero_wallet::get_language() const { return wallet2->get_seed_language(); } - vector MoneroWallet::getLanguages() const { + vector monero_wallet::get_languages() const { vector languages; crypto::ElectrumWords::get_language_list(languages, true); return languages; @@ -1008,12 +1008,12 @@ namespace monero { // get primary address (default impl?) - string MoneroWallet::getAddress(uint32_t accountIdx, uint32_t subaddressIdx) const { + string monero_wallet::get_address(uint32_t accountIdx, uint32_t subaddressIdx) const { return wallet2->get_subaddress_as_str({accountIdx, subaddressIdx}); } - MoneroSubaddress MoneroWallet::getAddressIndex(const string& address) const { - MTRACE("getAddressIndex(" << address << ")"); + monero_subaddress monero_wallet::get_address_index(const string& address) const { + MTRACE("get_address_index(" << address << ")"); // validate address cryptonote::address_parse_info info; @@ -1026,15 +1026,15 @@ namespace monero { if (!index) throw runtime_error("Address doesn't belong to the wallet"); // return indices in subaddress - MoneroSubaddress subaddress; + monero_subaddress subaddress; cryptonote::subaddress_index cnIndex = *index; subaddress.accountIndex = cnIndex.major; subaddress.index = cnIndex.minor; return subaddress; } - MoneroIntegratedAddress MoneroWallet::getIntegratedAddress(const string& standardAddress, const string& paymentId) const { - MTRACE("getIntegratedAddress(" << standardAddress << ", " << paymentId << ")"); + monero_integrated_address monero_wallet::get_integrated_address(const string& standardAddress, const string& paymentId) const { + MTRACE("get_integrated_address(" << standardAddress << ", " << paymentId << ")"); // TODO monero-core: this logic is based on wallet_rpc_server::on_make_integrated_address() and should be moved to wallet so this is unecessary for api users @@ -1048,7 +1048,7 @@ namespace monero { // use primary address if standard address not given, else validate if (standardAddress.empty()) { - return decodeIntegratedAddress(wallet2->get_integrated_address_as_str(paymentIdH8)); + return decode_integrated_address(wallet2->get_integrated_address_as_str(paymentIdH8)); } else { // validate standard address @@ -1059,12 +1059,12 @@ namespace monero { if (paymentId.empty()) throw runtime_error("Payment ID shouldn't be left unspecified"); // create integrated address from given standard address - return decodeIntegratedAddress(cryptonote::get_account_integrated_address_as_str(wallet2->nettype(), info.address, paymentIdH8)); + return decode_integrated_address(cryptonote::get_account_integrated_address_as_str(wallet2->nettype(), info.address, paymentIdH8)); } } - MoneroIntegratedAddress MoneroWallet::decodeIntegratedAddress(const string& integratedAddress) const { - MTRACE("decodeIntegratedAddress(" << integratedAddress << ")"); + monero_integrated_address monero_wallet::decode_integrated_address(const string& integratedAddress) const { + MTRACE("decode_integrated_address(" << integratedAddress << ")"); // validate integrated address cryptonote::address_parse_info info; @@ -1072,63 +1072,63 @@ namespace monero { if (!info.has_payment_id) throw runtime_error("Address is not an integrated address"); // initialize and return result - MoneroIntegratedAddress result; + monero_integrated_address result; result.standardAddress = cryptonote::get_account_address_as_str(wallet2->nettype(), info.is_subaddress, info.address); result.paymentId = epee::string_tools::pod_to_hex(info.payment_id); result.integratedAddress = integratedAddress; return result; } - string MoneroWallet::getMnemonic() const { + string monero_wallet::get_mnemonic() const { epee::wipeable_string wipeablePassword; wallet2->get_seed(wipeablePassword); return string(wipeablePassword.data(), wipeablePassword.size()); } - string MoneroWallet::getPublicViewKey() const { - MTRACE("getPrivateViewKey()"); + string monero_wallet::get_public_view_key() const { + MTRACE("get_private_view_key()"); return epee::string_tools::pod_to_hex(wallet2->get_account().get_keys().m_account_address.m_view_public_key); } - string MoneroWallet::getPrivateViewKey() const { - MTRACE("getPrivateViewKey()"); + string monero_wallet::get_private_view_key() const { + MTRACE("get_private_view_key()"); return epee::string_tools::pod_to_hex(wallet2->get_account().get_keys().m_view_secret_key); } - string MoneroWallet::getPublicSpendKey() const { - MTRACE("getPrivateSpendKey()"); + string monero_wallet::get_public_spend_key() const { + MTRACE("get_private_spend_key()"); return epee::string_tools::pod_to_hex(wallet2->get_account().get_keys().m_account_address.m_spend_public_key); } - string MoneroWallet::getPrivateSpendKey() const { - MTRACE("getPrivateSpendKey()"); + string monero_wallet::get_private_spend_key() const { + MTRACE("get_private_spend_key()"); return epee::string_tools::pod_to_hex(wallet2->get_account().get_keys().m_spend_secret_key); } - void MoneroWallet::setListener(const boost::optional listener) { - MTRACE("setListener()"); + void monero_wallet::set_listener(const boost::optional listener) { + MTRACE("set_listener()"); wallet2Listener->setWalletListener(listener); } - MoneroSyncResult MoneroWallet::sync() { + monero_sync_result monero_wallet::sync() { MTRACE("sync()"); if (!isConnected) throw runtime_error("No connection to daemon"); return lockAndSync(); } - MoneroSyncResult MoneroWallet::sync(MoneroSyncListener& listener) { + monero_sync_result monero_wallet::sync(monero_sync_listener& listener) { MTRACE("sync(listener)"); if (!isConnected) throw runtime_error("No connection to daemon"); return lockAndSync(boost::none, listener); } - MoneroSyncResult MoneroWallet::sync(uint64_t startHeight) { + monero_sync_result monero_wallet::sync(uint64_t startHeight) { MTRACE("sync(" << startHeight << ")"); if (!isConnected) throw runtime_error("No connection to daemon"); return lockAndSync(startHeight); } - MoneroSyncResult MoneroWallet::sync(uint64_t startHeight, MoneroSyncListener& listener) { + monero_sync_result monero_wallet::sync(uint64_t startHeight, monero_sync_listener& listener) { MTRACE("sync(" << startHeight << ", listener)"); if (!isConnected) throw runtime_error("No connection to daemon"); return lockAndSync(startHeight, listener); @@ -1137,7 +1137,7 @@ namespace monero { /** * Start automatic syncing as its own thread. */ - void MoneroWallet::startSyncing() { + void monero_wallet::start_syncing() { if (!syncingEnabled) { syncingEnabled = true; syncCV.notify_one(); @@ -1147,15 +1147,15 @@ namespace monero { /** * Stop automatic syncing as its own thread. */ - void MoneroWallet::stopSyncing() { + void monero_wallet::stop_syncing() { if (!syncingThreadDone) { syncingEnabled = false; } } // TODO: support arguments bool hard, bool refresh = true, bool keep_key_images = false - void MoneroWallet::rescanBlockchain() { - MTRACE("rescanBlockchain()"); + void monero_wallet::rescan_blockchain() { + MTRACE("rescan_blockchain()"); if (!isConnected) throw runtime_error("No connection to daemon"); rescanOnSync = true; lockAndSync(); @@ -1163,11 +1163,11 @@ namespace monero { // isMultisigImportNeeded - uint64_t MoneroWallet::getHeight() const { + uint64_t monero_wallet::get_height() const { return wallet2->get_blockchain_current_height(); } - uint64_t MoneroWallet::getChainHeight() const { + uint64_t monero_wallet::getChainHeight() const { string err; if (!isConnected) throw runtime_error("No connection to daemon"); uint64_t chainHeight = wallet2->get_daemon_blockchain_height(err); @@ -1175,70 +1175,70 @@ namespace monero { return chainHeight; } - uint64_t MoneroWallet::getRestoreHeight() const { + uint64_t monero_wallet::get_restore_height() const { return wallet2->get_refresh_from_block_height(); } - void MoneroWallet::setRestoreHeight(uint64_t restoreHeight) { + void monero_wallet::set_restore_height(uint64_t restoreHeight) { wallet2->set_refresh_from_block_height(restoreHeight); } - uint64_t MoneroWallet::getBalance() const { + uint64_t monero_wallet::get_balance() const { return wallet2->balance_all(); } - uint64_t MoneroWallet::getBalance(uint32_t accountIdx) const { + uint64_t monero_wallet::get_balance(uint32_t accountIdx) const { return wallet2->balance(accountIdx); } - uint64_t MoneroWallet::getBalance(uint32_t accountIdx, uint32_t subaddressIdx) const { + uint64_t monero_wallet::get_balance(uint32_t accountIdx, uint32_t subaddressIdx) const { map balancePerSubaddress = wallet2->balance_per_subaddress(accountIdx); auto iter = balancePerSubaddress.find(subaddressIdx); return iter == balancePerSubaddress.end() ? 0 : iter->second; } - uint64_t MoneroWallet::getUnlockedBalance() const { + uint64_t monero_wallet::get_unlocked_balance() const { return wallet2->unlocked_balance_all(); } - uint64_t MoneroWallet::getUnlockedBalance(uint32_t accountIdx) const { + uint64_t monero_wallet::get_unlocked_balance(uint32_t accountIdx) const { return wallet2->unlocked_balance(accountIdx); } - uint64_t MoneroWallet::getUnlockedBalance(uint32_t accountIdx, uint32_t subaddressIdx) const { + uint64_t monero_wallet::get_unlocked_balance(uint32_t accountIdx, uint32_t subaddressIdx) const { map> unlockedBalancePerSubaddress = wallet2->unlocked_balance_per_subaddress(accountIdx); auto iter = unlockedBalancePerSubaddress.find(subaddressIdx); return iter == unlockedBalancePerSubaddress.end() ? 0 : iter->second.first; } - vector MoneroWallet::getAccounts() const { - MTRACE("getAccounts()"); - return getAccounts(false, string("")); + vector monero_wallet::get_accounts() const { + MTRACE("get_accounts()"); + return get_accounts(false, string("")); } - vector MoneroWallet::getAccounts(bool includeSubaddresses) const { - MTRACE("getAccounts(" << includeSubaddresses << ")"); + vector monero_wallet::get_accounts(bool includeSubaddresses) const { + MTRACE("get_accounts(" << includeSubaddresses << ")"); throw runtime_error("Not implemented"); } - vector MoneroWallet::getAccounts(const string& tag) const { - MTRACE("getAccounts(" << tag << ")"); + vector monero_wallet::get_accounts(const string& tag) const { + MTRACE("get_accounts(" << tag << ")"); throw runtime_error("Not implemented"); } - vector MoneroWallet::getAccounts(bool includeSubaddresses, const string& tag) const { - MTRACE("getAccounts(" << includeSubaddresses << ", " << tag << ")"); + vector monero_wallet::get_accounts(bool includeSubaddresses, const string& tag) const { + MTRACE("get_accounts(" << includeSubaddresses << ", " << tag << ")"); // need transfers to inform if subaddresses used vector transfers; if (includeSubaddresses) wallet2->get_transfers(transfers); // build accounts - vector accounts; + vector accounts; for (uint32_t accountIdx = 0; accountIdx < wallet2->get_num_subaddress_accounts(); accountIdx++) { - MoneroAccount account; + monero_account account; account.index = accountIdx; - account.primaryAddress = getAddress(accountIdx, 0); + account.primaryAddress = get_address(accountIdx, 0); account.balance = wallet2->balance(accountIdx); account.unlockedBalance = wallet2->unlocked_balance(accountIdx); if (includeSubaddresses) account.subaddresses = getSubaddressesAux(accountIdx, vector(), transfers); @@ -1248,35 +1248,35 @@ namespace monero { return accounts; } - MoneroAccount MoneroWallet::getAccount(const uint32_t accountIdx) const { - return getAccount(accountIdx, false); + monero_account monero_wallet::get_account(const uint32_t accountIdx) const { + return get_account(accountIdx, false); } - MoneroAccount MoneroWallet::getAccount(uint32_t accountIdx, bool includeSubaddresses) const { - MTRACE("getAccount(" << accountIdx << ", " << includeSubaddresses << ")"); + monero_account monero_wallet::get_account(uint32_t accountIdx, bool includeSubaddresses) const { + MTRACE("get_account(" << accountIdx << ", " << includeSubaddresses << ")"); // need transfers to inform if subaddresses used vector transfers; if (includeSubaddresses) wallet2->get_transfers(transfers); // build and return account - MoneroAccount account; + monero_account account; account.index = accountIdx; - account.primaryAddress = getAddress(accountIdx, 0); + account.primaryAddress = get_address(accountIdx, 0); account.balance = wallet2->balance(accountIdx); account.unlockedBalance = wallet2->unlocked_balance(accountIdx); if (includeSubaddresses) account.subaddresses = getSubaddressesAux(accountIdx, vector(), transfers); return account; } - MoneroAccount MoneroWallet::createAccount(const string& label) { - MTRACE("createAccount(" << label << ")"); + monero_account monero_wallet::create_account(const string& label) { + MTRACE("create_account(" << label << ")"); // create account wallet2->add_subaddress_account(label); // initialize and return result - MoneroAccount account; + monero_account account; account.index = wallet2->get_num_subaddress_accounts() - 1; account.primaryAddress = wallet2->get_subaddress_as_str({account.index.get(), 0}); account.balance = 0; @@ -1284,12 +1284,12 @@ namespace monero { return account; } - vector MoneroWallet::getSubaddresses(const uint32_t accountIdx) const { - return getSubaddresses(accountIdx, vector()); + vector monero_wallet::get_subaddresses(const uint32_t accountIdx) const { + return get_subaddresses(accountIdx, vector()); } - vector MoneroWallet::getSubaddresses(const uint32_t accountIdx, const vector& subaddressIndices) const { - MTRACE("getSubaddresses(" << accountIdx << ", ...)"); + vector monero_wallet::get_subaddresses(const uint32_t accountIdx, const vector& subaddressIndices) const { + MTRACE("get_subaddresses(" << accountIdx << ", ...)"); MTRACE("Subaddress indices size: " << subaddressIndices.size()); vector transfers; @@ -1297,20 +1297,20 @@ namespace monero { return getSubaddressesAux(accountIdx, subaddressIndices, transfers); } - MoneroSubaddress MoneroWallet::getSubaddress(const uint32_t accountIdx, const uint32_t subaddressIdx) const { + monero_subaddress monero_wallet::getSubaddress(const uint32_t accountIdx, const uint32_t subaddressIdx) const { throw runtime_error("Not implemented"); } - // getSubaddresses + // get_subaddresses - MoneroSubaddress MoneroWallet::createSubaddress(const uint32_t accountIdx, const string& label) { - MTRACE("createSubaddress(" << accountIdx << ", " << label << ")"); + monero_subaddress monero_wallet::create_subaddress(const uint32_t accountIdx, const string& label) { + MTRACE("create_subaddress(" << accountIdx << ", " << label << ")"); // create subaddress wallet2->add_subaddress(accountIdx, label); // initialize and return result - MoneroSubaddress subaddress; + monero_subaddress subaddress; subaddress.accountIndex = accountIdx; subaddress.index = wallet2->get_num_subaddresses(accountIdx) - 1; subaddress.address = wallet2->get_subaddress_as_str({accountIdx, subaddress.index.get()}); @@ -1323,19 +1323,19 @@ namespace monero { return subaddress; } - vector> MoneroWallet::getTxs() const { - MoneroTxRequest request; - return getTxs(request); + vector> monero_wallet::get_txs() const { + monero_tx_request request; + return get_txs(request); } - vector> MoneroWallet::getTxs(const MoneroTxRequest& request) const { - MTRACE("getTxs(request)"); + vector> monero_wallet::get_txs(const monero_tx_request& request) const { + MTRACE("get_txs(request)"); // copy and normalize tx request - shared_ptr requestSp = make_shared(request); // convert to shared pointer for copy - shared_ptr req = requestSp->copy(requestSp, make_shared()); - if (req->transferRequest == boost::none) req->transferRequest = make_shared(); - shared_ptr transferReq = req->transferRequest.get(); + shared_ptr requestSp = make_shared(request); // convert to shared pointer for copy + shared_ptr req = requestSp->copy(requestSp, make_shared()); + if (req->transferRequest == boost::none) req->transferRequest = make_shared(); + shared_ptr transferReq = req->transferRequest.get(); // print req if (req->block != boost::none) MTRACE("Tx req's rooted at [block]: " << req->block.get()->serialize()); @@ -1345,14 +1345,14 @@ namespace monero { req->transferRequest = boost::none; // fetch all transfers that meet tx request - MoneroTransferRequest tempTransferReq; - tempTransferReq.txRequest = make_shared(*req); - vector> transfers = getTransfers(tempTransferReq); + monero_transfer_request tempTransferReq; + tempTransferReq.txRequest = make_shared(*req); + vector> transfers = get_transfers(tempTransferReq); // collect unique txs from transfers while retaining order - vector> txs = vector>(); - unordered_set> txsSet; - for (const shared_ptr& transfer : transfers) { + vector> txs = vector>(); + unordered_set> txsSet; + for (const shared_ptr& transfer : transfers) { if (txsSet.find(transfer->tx) == txsSet.end()) { txs.push_back(transfer->tx); txsSet.insert(transfer->tx); @@ -1360,26 +1360,26 @@ namespace monero { } // cache types into maps for merging and lookup - map> txMap; - map> blockMap; - for (const shared_ptr& tx : txs) { - mergeTx(tx, txMap, blockMap, false); + map> txMap; + map> blockMap; + for (const shared_ptr& tx : txs) { + merge_tx(tx, txMap, blockMap, false); } // fetch and merge outputs if requested - MoneroOutputRequest tempOutputReq; - tempOutputReq.txRequest = make_shared(*req); + monero_output_request tempOutputReq; + tempOutputReq.txRequest = make_shared(*req); if (req->includeOutputs != boost::none && *req->includeOutputs) { // fetch outputs - vector> outputs = getOutputs(tempOutputReq); + vector> outputs = get_outputs(tempOutputReq); // merge output txs one time while retaining order - unordered_set> outputTxs; - for (const shared_ptr& output : outputs) { - shared_ptr tx = static_pointer_cast(output->tx); + unordered_set> outputTxs; + for (const shared_ptr& output : outputs) { + shared_ptr tx = static_pointer_cast(output->tx); if (outputTxs.find(tx) == outputTxs.end()) { - mergeTx(tx, txMap, blockMap, true); + merge_tx(tx, txMap, blockMap, true); outputTxs.insert(tx); } } @@ -1387,10 +1387,10 @@ namespace monero { // filter txs that don't meet transfer req // TODO: port this updated version to js req->transferRequest = transferReq; - vector> txsRequested; - vector>::iterator txIter = txs.begin(); + vector> txsRequested; + vector>::iterator txIter = txs.begin(); while (txIter != txs.end()) { - shared_ptr tx = *txIter; + shared_ptr tx = *txIter; if (req->meetsCriteria(tx.get())) { txsRequested.push_back(tx); txIter++; @@ -1405,7 +1405,7 @@ namespace monero { if (!req->txIds.empty()) { for (const string& txId : req->txIds) { bool found = false; - for (const shared_ptr& tx : txs) { + for (const shared_ptr& tx : txs) { if (txId == *tx->id) { found = true; break; @@ -1417,15 +1417,15 @@ namespace monero { // special case: re-fetch txs if inconsistency caused by needing to make multiple wallet calls // TODO monero core: offer wallet.get_txs(...) - for (const shared_ptr& tx : txs) { - if (*tx->isConfirmed && tx->block == boost::none) return getTxs(*req); + for (const shared_ptr& tx : txs) { + if (*tx->isConfirmed && tx->block == boost::none) return get_txs(*req); } // otherwise order txs if tx ids given then return if (!req->txIds.empty()) { - vector> orderedTxs; + vector> orderedTxs; for (const string& txId : req->txIds) { - map>::const_iterator txIter = txMap.find(txId); + map>::const_iterator txIter = txMap.find(txId); orderedTxs.push_back(txIter->second); } txs = orderedTxs; @@ -1433,8 +1433,8 @@ namespace monero { return txs; } - vector> MoneroWallet::getTransfers(const MoneroTransferRequest& request) const { - MTRACE("MoneroWallet::getTransfers(request)"); + vector> monero_wallet::get_transfers(const monero_transfer_request& request) const { + MTRACE("monero_wallet::get_transfers(request)"); // LOG request if (request.txRequest != boost::none) { @@ -1443,21 +1443,21 @@ namespace monero { } // copy and normalize request - shared_ptr req; - if (request.txRequest == boost::none) req = request.copy(make_shared(request), make_shared()); + shared_ptr req; + if (request.txRequest == boost::none) req = request.copy(make_shared(request), make_shared()); else { - shared_ptr txReq = request.txRequest.get()->copy(request.txRequest.get(), make_shared()); + shared_ptr txReq = request.txRequest.get()->copy(request.txRequest.get(), make_shared()); if (request.txRequest.get()->transferRequest != boost::none && request.txRequest.get()->transferRequest.get().get() == &request) { req = txReq->transferRequest.get(); } else { if (request.txRequest.get()->transferRequest != boost::none) throw new runtime_error("Transfer request's tx request must be a circular reference or null"); - shared_ptr requestSp = make_shared(request); // convert request to shared pointer for copy - req = requestSp->copy(requestSp, make_shared()); + shared_ptr requestSp = make_shared(request); // convert request to shared pointer for copy + req = requestSp->copy(requestSp, make_shared()); req->txRequest = txReq; } } - if (req->txRequest == boost::none) req->txRequest = make_shared(); - shared_ptr txReq = req->txRequest.get(); + if (req->txRequest == boost::none) req->txRequest = make_shared(); + shared_ptr txReq = req->txRequest.get(); txReq->transferRequest = boost::none; // break circular link for meetsCriteria() // build parameters for wallet2->get_payments() @@ -1471,9 +1471,9 @@ namespace monero { subaddressIndices.insert(req->subaddressIndices[i]); } - // translate from MoneroTxRequest to in, out, pending, pool, failed terminology used by monero-wallet-rpc + // translate from monero_tx_request to in, out, pending, pool, failed terminology used by monero-wallet-rpc bool canBeConfirmed = !boolEquals(false, txReq->isConfirmed) && !boolEquals(true, txReq->inTxPool) && !boolEquals(true, txReq->isFailed) && !boolEquals(false, txReq->isRelayed); - bool canBeInTxPool = !boolEquals(true, txReq->isConfirmed) && !boolEquals(false, txReq->inTxPool) && !boolEquals(true, txReq->isFailed) && !boolEquals(false, txReq->isRelayed) && txReq->getHeight() == boost::none && txReq->minHeight == boost::none; + bool canBeInTxPool = !boolEquals(true, txReq->isConfirmed) && !boolEquals(false, txReq->inTxPool) && !boolEquals(true, txReq->isFailed) && !boolEquals(false, txReq->isRelayed) && txReq->get_height() == boost::none && txReq->minHeight == boost::none; bool canBeIncoming = !boolEquals(false, req->isIncoming) && !boolEquals(true, req->getIsOutgoing()) && !boolEquals(true, req->hasDestinations); bool canBeOutgoing = !boolEquals(false, req->getIsOutgoing()) && !boolEquals(true, req->isIncoming); bool isIn = canBeIncoming && canBeConfirmed; @@ -1483,17 +1483,17 @@ namespace monero { bool isFailed = !boolEquals(false, txReq->isFailed) && !boolEquals(true, txReq->isConfirmed) && !boolEquals(true, txReq->inTxPool); // cache unique txs and blocks - uint64_t height = getHeight(); - map> txMap; - map> blockMap; + uint64_t height = get_height(); + map> txMap; + map> blockMap; // get confirmed incoming transfers if (isIn) { std::list> payments; wallet2->get_payments(payments, minHeight, maxHeight, accountIndex, subaddressIndices); for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { - shared_ptr tx = buildTxWithIncomingTransfer(*wallet2, height, i->first, i->second); - mergeTx(tx, txMap, blockMap, false); + shared_ptr tx = buildTxWithIncomingTransfer(*wallet2, height, i->first, i->second); + merge_tx(tx, txMap, blockMap, false); } } @@ -1502,8 +1502,8 @@ namespace monero { std::list> payments; wallet2->get_payments_out(payments, minHeight, maxHeight, accountIndex, subaddressIndices); for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { - shared_ptr tx = buildTxWithOutgoingTransfer(*wallet2, height, i->first, i->second); - mergeTx(tx, txMap, blockMap, false); + shared_ptr tx = buildTxWithOutgoingTransfer(*wallet2, height, i->first, i->second); + merge_tx(tx, txMap, blockMap, false); } } @@ -1512,9 +1512,9 @@ namespace monero { std::list> upayments; wallet2->get_unconfirmed_payments_out(upayments, accountIndex, subaddressIndices); for (std::list>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) { - shared_ptr tx = buildTxWithOutgoingTransferUnconfirmed(*wallet2, i->first, i->second); + shared_ptr tx = buildTxWithOutgoingTransferUnconfirmed(*wallet2, i->first, i->second); if (txReq->isFailed != boost::none && txReq->isFailed.get() != tx->isFailed.get()) continue; // skip merging if tx unrequested - mergeTx(tx, txMap, blockMap, false); + merge_tx(tx, txMap, blockMap, false); } } @@ -1524,21 +1524,21 @@ namespace monero { std::list> payments; wallet2->get_unconfirmed_payments(payments, accountIndex, subaddressIndices); for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { - shared_ptr tx = buildTxWithIncomingTransferUnconfirmed(*wallet2, i->first, i->second); - mergeTx(tx, txMap, blockMap, false); + shared_ptr tx = buildTxWithIncomingTransferUnconfirmed(*wallet2, i->first, i->second); + merge_tx(tx, txMap, blockMap, false); } } // sort txs by block height - vector> txs ; - for (map>::const_iterator txIter = txMap.begin(); txIter != txMap.end(); txIter++) { + vector> txs ; + for (map>::const_iterator txIter = txMap.begin(); txIter != txMap.end(); txIter++) { txs.push_back(txIter->second); } sort(txs.begin(), txs.end(), txHeightLessThan); // filter and return transfers - vector> transfers; - for (const shared_ptr& tx : txs) { + vector> transfers; + for (const shared_ptr& tx : txs) { // sort transfers sort(tx->incomingTransfers.begin(), tx->incomingTransfers.end(), incomingTransferBefore); @@ -1548,7 +1548,7 @@ namespace monero { else tx->outgoingTransfer = boost::none; // collect incoming transfers, erase if unrequested - vector>::iterator iter = tx->incomingTransfers.begin(); + vector>::iterator iter = tx->incomingTransfers.begin(); while (iter != tx->incomingTransfers.end()) { if (req->meetsCriteria((*iter).get())) { transfers.push_back(*iter); @@ -1563,13 +1563,13 @@ namespace monero { tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator? } } - MTRACE("MoneroWallet.cpp getTransfers() returning " << transfers.size() << " transfers"); + MTRACE("monero_wallet.cpp get_transfers() returning " << transfers.size() << " transfers"); return transfers; } - vector> MoneroWallet::getOutputs(const MoneroOutputRequest& request) const { - MTRACE("MoneroWallet::getOutputs(request)"); + vector> monero_wallet::get_outputs(const monero_output_request& request) const { + MTRACE("monero_wallet::get_outputs(request)"); // print request MTRACE("Output request: " << request.serialize()); @@ -1579,21 +1579,21 @@ namespace monero { } // copy and normalize request - shared_ptr req; - if (request.txRequest == boost::none) req = request.copy(make_shared(request), make_shared()); + shared_ptr req; + if (request.txRequest == boost::none) req = request.copy(make_shared(request), make_shared()); else { - shared_ptr txReq = request.txRequest.get()->copy(request.txRequest.get(), make_shared()); + shared_ptr txReq = request.txRequest.get()->copy(request.txRequest.get(), make_shared()); if (request.txRequest.get()->outputRequest != boost::none && request.txRequest.get()->outputRequest.get().get() == &request) { req = txReq->outputRequest.get(); } else { if (request.txRequest.get()->outputRequest != boost::none) throw new runtime_error("Output request's tx request must be a circular reference or null"); - shared_ptr requestSp = make_shared(request); // convert request to shared pointer for copy - req = requestSp->copy(requestSp, make_shared()); + shared_ptr requestSp = make_shared(request); // convert request to shared pointer for copy + req = requestSp->copy(requestSp, make_shared()); req->txRequest = txReq; } } - if (req->txRequest == boost::none) req->txRequest = make_shared(); - shared_ptr txReq = req->txRequest.get(); + if (req->txRequest == boost::none) req->txRequest = make_shared(); + shared_ptr txReq = req->txRequest.get(); txReq->outputRequest = boost::none; // break circular link for meetsCriteria() // get output data from wallet2 @@ -1601,32 +1601,32 @@ namespace monero { wallet2->get_transfers(outputsW2); // cache unique txs and blocks - map> txMap; - map> blockMap; + map> txMap; + map> blockMap; for (const auto& outputW2 : outputsW2) { // TODO: skip tx building if w2 output filtered by indices, etc - shared_ptr tx = buildTxWithVout(*wallet2, outputW2); - mergeTx(tx, txMap, blockMap, false); + shared_ptr tx = buildTxWithVout(*wallet2, outputW2); + merge_tx(tx, txMap, blockMap, false); } // sort txs by block height - vector> txs ; - for (map>::const_iterator txIter = txMap.begin(); txIter != txMap.end(); txIter++) { + vector> txs ; + for (map>::const_iterator txIter = txMap.begin(); txIter != txMap.end(); txIter++) { txs.push_back(txIter->second); } sort(txs.begin(), txs.end(), txHeightLessThan); // filter and return outputs - vector> vouts; - for (const shared_ptr& tx : txs) { + vector> vouts; + for (const shared_ptr& tx : txs) { // sort outputs sort(tx->vouts.begin(), tx->vouts.end(), voutBefore); // collect requested outputs, remove unrequested outputs - vector>::iterator voutIter = tx->vouts.begin(); + vector>::iterator voutIter = tx->vouts.begin(); while (voutIter != tx->vouts.end()) { - shared_ptr voutWallet = static_pointer_cast(*voutIter); + shared_ptr voutWallet = static_pointer_cast(*voutIter); if (req->meetsCriteria(voutWallet.get())) { vouts.push_back(voutWallet); voutIter++; @@ -1641,11 +1641,11 @@ namespace monero { return vouts; } - string MoneroWallet::getOutputsHex() const { + string monero_wallet::get_outputs_hex() const { return epee::string_tools::buff_to_hex_nodelimer(wallet2->export_outputs_to_str(true)); } - int MoneroWallet::importOutputsHex(const string& outputsHex) { + int monero_wallet::import_outputs_hex(const string& outputsHex) { // validate and parse hex data cryptonote::blobdata blob; @@ -1657,14 +1657,14 @@ namespace monero { return wallet2->import_outputs_from_str(blob); } - vector> MoneroWallet::getKeyImages() const { - MTRACE("MoneroWallet::getKeyImages()"); + vector> monero_wallet::get_key_images() const { + MTRACE("monero_wallet::get_key_images()"); // build key images from wallet2 types - vector> keyImages; + vector> keyImages; std::pair>> ski = wallet2->export_key_images(true); for (size_t n = 0; n < ski.second.size(); ++n) { - shared_ptr keyImage = make_shared(); + shared_ptr keyImage = make_shared(); keyImages.push_back(keyImage); keyImage->hex = epee::string_tools::pod_to_hex(ski.second[n].first); keyImage->signature = epee::string_tools::pod_to_hex(ski.second[n].second); @@ -1672,8 +1672,8 @@ namespace monero { return keyImages; } - shared_ptr MoneroWallet::importKeyImages(const vector>& keyImages) { - MTRACE("MoneroWallet::importKeyImages()"); + shared_ptr monero_wallet::import_key_images(const vector>& keyImages) { + MTRACE("monero_wallet::import_key_images()"); // validate and prepare key images for wallet2 std::vector> ski; @@ -1692,16 +1692,16 @@ namespace monero { uint64_t height = wallet2->import_key_images(ski, 0, spent, unspent); // TODO: use offset? refer to wallet_rpc_server::on_import_key_images() req.offset // translate results - shared_ptr result = make_shared(); + shared_ptr result = make_shared(); result->height = height; result->spentAmount = spent; result->unspentAmount = unspent; return result; } - vector> MoneroWallet::sendSplit(const MoneroSendRequest& request) { - MTRACE("MoneroWallet::sendSplit(request)"); - MTRACE("MoneroSendRequest: " << request.serialize()); + vector> monero_wallet::send_split(const monero_send_request& request) { + MTRACE("monero_wallet::send_split(request)"); + MTRACE("monero_send_request: " << request.serialize()); wallet_rpc::COMMAND_RPC_TRANSFER::request req; wallet_rpc::COMMAND_RPC_TRANSFER::response res; @@ -1710,7 +1710,7 @@ namespace monero { // prepare parameters for wallet rpc's validate_transfer() string paymentId = request.paymentId == boost::none ? string("") : request.paymentId.get(); list trDestinations; - for (const shared_ptr& destination : request.destinations) { + for (const shared_ptr& destination : request.destinations) { tools::wallet_rpc::transfer_destination trDestination; trDestination.amount = destination->amount.get(); trDestination.address = destination->address.get(); @@ -1721,7 +1721,7 @@ namespace monero { std::vector dsts; std::vector extra; if (!validate_transfer(wallet2.get(), trDestinations, paymentId, dsts, extra, true, err)) { - throw runtime_error("Need to handle sendSplit() validate_transfer error"); // TODO + throw runtime_error("Need to handle send_split() validate_transfer error"); // TODO } // prepare parameters for wallet2's create_transactions_2() @@ -1739,7 +1739,7 @@ namespace monero { // check if request cannot be fulfilled due to splitting if (request.canSplit != boost::none && request.canSplit.get() == false && ptx_vector.size() != 1) { - throw runtime_error("Transaction would be too large. Try sendSplit()"); + throw runtime_error("Transaction would be too large. Try send_split()"); } // config for fill_response() @@ -1762,7 +1762,7 @@ namespace monero { } // build sent txs from results // TODO: break this into separate utility function - vector> txs; + vector> txs; auto txIdsIter = txIds.begin(); auto txKeysIter = txKeys.begin(); auto txAmountsIter = txAmounts.begin(); @@ -1772,14 +1772,14 @@ namespace monero { while (txIdsIter != txIds.end()) { // init tx with outgoing transfer from filled values - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); txs.push_back(tx); tx->id = *txIdsIter; tx->key = *txKeysIter; tx->fee = *txFeesIter; tx->fullHex = *txBlobsIter; tx->metadata = *txMetadatasIter; - shared_ptr outTransfer = make_shared(); + shared_ptr outTransfer = make_shared(); tx->outgoingTransfer = outTransfer; outTransfer->amount = *txAmountsIter; @@ -1811,9 +1811,9 @@ namespace monero { return txs; } - shared_ptr MoneroWallet::sweepOutput(const MoneroSendRequest& request) const { - MTRACE("sweepOutput()"); - MTRACE("MoneroSendRequest: " << request.serialize()); + shared_ptr monero_wallet::sweep_output(const monero_send_request& request) const { + MTRACE("sweep_output()"); + MTRACE("monero_send_request: " << request.serialize()); // validate input request if (request.keyImage == boost::none || request.keyImage.get().empty()) throw runtime_error("Must provide key image of output to sweep"); @@ -1870,8 +1870,8 @@ namespace monero { throw runtime_error("need to handle error filling response!"); // TODO: return err message } - // build sent txs from results // TODO: use common utility with sendSplit() to avoid code duplication - vector> txs; + // build sent txs from results // TODO: use common utility with send_split() to avoid code duplication + vector> txs; auto txIdsIter = txIds.begin(); auto txKeysIter = txKeys.begin(); auto txAmountsIter = txAmounts.begin(); @@ -1881,14 +1881,14 @@ namespace monero { while (txIdsIter != txIds.end()) { // init tx with outgoing transfer from filled values - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); txs.push_back(tx); tx->id = *txIdsIter; tx->key = *txKeysIter; tx->fee = *txFeesIter; tx->fullHex = *txBlobsIter; tx->metadata = *txMetadatasIter; - shared_ptr outTransfer = make_shared(); + shared_ptr outTransfer = make_shared(); tx->outgoingTransfer = outTransfer; outTransfer->amount = *txAmountsIter; @@ -1924,8 +1924,8 @@ namespace monero { return txs[0]; } - vector> MoneroWallet::sweepDust(bool doNotRelay) { - MTRACE("MoneroWallet::sweepDust()"); + vector> monero_wallet::sweep_dust(bool doNotRelay) { + MTRACE("monero_wallet::sweep_dust()"); // create transaction to fill std::vector ptx_vector = wallet2->create_unmixable_sweep_transactions(); @@ -1949,8 +1949,8 @@ namespace monero { throw runtime_error("need to handle error filling response!"); // TODO: return err message } - // build sent txs from results // TODO: use common utility with sendSplit() to avoid code duplication - vector> txs; + // build sent txs from results // TODO: use common utility with send_split() to avoid code duplication + vector> txs; auto txIdsIter = txIds.begin(); auto txKeysIter = txKeys.begin(); auto txAmountsIter = txAmounts.begin(); @@ -1960,14 +1960,14 @@ namespace monero { while (txIdsIter != txIds.end()) { // init tx with outgoing transfer from filled values - shared_ptr tx = make_shared(); + shared_ptr tx = make_shared(); txs.push_back(tx); tx->id = *txIdsIter; tx->key = *txKeysIter; tx->fee = *txFeesIter; tx->fullHex = *txBlobsIter; tx->metadata = *txMetadatasIter; - shared_ptr outTransfer = make_shared(); + shared_ptr outTransfer = make_shared(); tx->outgoingTransfer = outTransfer; outTransfer->amount = *txAmountsIter; @@ -1997,8 +1997,8 @@ namespace monero { return txs; } - vector MoneroWallet::relayTxs(const vector& txMetadatas) { - MTRACE("relayTxs()"); + vector monero_wallet::relay_txs(const vector& txMetadatas) { + MTRACE("relay_txs()"); // relay each metadata as a tx vector txIds; @@ -2035,8 +2035,8 @@ namespace monero { return txIds; } - string MoneroWallet::getTxNote(const string& txId) const { - MTRACE("MoneroWallet::getTxNote()"); + string monero_wallet::get_tx_note(const string& txId) const { + MTRACE("monero_wallet::get_tx_note()"); cryptonote::blobdata txBlob; if (!epee::string_tools::parse_hexstr_to_binbuff(txId, txBlob) || txBlob.size() != sizeof(crypto::hash)) { throw runtime_error("TX ID has invalid format"); @@ -2045,15 +2045,15 @@ namespace monero { return wallet2->get_tx_note(txHash); } - vector MoneroWallet::getTxNotes(const vector& txIds) const { - MTRACE("MoneroWallet::getTxNotes()"); + vector monero_wallet::get_tx_notes(const vector& txIds) const { + MTRACE("monero_wallet::get_tx_notes()"); vector txNotes; - for (const auto& txId : txIds) txNotes.push_back(getTxNote(txId)); + for (const auto& txId : txIds) txNotes.push_back(get_tx_note(txId)); return txNotes; } - void MoneroWallet::setTxNote(const string& txId, const string& note) { - MTRACE("MoneroWallet::setTxNote()"); + void monero_wallet::set_tx_note(const string& txId, const string& note) { + MTRACE("monero_wallet::set_tx_note()"); cryptonote::blobdata txBlob; if (!epee::string_tools::parse_hexstr_to_binbuff(txId, txBlob) || txBlob.size() != sizeof(crypto::hash)) { throw runtime_error("TX ID has invalid format"); @@ -2062,19 +2062,19 @@ namespace monero { wallet2->set_tx_note(txHash, note); } - void MoneroWallet::setTxNotes(const vector& txIds, const vector& txNotes) { - MTRACE("MoneroWallet::setTxNotes()"); + void monero_wallet::set_tx_notes(const vector& txIds, const vector& txNotes) { + MTRACE("monero_wallet::set_tx_notes()"); if (txIds.size() != txNotes.size()) throw runtime_error("Different amount of txids and notes"); for (int i = 0; i < txIds.size(); i++) { - setTxNote(txIds[i], txNotes[i]); + set_tx_note(txIds[i], txNotes[i]); } } - string MoneroWallet::sign(const string& msg) const { + string monero_wallet::sign(const string& msg) const { return wallet2->sign(msg); } - bool MoneroWallet::verify(const string& msg, const string& address, const string& signature) const { + bool monero_wallet::verify(const string& msg, const string& address, const string& signature) const { // validate and parse address or url cryptonote::address_parse_info info; @@ -2099,8 +2099,8 @@ namespace monero { return wallet2->verify(msg, info.address, signature); } - string MoneroWallet::getTxKey(const string& txId) const { - MTRACE("MoneroWallet::getTxKey()"); + string monero_wallet::get_tx_key(const string& txId) const { + MTRACE("monero_wallet::get_tx_key()"); // validate and parse tx id hash crypto::hash txHash; @@ -2124,8 +2124,8 @@ namespace monero { return std::string(s.data(), s.size()); } - shared_ptr MoneroWallet::checkTxKey(const string& txId, const string& txKey, const string& address) const { - MTRACE("MoneroWallet::checkTxKey()"); + shared_ptr monero_wallet::check_tx_key(const string& txId, const string& txKey, const string& address) const { + MTRACE("monero_wallet::check_tx_key()"); // validate and parse tx id crypto::hash txHash; @@ -2166,7 +2166,7 @@ namespace monero { bool inTxPool; uint64_t numConfirmations; wallet2->check_tx_key(txHash, tx_key, additionalTxKeys, info.address, receivedAmount, inTxPool, numConfirmations); - shared_ptr checkTx = make_shared(); + shared_ptr checkTx = make_shared(); checkTx->isGood = true; // check is good if we get this far checkTx->receivedAmount = receivedAmount; checkTx->inTxPool = inTxPool; @@ -2174,7 +2174,7 @@ namespace monero { return checkTx; } - string MoneroWallet::getTxProof(const string& txId, const string& address, const string& message) const { + string monero_wallet::get_tx_proof(const string& txId, const string& address, const string& message) const { // validate and parse tx id hash crypto::hash txHash; @@ -2192,8 +2192,8 @@ namespace monero { return wallet2->get_tx_proof(txHash, info.address, info.is_subaddress, message); } - shared_ptr MoneroWallet::checkTxProof(const string& txId, const string& address, const string& message, const string& signature) const { - MTRACE("MoneroWallet::checkTxProof()"); + shared_ptr monero_wallet::check_tx_proof(const string& txId, const string& address, const string& message, const string& signature) const { + MTRACE("monero_wallet::check_tx_proof()"); // validate and parse tx id crypto::hash txHash; @@ -2208,7 +2208,7 @@ namespace monero { } // initialize and return tx check using wallet2 - shared_ptr checkTx = make_shared(); + shared_ptr checkTx = make_shared(); uint64_t receivedAmount; bool inTxPool; uint64_t numConfirmations; @@ -2221,8 +2221,8 @@ namespace monero { return checkTx; } - string MoneroWallet::getSpendProof(const string& txId, const string& message) const { - MTRACE("MoneroWallet::getSpendProof()"); + string monero_wallet::get_spend_proof(const string& txId, const string& message) const { + MTRACE("monero_wallet::get_spend_proof()"); // validate and parse tx id crypto::hash txHash; @@ -2234,8 +2234,8 @@ namespace monero { return wallet2->get_spend_proof(txHash, message); } - bool MoneroWallet::checkSpendProof(const string& txId, const string& message, const string& signature) const { - MTRACE("MoneroWallet::checkSpendProof()"); + bool monero_wallet::check_spend_proof(const string& txId, const string& message, const string& signature) const { + MTRACE("monero_wallet::check_spend_proof()"); // validate and parse tx id crypto::hash txHash; @@ -2247,22 +2247,22 @@ namespace monero { return wallet2->check_spend_proof(txHash, message, signature); } - string MoneroWallet::getReserveProofWallet(const string& message) const { - MTRACE("MoneroWallet::getReserveProofWallet()"); + string monero_wallet::get_reserve_proof_wallet(const string& message) const { + MTRACE("monero_wallet::get_reserve_proof_wallet()"); boost::optional> account_minreserve; return wallet2->get_reserve_proof(account_minreserve, message); } - string MoneroWallet::getReserveProofAccount(uint32_t accountIdx, uint64_t amount, const string& message) const { - MTRACE("MoneroWallet::getReserveProofAccount()"); + string monero_wallet::get_reserve_proof_account(uint32_t accountIdx, uint64_t amount, const string& message) const { + MTRACE("monero_wallet::get_reserve_proof_account()"); boost::optional> account_minreserve; if (accountIdx >= wallet2->get_num_subaddress_accounts()) throw runtime_error("Account index is out of bound"); account_minreserve = std::make_pair(accountIdx, amount); return wallet2->get_reserve_proof(account_minreserve, message); } - shared_ptr MoneroWallet::checkReserveProof(const string& address, const string& message, const string& signature) const { - MTRACE("MoneroWallet::checkReserveProof()"); + shared_ptr monero_wallet::check_reserve_proof(const string& address, const string& message, const string& signature) const { + MTRACE("monero_wallet::check_reserve_proof()"); // validate and parse input cryptonote::address_parse_info info; @@ -2270,7 +2270,7 @@ namespace monero { if (info.is_subaddress) throw runtime_error("Address must not be a subaddress"); // initialize check reserve using wallet2 - shared_ptr checkReserve = make_shared(); + shared_ptr checkReserve = make_shared(); uint64_t totalAmount; uint64_t unconfirmedSpentAmount; checkReserve->isGood = wallet2->check_reserve_proof(info.address, message, signature, totalAmount, unconfirmedSpentAmount); @@ -2281,8 +2281,8 @@ namespace monero { return checkReserve; } - string MoneroWallet::createPaymentUri(const MoneroSendRequest& request) const { - MTRACE("createPaymentUri()"); + string monero_wallet::create_payment_uri(const monero_send_request& request) const { + MTRACE("create_payment_uri()"); // validate request if (request.destinations.size() != 1) throw runtime_error("Cannot make URI from supplied parameters: must provide exactly one destination to send funds"); @@ -2303,8 +2303,8 @@ namespace monero { return uri; } - shared_ptr MoneroWallet::parsePaymentUri(const string& uri) const { - MTRACE("parsePaymentUri(" << uri << ")"); + shared_ptr monero_wallet::parse_payment_uri(const string& uri) const { + MTRACE("parse_payment_uri(" << uri << ")"); // decode uri to parameters string address; @@ -2319,28 +2319,28 @@ namespace monero { } // initialize send request - shared_ptr sendRequest = make_shared(); - shared_ptr destination = make_shared(); + shared_ptr sendRequest = make_shared(); + shared_ptr destination = make_shared(); sendRequest->destinations.push_back(destination); if (!address.empty()) destination->address = address; destination->amount = amount; if (!paymentId.empty()) sendRequest->paymentId = paymentId; if (!note.empty()) sendRequest->note = note; if (!recipientName.empty()) sendRequest->recipientName = recipientName; - if (!unknownParameters.empty()) MWARNING("WARNING in MoneroWallet::parsePaymentUri: URI contains unknown parameters which are discarded"); // TODO: return unknown parameters? + if (!unknownParameters.empty()) MWARNING("WARNING in monero_wallet::parse_payment_uri: URI contains unknown parameters which are discarded"); // TODO: return unknown parameters? return sendRequest; } - void MoneroWallet::setAttribute(const string& key, const string& val) { + void monero_wallet::set_attribute(const string& key, const string& val) { wallet2->set_attribute(key, val); } - string MoneroWallet::getAttribute(const string& key) const { + string monero_wallet::get_attribute(const string& key) const { return wallet2->get_attribute(key); } - void MoneroWallet::startMining(boost::optional numThreads, boost::optional backgroundMining, boost::optional ignoreBattery) { - MTRACE("startMining()"); + void monero_wallet::start_mining(boost::optional numThreads, boost::optional backgroundMining, boost::optional ignoreBattery) { + MTRACE("start_mining()"); // only mine on trusted daemon if (!wallet2->is_trusted_daemon()) throw runtime_error("This command requires a trusted daemon."); @@ -2369,8 +2369,8 @@ namespace monero { } } - void MoneroWallet::stopMining() { - MTRACE("stopMining()"); + void monero_wallet::stop_mining() { + MTRACE("stop_mining()"); cryptonote::COMMAND_RPC_STOP_MINING::request daemon_req; cryptonote::COMMAND_RPC_STOP_MINING::response daemon_res; bool r = wallet2->invoke_http_json("/stop_mining", daemon_req, daemon_res); @@ -2379,17 +2379,17 @@ namespace monero { } } - void MoneroWallet::save() { + void monero_wallet::save() { MTRACE("save()"); wallet2->store(); } - void MoneroWallet::moveTo(string path, string password) { - MTRACE("moveTo(" << path << ", " << password << ")"); + void monero_wallet::move_to(string path, string password) { + MTRACE("move_to(" << path << ", " << password << ")"); wallet2->store_to(path, password); } - void MoneroWallet::close() { + void monero_wallet::close() { MTRACE("close()"); syncingEnabled = false; syncingThreadDone = true; @@ -2401,10 +2401,10 @@ namespace monero { // ------------------------------- PRIVATE HELPERS ---------------------------- - void MoneroWallet::initCommon() { - MTRACE("MoneroWallet.cpp initCommon()"); + void monero_wallet::initCommon() { + MTRACE("monero_wallet.cpp initCommon()"); wallet2Listener = unique_ptr(new Wallet2Listener(*this, *wallet2)); - if (getDaemonConnection() == nullptr) isConnected = false; + if (get_daemon_connection() == nullptr) isConnected = false; isSynced = false; rescanOnSync = false; syncingEnabled = false; @@ -2417,7 +2417,7 @@ namespace monero { }); } - void MoneroWallet::syncingThreadFunc() { + void monero_wallet::syncingThreadFunc() { MTRACE("syncingThreadFunc()"); while (true) { boost::mutex::scoped_lock lock(syncingMutex); @@ -2434,15 +2434,15 @@ namespace monero { } } - MoneroSyncResult MoneroWallet::lockAndSync(boost::optional startHeight, boost::optional listener) { + monero_sync_result monero_wallet::lockAndSync(boost::optional startHeight, boost::optional listener) { bool rescan = rescanOnSync.exchange(false); boost::lock_guard guarg(syncMutex); // synchronize sync() and syncAsync() - MoneroSyncResult result; + monero_sync_result result; result.numBlocksFetched = 0; result.receivedMoney = false; do { // skip if daemon is not connected or synced - if (isConnected && getIsDaemonSynced()) { + if (isConnected && get_is_daemon_synced()) { // rescan blockchain if requested if (rescan) wallet2->rescan_blockchain(false); @@ -2457,16 +2457,16 @@ namespace monero { return result; } - MoneroSyncResult MoneroWallet::syncAux(boost::optional startHeight, boost::optional listener) { + monero_sync_result monero_wallet::syncAux(boost::optional startHeight, boost::optional listener) { MTRACE("syncAux()"); // determine sync start height - uint64_t syncStartHeight = startHeight == boost::none ? max(getHeight(), getRestoreHeight()) : *startHeight; - if (syncStartHeight < getRestoreHeight()) setRestoreHeight(syncStartHeight); // TODO monero core: start height processed > requested start height unless restore height manually set + uint64_t syncStartHeight = startHeight == boost::none ? max(get_height(), get_restore_height()) : *startHeight; + if (syncStartHeight < get_restore_height()) set_restore_height(syncStartHeight); // TODO monero core: start height processed > requested start height unless restore height manually set // sync wallet and return result wallet2Listener->onSyncStart(syncStartHeight, listener); - MoneroSyncResult result; + monero_sync_result result; wallet2->refresh(wallet2->is_trusted_daemon(), syncStartHeight, result.numBlocksFetched, result.receivedMoney, true); if (!isSynced) isSynced = true; wallet2Listener->onSyncEnd(); @@ -2474,8 +2474,8 @@ namespace monero { } // private helper to initialize subaddresses using transfer details - vector MoneroWallet::getSubaddressesAux(const uint32_t accountIdx, const vector& subaddressIndices, const vector& transfers) const { - vector subaddresses; + vector monero_wallet::getSubaddressesAux(const uint32_t accountIdx, const vector& subaddressIndices, const vector& transfers) const { + vector subaddresses; // get balances per subaddress as maps map balancePerSubaddress = wallet2->balance_per_subaddress(accountIdx); @@ -2493,11 +2493,11 @@ namespace monero { // initialize subaddresses at indices for (uint32_t subaddressIndicesIdx = 0; subaddressIndicesIdx < subaddressIndicesReq.size(); subaddressIndicesIdx++) { - MoneroSubaddress subaddress; + monero_subaddress subaddress; subaddress.accountIndex = accountIdx; uint32_t subaddressIdx = subaddressIndicesReq.at(subaddressIndicesIdx); subaddress.index = subaddressIdx; - subaddress.address = getAddress(accountIdx, subaddressIdx); + subaddress.address = get_address(accountIdx, subaddressIdx); subaddress.label = wallet2->get_subaddress_label({accountIdx, subaddressIdx}); auto iter1 = balancePerSubaddress.find(subaddressIdx); subaddress.balance = iter1 == balancePerSubaddress.end() ? 0 : iter1->second; diff --git a/src/wallet/MoneroWallet.h b/src/wallet/monero_wallet.h similarity index 78% rename from src/wallet/MoneroWallet.h rename to src/wallet/monero_wallet.h index aff5e63..4dc0f77 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/monero_wallet.h @@ -52,7 +52,7 @@ #pragma once -#include "MoneroWalletModel.h" +#include "monero_wallet_model.h" #include "wallet/wallet2.h" #include @@ -100,7 +100,7 @@ namespace monero { /** * Receives progress notifications as a wallet is synchronized. */ - class MoneroSyncListener { + class monero_sync_listener { public: /** @@ -112,13 +112,13 @@ namespace monero { * @param percentDone is the sync progress as a percentage * @param message is a human-readable description of the current progress */ - virtual void onSyncProgress(uint64_t height, uint64_t startHeight, uint64_t endHeight, double percentDone, const string& message) {} + virtual void on_sync_progress(uint64_t height, uint64_t startHeight, uint64_t endHeight, double percentDone, const string& message) {} }; /** * Receives notifications as a wallet is updated. */ - class MoneroWalletListener : public MoneroSyncListener { + class MoneroWalletListener : public monero_sync_listener { public: /** @@ -126,21 +126,21 @@ namespace monero { * * @param block is the newly processed block */ - virtual void onNewBlock(uint64_t height) {}; + virtual void on_new_block(uint64_t height) {}; /** * Invoked when the wallet receives an output. * * @param output is the incoming output to the wallet */ - virtual void onOutputReceived(const MoneroOutputWallet& output) {}; + virtual void on_output_received(const monero_output_wallet& output) {}; /** * Invoked when the wallet spends an output. * * @param output the outgoing transfer from the wallet */ - virtual void onOutputSpent(const MoneroOutputWallet& output) {}; + virtual void on_output_spent(const monero_output_wallet& output) {}; }; // forward declaration of internal wallet2 listener @@ -151,7 +151,7 @@ namespace monero { /** * Monero wallet interface. */ - class MoneroWallet { + class monero_wallet { public: @@ -170,7 +170,7 @@ namespace monero { * @param password is the password of the wallet file to open * @param networkType is the wallet's network type */ - static MoneroWallet* openWallet(const string& path, const string& password, const MoneroNetworkType networkType); + static monero_wallet* open_wallet(const string& path, const string& password, const MoneroNetworkType networkType); /** * Create a new wallet with a randomly generated seed. @@ -181,8 +181,8 @@ namespace monero { * @param daemonConnection is connection information to a daemon (default = an unconnected wallet) * @param language is the wallet and mnemonic's language (default = "English") */ - static MoneroWallet* createWalletRandom(const string& path, const string& password); - static MoneroWallet* createWalletRandom(const string& path, const string& password, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language); + static monero_wallet* create_wallet_random(const string& path, const string& password); + static monero_wallet* create_wallet_random(const string& path, const string& password, const MoneroNetworkType networkType, const monero_rpc_connection& daemonConnection, const string& language); /** * Create a wallet from an existing mnemonic phrase. @@ -194,8 +194,8 @@ namespace monero { * @param daemonConnection is connection information to a daemon (default = an unconnected wallet) * @param restoreHeight is the block height to restore (i.e. scan the chain) from (default = 0) */ - static MoneroWallet* createWalletFromMnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic); - static MoneroWallet* createWalletFromMnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight); + static monero_wallet* create_wallet_from_mnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic); + static monero_wallet* create_wallet_from_mnemonic(const string& path, const string& password, const MoneroNetworkType networkType, const string& mnemonic, const monero_rpc_connection& daemonConnection, uint64_t restoreHeight); /** * Create a wallet from an address, view key, and spend key. @@ -210,14 +210,14 @@ namespace monero { * @param restoreHeight is the block height to restore (i.e. scan the chain) from (default = 0) * @param language is the wallet and mnemonic's language (default = "English") */ - static MoneroWallet* createWalletFromKeys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey); - static MoneroWallet* createWalletFromKeys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight); - static MoneroWallet* createWalletFromKeys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight, const string& language); + static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey); + static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const monero_rpc_connection& daemonConnection, uint64_t restoreHeight); + static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const MoneroNetworkType networkType, const string& address, const string& viewKey, const string& spendKey, const monero_rpc_connection& daemonConnection, uint64_t restoreHeight, const string& language); /** * Deconstruct the wallet. */ - ~MoneroWallet(); + ~monero_wallet(); /** * Set the wallet's daemon connection. @@ -226,133 +226,133 @@ namespace monero { * @param username is the username to authenticate with the daemon (optional) * @param password is the password to authenticate with the daemon (optional) */ - void setDaemonConnection(const string& uri, const string& username = "", const string& password = ""); + void set_daemon_connection(const string& uri, const string& username = "", const string& password = ""); /** * Set the wallet's daemon connection. * * @param connection is the connection to set */ - void setDaemonConnection(const MoneroRpcConnection& connection); + void set_daemon_connection(const monero_rpc_connection& connection); /** * Get the wallet's daemon connection. * * @return the wallet's daemon connection */ - shared_ptr getDaemonConnection() const; + shared_ptr get_daemon_connection() const; /** * Indicates if the wallet is connected a daemon. * * @return true if the wallet is connected to a daemon, false otherwise */ - bool getIsConnected() const; + bool get_is_connected() const; /** * Get the height that the wallet's daemon is synced to. * * @return the height that the wallet's daemon is synced to */ - uint64_t getDaemonHeight() const; + uint64_t get_daemon_height() const; /** * Get the height of the next block in the chain. * * @return the height of the next block in the chain */ - uint64_t getDaemonTargetHeight() const; + uint64_t get_daemon_target_height() const; /** * Indicates if the wallet's daemon is synced with the network. * * @return true if the daemon is synced with the network, false otherwise */ - bool getIsDaemonSynced() const; + bool get_is_daemon_synced() const; /** * Indicates if the wallet is synced with the daemon. * * @return true if the wallet is synced with the daemon, false otherwise */ - bool getIsSynced() const; + bool get_is_synced() const; /** * Get the path of this wallet's file on disk. * * @return the path of this wallet's file on disk */ - string getPath() const; + string get_path() const; /** * Get the wallet's network type (mainnet, testnet, or stagenet). * * @return the wallet's network type */ - MoneroNetworkType getNetworkType() const; + MoneroNetworkType get_network_type() const; /** * Get the wallet's seed. * * @return the wallet's seed */ - string getSeed() const; + string get_seed() const; /** * Get the wallet's mnemonic phrase derived from the seed. * * @param mnemonic is assigned the wallet's mnemonic phrase */ - string getMnemonic() const; + string get_mnemonic() const; /** * Get the language of the wallet's mnemonic phrase. * * @return the language of the wallet's mnemonic phrase */ - string getLanguage() const; + string get_language() const; /** * Get a list of available languages for the wallet's mnemonic phrase. * * @return the available languages for the wallet's mnemonic phrase */ - vector getLanguages() const; + vector get_languages() const; /** * Get the wallet's public view key. * * @return the wallet's public view key */ - string getPublicViewKey() const; + string get_public_view_key() const; /** * Get the wallet's private view key. * * @return the wallet's private view key */ - string getPrivateViewKey() const; + string get_private_view_key() const; /** * Get the wallet's public spend key. * * @return the wallet's public spend key */ - string getPublicSpendKey() const; + string get_public_spend_key() const; /** * Get the wallet's private spend key. * * @return the wallet's private spend key */ - string getPrivateSpendKey() const; + string get_private_spend_key() const; /** * Get the wallet's primary address. * * @return the wallet's primary address */ - string getPrimaryAddress() const; + string get_primary_address() const; /** * Get the address of a specific subaddress. @@ -361,7 +361,7 @@ namespace monero { * @param subaddressIdx specifies the subaddress index within the account * @return the receive address of the specified subaddress */ - string getAddress(const uint32_t accountIdx, const uint32_t subaddressIdx) const; + string get_address(const uint32_t accountIdx, const uint32_t subaddressIdx) const; /** * Get the account and subaddress index of the given address. @@ -370,7 +370,7 @@ namespace monero { * @return the account and subaddress indices * @throws exception if address is not a wallet address */ - MoneroSubaddress getAddressIndex(const string& address) const; + monero_subaddress get_address_index(const string& address) const; /** * Get an integrated address from a standard address and a payment id. @@ -379,7 +379,7 @@ namespace monero { * @param paymentId is the integrated addresse's payment id (defaults to randomly generating new payment id) * @return the integrated address */ - MoneroIntegratedAddress getIntegratedAddress(const string& standardAddress = "", const string& paymentId = "") const; + monero_integrated_address get_integrated_address(const string& standardAddress = "", const string& paymentId = "") const; /** * Decode an integrated address to get its standard address and payment id. @@ -387,21 +387,21 @@ namespace monero { * @param integratedAddress is an integrated address to decode * @return the decoded integrated address including standard address and payment id */ - MoneroIntegratedAddress decodeIntegratedAddress(const string& integratedAddress) const; + monero_integrated_address decode_integrated_address(const string& integratedAddress) const; /** * Set the wallet's listener to receive wallet notifications. * * @param listener is the listener to receive wallet notifications */ - void setListener(boost::optional listener); + void set_listener(boost::optional listener); /** * Synchronize the wallet with the daemon as a one-time synchronous process. * * @return the sync result */ - MoneroSyncResult sync(); + monero_sync_result sync(); /** * Synchronize the wallet with the daemon as a one-time synchronous process. @@ -409,7 +409,7 @@ namespace monero { * @param listener is invoked as sync progress is made * @return the sync result */ - MoneroSyncResult sync(MoneroSyncListener& listener); + monero_sync_result sync(monero_sync_listener& listener); /** * Synchronize the wallet with the daemon as a one-time synchronous process. @@ -417,7 +417,7 @@ namespace monero { * @param startHeight is the start height to sync from (ignored if less than last processed block) * @return the sync result */ - MoneroSyncResult sync(uint64_t startHeight); + monero_sync_result sync(uint64_t startHeight); /** * Synchronizes the wallet with the blockchain. @@ -426,17 +426,17 @@ namespace monero { * @param listener is invoked as sync progress is made * @return the sync result */ - MoneroSyncResult sync(uint64_t startHeight, MoneroSyncListener& listener); + monero_sync_result sync(uint64_t startHeight, monero_sync_listener& listener); /** * Start an asynchronous thread to continuously synchronize the wallet with the daemon. */ - void startSyncing(); + void start_syncing(); /** * Stop the asynchronous thread to continuously synchronize the wallet with the daemon. */ - void stopSyncing(); + void stop_syncing(); /** * Rescan the blockchain from scratch, losing any information which cannot be recovered from @@ -445,14 +445,14 @@ namespace monero { * WARNING: This method discards local wallet data like destination addresses, tx secret keys, * tx notes, etc. */ - void rescanBlockchain(); + void rescan_blockchain(); /** * Get the height of the last block processed by the wallet (its index + 1). * * @return the height of the last block processed by the wallet */ - uint64_t getHeight() const; + uint64_t get_height() const; /** * Get the blockchain's height. @@ -466,14 +466,14 @@ namespace monero { * * @return the height of the first block that the wallet scans */ - uint64_t getRestoreHeight() const; + uint64_t get_restore_height() const; /** * Set the height of the first block that the wallet scans. * * @param restoreHeight is the height of the first block that the wallet scans */ - void setRestoreHeight(uint64_t restoreHeight); + void set_restore_height(uint64_t restoreHeight); // /** // * Indicates if importing multisig data is needed for returning a correct balance. @@ -487,7 +487,7 @@ namespace monero { * * @return the wallet's balance */ - uint64_t getBalance() const; + uint64_t get_balance() const; /** * Get an account's balance. @@ -495,7 +495,7 @@ namespace monero { * @param accountIdx is the index of the account to get the balance of * @return the account's balance */ - uint64_t getBalance(uint32_t accountIdx) const; + uint64_t get_balance(uint32_t accountIdx) const; /** * Get a subaddress's balance. @@ -504,14 +504,14 @@ namespace monero { * @param subaddressIdx is the index of the subaddress to get the balance of * @return the subaddress's balance */ - uint64_t getBalance(uint32_t accountIdx, uint32_t subaddressIdx) const; + uint64_t get_balance(uint32_t accountIdx, uint32_t subaddressIdx) const; /** * Get the wallet's unlocked balance. * * @return the wallet's unlocked balance */ - uint64_t getUnlockedBalance() const; + uint64_t get_unlocked_balance() const; /** * Get an account's unlocked balance. @@ -519,7 +519,7 @@ namespace monero { * @param accountIdx is the index of the account to get the unlocked balance of * @return the account's unlocked balance */ - uint64_t getUnlockedBalance(uint32_t accountIdx) const; + uint64_t get_unlocked_balance(uint32_t accountIdx) const; /** * Get a subaddress's unlocked balance. @@ -528,39 +528,39 @@ namespace monero { * @param subaddressIdx is the index of the subaddress to get the unlocked balance of * @return the subaddress's balance */ - uint64_t getUnlockedBalance(uint32_t accountIdx, uint32_t subaddressIdx) const; + uint64_t get_unlocked_balance(uint32_t accountIdx, uint32_t subaddressIdx) const; /** * Get all accounts. * - * @return List are all accounts within the wallet + * @return List are all accounts within the wallet */ - vector getAccounts() const; + vector get_accounts() const; /** * Get all accounts. * * @param includeSubaddresses specifies if subaddresses should be included - * @return List are all accounts + * @return List are all accounts */ - vector getAccounts(bool includeSubaddresses) const; + vector get_accounts(bool includeSubaddresses) const; /** * Get accounts with a given tag. * * @param tag is the tag for filtering accounts, all accounts if null - * @return List are all accounts for the wallet with the given tag + * @return List are all accounts for the wallet with the given tag */ - vector getAccounts(const string& tag) const; + vector get_accounts(const string& tag) const; /** * Get accounts with a given tag. * * @param includeSubaddresses specifies if subaddresses should be included * @param tag is the tag for filtering accounts, all accounts if null - * @return List are all accounts for the wallet with the given tag + * @return List are all accounts for the wallet with the given tag */ - vector getAccounts(bool includeSubaddresses, const string& tag) const; + vector get_accounts(bool includeSubaddresses, const string& tag) const; /** * Get an account without subaddress information. @@ -568,7 +568,7 @@ namespace monero { * @param accountIdx specifies the account to get * @return the retrieved account */ - MoneroAccount getAccount(uint32_t accountIdx) const; + monero_account get_account(uint32_t accountIdx) const; /** * Get an account. @@ -577,7 +577,7 @@ namespace monero { * @param includeSubaddresses specifies if subaddresses should be included * @return the retrieved account */ - MoneroAccount getAccount(const uint32_t accountIdx, bool includeSubaddresses) const; + monero_account get_account(const uint32_t accountIdx, bool includeSubaddresses) const; /** * Create a new account with a label for the first subaddress. @@ -585,15 +585,15 @@ namespace monero { * @param label specifies the label for the account's first subaddress (optional) * @return the created account */ - MoneroAccount createAccount(const string& label = ""); + monero_account create_account(const string& label = ""); /** * Get all subaddresses in an account. * * @param accountIdx specifies the account to get subaddresses within - * @return List are the retrieved subaddresses + * @return List are the retrieved subaddresses */ - vector getSubaddresses(const uint32_t accountIdx) const; + vector get_subaddresses(const uint32_t accountIdx) const; /** * Get subaddresses in an account. @@ -602,7 +602,7 @@ namespace monero { * @param subaddressIndices are specific subaddresses to get (optional) * @return the retrieved subaddresses */ - vector getSubaddresses(const uint32_t accountIdx, const vector& subaddressIndices) const; + vector get_subaddresses(const uint32_t accountIdx, const vector& subaddressIndices) const; /** * Get a subaddress. @@ -611,7 +611,7 @@ namespace monero { * @param subaddressIdx specifies index of the subaddress within the account * @return the retrieved subaddress */ - MoneroSubaddress getSubaddress(const uint32_t accountIdx, const uint32_t subaddressIdx) const; + monero_subaddress getSubaddress(const uint32_t accountIdx, const uint32_t subaddressIdx) const; /** * Create a subaddress within an account. @@ -620,15 +620,15 @@ namespace monero { * @param label specifies the the label for the subaddress (defaults to empty string) * @return the created subaddress */ - MoneroSubaddress createSubaddress(uint32_t accountIdx, const string& label = ""); + monero_subaddress create_subaddress(uint32_t accountIdx, const string& label = ""); // /** // * Get a wallet transaction by id. // * // * @param txId is an id of a transaction to get -// * @return MoneroTxWallet is the identified transactions +// * @return monero_tx_wallet is the identified transactions // */ -// public MoneroTxWallet getTx(string txId); +// public monero_tx_wallet getTx(string txId); /** * Get all wallet transactions. Wallet transactions contain one or more @@ -636,7 +636,7 @@ namespace monero { * * @return all wallet transactions */ - vector> getTxs() const; + vector> get_txs() const; // /** // * Get wallet transactions by id. @@ -644,7 +644,7 @@ namespace monero { // * @param txIds are ids of transactions to get // * @return the identified transactions // */ -// public List getTxs(Collection txIds); +// public List get_txs(Collection txIds); /** * Get wallet transactions. Wallet transactions contain one or more @@ -658,7 +658,7 @@ namespace monero { * @param request filters query results (optional) * @return wallet transactions per the request */ - vector> getTxs(const MoneroTxRequest& request) const; + vector> get_txs(const monero_tx_request& request) const; // /** // * Get all incoming and outgoing transfers to and from this wallet. An @@ -670,7 +670,7 @@ namespace monero { // * // * @return all wallet transfers // */ -// public List getTransfers(); +// public List get_transfers(); // // /** // * Get incoming and outgoing transfers to and from an account. An outgoing @@ -683,7 +683,7 @@ namespace monero { // * @param accountIdx is the index of the account to get transfers from // * @return transfers to/from the account // */ -// public List getTransfers(int accountIdx); +// public List get_transfers(int accountIdx); // // /** // * Get incoming and outgoing transfers to and from a subaddress. An outgoing @@ -697,7 +697,7 @@ namespace monero { // * @param subaddressIdx is the index of the subaddress to get transfers from // * @return transfers to/from the subaddress // */ -// public List getTransfers(int accountIdx, int subaddressIdx); +// public List get_transfers(int accountIdx, int subaddressIdx); /** * Get incoming and outgoing transfers to and from this wallet. An outgoing @@ -707,7 +707,7 @@ namespace monero { * a subaddress within an account. Transfers belong to transactions which * are stored on the blockchain. * - * Query results can be filtered by passing in a MoneroTransferRequest. + * Query results can be filtered by passing in a monero_transfer_request. * Transfers must meet every criteria defined in the request in order to be * returned. All filtering is optional and no filtering is applied when not * defined. @@ -715,37 +715,37 @@ namespace monero { * @param request filters query results (optional) * @return wallet transfers per the request */ - vector> getTransfers(const MoneroTransferRequest& request) const; + vector> get_transfers(const monero_transfer_request& request) const; // /** // * Get outputs created from previous transactions that belong to the wallet // * (i.e. that the wallet can spend one time). Outputs are part of // * transactions which are stored in blocks on the blockchain. // * -// * @return List are all wallet outputs +// * @return List are all wallet outputs // */ -// public List getOutputs(); +// public List get_outputs(); /** * Get outputs created from previous transactions that belong to the wallet * (i.e. that the wallet can spend one time). Outputs are part of * transactions which are stored in blocks on the blockchain. * - * Results can be configured by passing a MoneroOutputRequest. Outputs must + * Results can be configured by passing a monero_output_request. Outputs must * meet every criteria defined in the request in order to be returned. All * filtering is optional and no filtering is applied when not defined. * * @param request specifies request options (optional) - * @return List are wallet outputs per the request + * @return List are wallet outputs per the request */ - vector> getOutputs(const MoneroOutputRequest& request) const; + vector> get_outputs(const monero_output_request& request) const; /** * Export all outputs in hex format. * * @return all outputs in hex format, empty string if no outputs */ - string getOutputsHex() const; + string get_outputs_hex() const; /** * Import outputs in hex format. @@ -753,14 +753,14 @@ namespace monero { * @param outputsHex are outputs in hex format * @return the number of outputs imported */ - int importOutputsHex(const string& outputsHex); + int import_outputs_hex(const string& outputsHex); /** * Get all signed key images. * * @return the wallet's signed key images */ - vector> getKeyImages() const; + vector> get_key_images() const; /** * Import signed key images and verify their spent status. @@ -768,14 +768,14 @@ namespace monero { * @param keyImages are key images to import and verify (requires hex and signature) * @return results of the import */ - shared_ptr importKeyImages(const vector>& keyImages); + shared_ptr import_key_images(const vector>& keyImages); // /** // * Get new key images from the last imported outputs. // * // * @return the key images from the last imported outputs // */ -// public List getNewKeyImagesFromLastImport(); +// public List getNewKeyImagesFromLastImport(); /** * Create one or more transactions which transfer funds from this wallet to @@ -784,7 +784,7 @@ namespace monero { * @param request configures the transaction * @return the resulting transaction */ - vector> sendSplit(const MoneroSendRequest& request); + vector> send_split(const monero_send_request& request); // // /** @@ -796,7 +796,7 @@ namespace monero { // * @param sendAmount is the amount being sent // * @return the resulting transaction // */ -// public MoneroTxWallet send(int accountIndex, string address, BigInteger sendAmount); +// public monero_tx_wallet send(int accountIndex, string address, BigInteger sendAmount); // // /** // * Create and relay a transaction which transfers funds from this wallet to @@ -808,7 +808,7 @@ namespace monero { // * @param priority is the send priority (default normal) // * @return the resulting transaction // */ -// public MoneroTxWallet send(int accountIndex, string address, BigInteger sendAmount, MoneroSendPriority priority); +// public monero_tx_wallet send(int accountIndex, string address, BigInteger sendAmount, monero_send_priority priority); // // /** // * Create and relay (depending on configuration) one or more transactions @@ -817,7 +817,7 @@ namespace monero { // * @param request configures the transactions // * @return the resulting transactions // */ -// public List sendSplit(MoneroSendRequest request); +// public List send_split(monero_send_request request); // // /** // * Create and relay one or more transactions which transfer funds from this @@ -828,7 +828,7 @@ namespace monero { // * @param sendAmount is the amount being sent // * @return the resulting transactions // */ -// public List sendSplit(int accountIndex, string address, BigInteger sendAmount); +// public List send_split(int accountIndex, string address, BigInteger sendAmount); // // /** // * Create and relay one or more transactions which transfer funds from this @@ -840,7 +840,7 @@ namespace monero { // * @param priority is the send priority (default normal) // * @return the resulting transactions // */ -// public List sendSplit(int accountIndex, string address, BigInteger sendAmount, MoneroSendPriority priority); +// public List send_split(int accountIndex, string address, BigInteger sendAmount, monero_send_priority priority); /** * Sweep an output with a given key image. @@ -848,7 +848,7 @@ namespace monero { * @param request configures the sweep transaction * @return the resulting transaction from sweeping an output */ - shared_ptr sweepOutput(const MoneroSendRequest& request) const; + shared_ptr sweep_output(const monero_send_request& request) const; // /** // * Sweep an output with a given key image. @@ -857,7 +857,7 @@ namespace monero { // * @param keyImage is the key image hex of the output to sweep // * @return the resulting transaction from sweeping an output // */ -// public MoneroTxWallet sweepOutput(string address, string keyImage); +// public monero_tx_wallet sweep_output(string address, string keyImage); // // /** // * Sweep an output with a given key image. @@ -867,7 +867,7 @@ namespace monero { // * @param priority is the transaction priority (optional) // * @return the resulting transaction from sweeping an output // */ -// public MoneroTxWallet sweepOutput(string address, string keyImage, MoneroSendPriority priority); +// public monero_tx_wallet sweep_output(string address, string keyImage, monero_send_priority priority); // // /** // * Sweep a subaddress's unlocked funds to an address. @@ -877,7 +877,7 @@ namespace monero { // * @param address is the address to sweep the subaddress's funds to // * @return the resulting transactions // */ -// public List sweepSubaddress(int accountIdx, int subaddressIdx, string address); +// public List sweepSubaddress(int accountIdx, int subaddressIdx, string address); // // /** // * Sweep an acount's unlocked funds to an address. @@ -886,7 +886,7 @@ namespace monero { // * @param address is the address to sweep the account's funds to // * @return the resulting transactions // */ -// public List sweepAccount(int accountIdx, string address); +// public List sweepAccount(int accountIdx, string address); // // /** // * Sweep the wallet's unlocked funds to an address. @@ -894,7 +894,7 @@ namespace monero { // * @param address is the address to sweep the wallet's funds to // * @return the resulting transactions // */ -// public List sweepWallet(string address); +// public List sweepWallet(string address); // // /** // * Sweep all unlocked funds according to the given request. @@ -902,7 +902,7 @@ namespace monero { // * @param request is the sweep configuration // * @return the resulting transactions // */ -// public List sweepAllUnlocked(MoneroSendRequest request); +// public List sweepAllUnlocked(monero_send_request request); // // /** // * Sweep all unmixable dust outputs back to the wallet to make them easier to spend and mix. @@ -911,7 +911,7 @@ namespace monero { // * // * @return the resulting transactions from sweeping dust // */ -// public List sweepDust(); +// public List sweep_dust(); /** * Sweep all unmixable dust outputs back to the wallet to make them easier to spend and mix. @@ -919,7 +919,7 @@ namespace monero { * @param doNotRelay specifies if the resulting transaction should not be relayed (defaults to false i.e. relayed) * @return the resulting transactions from sweeping dust */ - vector> sweepDust(bool doNotRelay = false); + vector> sweep_dust(bool doNotRelay = false); // // /** // * Relay a transaction previously created without relaying. @@ -935,7 +935,7 @@ namespace monero { * @param txMetadatas are transaction metadata previously created without relaying * @return the ids of the relayed txs */ - vector relayTxs(const vector& txMetadatas); + vector relay_txs(const vector& txMetadatas); /** * Get a transaction note. @@ -943,7 +943,7 @@ namespace monero { * @param txId specifies the transaction to get the note of * @return the tx note */ - string getTxNote(const string& txId) const; + string get_tx_note(const string& txId) const; /** * Get notes for multiple transactions. @@ -951,7 +951,7 @@ namespace monero { * @param txIds identify the transactions to get notes for * @preturns notes for the transactions */ - vector getTxNotes(const vector& txIds) const; + vector get_tx_notes(const vector& txIds) const; /** * Set a note for a specific transaction. @@ -959,7 +959,7 @@ namespace monero { * @param txId specifies the transaction * @param note specifies the note */ - void setTxNote(const string& txId, const string& note); + void set_tx_note(const string& txId, const string& note); /** * Set notes for multiple transactions. @@ -967,7 +967,7 @@ namespace monero { * @param txIds specify the transactions to set notes for * @param notes are the notes to set for the transactions */ - void setTxNotes(const vector& txIds, const vector& notes); + void set_tx_notes(const vector& txIds, const vector& notes); /** * Sign a message. @@ -993,7 +993,7 @@ namespace monero { * @param txId is the transaction's id * @return is the transaction's secret key */ - string getTxKey(const string& txId) const; + string get_tx_key(const string& txId) const; /** * Check a transaction in the blockchain with its secret key. @@ -1003,7 +1003,7 @@ namespace monero { * @param address is the destination public address of the transaction * @return the result of the check */ - shared_ptr checkTxKey(const string& txId, const string& txKey, const string& address) const; + shared_ptr check_tx_key(const string& txId, const string& txKey, const string& address) const; // /** // * Get a transaction signature to prove it. @@ -1012,7 +1012,7 @@ namespace monero { // * @param address is the destination public address of the transaction // * @return the transaction signature // */ -// string getTxProof(const string& txId, const string& address) const; +// string get_tx_proof(const string& txId, const string& address) const; /** * Get a transaction signature to prove it. @@ -1022,7 +1022,7 @@ namespace monero { * @param message is a message to include with the signature to further authenticate the proof (optional) * @return the transaction signature */ - string getTxProof(const string& txId, const string& address, const string& message) const; + string get_tx_proof(const string& txId, const string& address, const string& message) const; /** * Prove a transaction by checking its signature. @@ -1033,7 +1033,7 @@ namespace monero { * @param signature is the transaction signature to confirm * @return the result of the check */ - shared_ptr checkTxProof(const string& txId, const string& address, const string& message, const string& signature) const; + shared_ptr check_tx_proof(const string& txId, const string& address, const string& message, const string& signature) const; // /** // * Generate a signature to prove a spend. Unlike proving a transaction, it does not require the destination public address. @@ -1041,7 +1041,7 @@ namespace monero { // * @param txId specifies the transaction to prove // * @return the transaction signature // */ -// string getSpendProof(const string& txId) const; +// string get_spend_proof(const string& txId) const; /** * Generate a signature to prove a spend. Unlike proving a transaction, it does not require the destination public address. @@ -1050,7 +1050,7 @@ namespace monero { * @param message is a message to include with the signature to further authenticate the proof (optional) * @return the transaction signature */ - string getSpendProof(const string& txId, const string& message) const; + string get_spend_proof(const string& txId, const string& message) const; /** * Prove a spend using a signature. Unlike proving a transaction, it does not require the destination public address. @@ -1060,7 +1060,7 @@ namespace monero { * @param signature is the transaction signature to confirm * @return true if the signature is good, false otherwise */ - bool checkSpendProof(const string& txId, const string& message, const string& signature) const; + bool check_spend_proof(const string& txId, const string& message, const string& signature) const; /** * Generate a signature to prove the entire balance of the wallet. @@ -1068,7 +1068,7 @@ namespace monero { * @param message is a message included with the signature to further authenticate the proof (optional) * @return the reserve proof signature */ - string getReserveProofWallet(const string& message) const; + string get_reserve_proof_wallet(const string& message) const; /** * Generate a signature to prove an available amount in an account. @@ -1078,7 +1078,7 @@ namespace monero { * @param message is a message to include with the signature to further authenticate the proof (optional) * @return the reserve proof signature */ - string getReserveProofAccount(uint32_t accountIdx, uint64_t amount, const string& message) const; + string get_reserve_proof_account(uint32_t accountIdx, uint64_t amount, const string& message) const; /** * Proves a wallet has a disposable reserve using a signature. @@ -1088,7 +1088,7 @@ namespace monero { * @param signature is the reserve proof signature to check * @return the result of checking the signature proof */ - shared_ptr checkReserveProof(const string& address, const string& message, const string& signature) const; + shared_ptr check_reserve_proof(const string& address, const string& message, const string& signature) const; // /** // * Get all address book entries. @@ -1167,7 +1167,7 @@ namespace monero { * @param request specifies configuration for a potential tx * @return is the payment uri */ - string createPaymentUri(const MoneroSendRequest& request) const; + string create_payment_uri(const monero_send_request& request) const; /** * Parses a payment URI to a send request. @@ -1175,7 +1175,7 @@ namespace monero { * @param uri is the payment uri to parse * @return the send request parsed from the uri */ - shared_ptr parsePaymentUri(const string& uri) const; + shared_ptr parse_payment_uri(const string& uri) const; /** * Set an arbitrary attribute. @@ -1183,7 +1183,7 @@ namespace monero { * @param key is the attribute key * @param val is the attribute value */ - void setAttribute(const string& key, const string& val); + void set_attribute(const string& key, const string& val); /** * Get an attribute. @@ -1191,7 +1191,7 @@ namespace monero { * @param key is the attribute to get the value of * @return the attribute's value */ - string getAttribute(const string& key) const; + string get_attribute(const string& key) const; /** * Start mining. @@ -1200,12 +1200,12 @@ namespace monero { * @param backgroundMining specifies if mining should occur in the background (optional) * @param ignoreBattery specifies if the battery should be ignored for mining (optional) */ - void startMining(boost::optional numThreads, boost::optional backgroundMining, boost::optional ignoreBattery); + void start_mining(boost::optional numThreads, boost::optional backgroundMining, boost::optional ignoreBattery); /** * Stop mining. */ - void stopMining(); + void stop_mining(); /** * Save the wallet at its current path. @@ -1218,7 +1218,7 @@ namespace monero { * @param path is the new wallet's path * @param password is the new wallet's password */ - void moveTo(string path, string password); + void move_to(string path, string password); /** * Close the wallet. @@ -1234,7 +1234,7 @@ namespace monero { boost::optional listener = boost::none; // wallet's external listener void initCommon(); - vector getSubaddressesAux(uint32_t accountIdx, const vector& subaddressIndices, const vector& transfers) const; + vector getSubaddressesAux(uint32_t accountIdx, const vector& subaddressIndices, const vector& transfers) const; // blockchain sync management mutable std::atomic isSynced; // whether or not wallet is synced @@ -1248,7 +1248,7 @@ namespace monero { boost::mutex syncingMutex; // synchronize auto sync loop std::atomic syncingThreadDone; // whether or not the syncing thread is shut down void syncingThreadFunc(); // function to run thread with syncing loop - MoneroSyncResult lockAndSync(boost::optional startHeight = boost::none, boost::optional listener = boost::none); // internal function to synchronize request to sync and rescan - MoneroSyncResult syncAux(boost::optional startHeight = boost::none, boost::optional listener = boost::none); // internal function to immediately block, sync, and report progress + monero_sync_result lockAndSync(boost::optional startHeight = boost::none, boost::optional listener = boost::none); // internal function to synchronize request to sync and rescan + monero_sync_result syncAux(boost::optional startHeight = boost::none, boost::optional listener = boost::none); // internal function to immediately block, sync, and report progress }; } diff --git a/src/wallet/MoneroWalletModel.cpp b/src/wallet/monero_wallet_model.cpp similarity index 61% rename from src/wallet/MoneroWalletModel.cpp rename to src/wallet/monero_wallet_model.cpp index 1af52f4..5880115 100644 --- a/src/wallet/MoneroWalletModel.cpp +++ b/src/wallet/monero_wallet_model.cpp @@ -50,9 +50,9 @@ * Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers */ -#include "MoneroWallet.h" +#include "monero_wallet.h" -#include "utils/MoneroUtils.h" +#include "utils/monero_utils.h" #include #include @@ -65,8 +65,8 @@ namespace monero { // ----------------------- UNDECLARED PRIVATE HELPERS ----------------------- - void mergeIncomingTransfer(vector>& transfers, const shared_ptr& transfer) { - for (const shared_ptr& aTransfer : transfers) { + void mergeIncomingTransfer(vector>& transfers, const shared_ptr& transfer) { + for (const shared_ptr& aTransfer : transfers) { if (aTransfer->accountIndex.get() == transfer->accountIndex.get() && aTransfer->subaddressIndex.get() == transfer->subaddressIndex.get()) { aTransfer->merge(aTransfer, transfer); return; @@ -77,19 +77,19 @@ namespace monero { // ---------------------------- MONERO ACCOUNT ------------------------------ - boost::property_tree::ptree MoneroAccount::toPropertyTree() const { + boost::property_tree::ptree monero_account::to_property_tree() const { boost::property_tree::ptree node; if (index != boost::none) node.put("index", *index); 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()) node.add_child("subaddresses", MoneroUtils::toPropertyTree(subaddresses)); + if (!subaddresses.empty()) node.add_child("subaddresses", monero_utils::to_property_tree(subaddresses)); return node; } // -------------------------- MONERO SUBADDRESS ----------------------------- - boost::property_tree::ptree MoneroSubaddress::toPropertyTree() const { + boost::property_tree::ptree monero_subaddress::to_property_tree() const { boost::property_tree::ptree node; if (accountIndex != boost::none) node.put("accountIndex", *accountIndex); if (index != boost::none) node.put("index", *index); @@ -105,29 +105,29 @@ namespace monero { // --------------------------- MONERO TX WALLET ----------------------------- - shared_ptr MoneroTxWallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroTxWallet::copy(const shared_ptr& src, const shared_ptr& tgt)"); - return MoneroTxWallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_tx_wallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_tx_wallet::copy(const shared_ptr& src, const shared_ptr& tgt)"); + return monero_tx_wallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroTxWallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroTxWallet::copy(const shared_ptr& src, const shared_ptr& tgt)"); + shared_ptr monero_tx_wallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_tx_wallet::copy(const shared_ptr& src, const shared_ptr& tgt)"); if (this != src.get()) throw runtime_error("this != src"); // copy base class - MoneroTx::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + monero_tx::copy(static_pointer_cast(src), static_pointer_cast(tgt)); // copy wallet extensions if (!src->incomingTransfers.empty()) { - tgt->incomingTransfers = vector>(); - for (const shared_ptr& transfer : src->incomingTransfers) { - shared_ptr transferCopy = transfer->copy(transfer, make_shared()); + tgt->incomingTransfers = vector>(); + for (const shared_ptr& transfer : src->incomingTransfers) { + shared_ptr transferCopy = transfer->copy(transfer, make_shared()); transferCopy->tx = tgt; tgt->incomingTransfers.push_back(transferCopy); } } if (src->outgoingTransfer != boost::none) { - shared_ptr transferCopy = src->outgoingTransfer.get()->copy(src->outgoingTransfer.get(), make_shared()); + shared_ptr transferCopy = src->outgoingTransfer.get()->copy(src->outgoingTransfer.get(), make_shared()); transferCopy->tx = tgt; tgt->outgoingTransfer = transferCopy; } @@ -136,39 +136,39 @@ namespace monero { return tgt; }; - boost::property_tree::ptree MoneroTxWallet::toPropertyTree() const { - boost::property_tree::ptree node = MoneroTx::toPropertyTree(); - if (!incomingTransfers.empty()) node.add_child("incomingTransfers", MoneroUtils::toPropertyTree(incomingTransfers)); - if (outgoingTransfer != boost::none) node.add_child("outgoingTransfer", (*outgoingTransfer)->toPropertyTree()); + boost::property_tree::ptree monero_tx_wallet::to_property_tree() const { + boost::property_tree::ptree node = monero_tx::to_property_tree(); + if (!incomingTransfers.empty()) node.add_child("incomingTransfers", monero_utils::to_property_tree(incomingTransfers)); + if (outgoingTransfer != boost::none) node.add_child("outgoingTransfer", (*outgoingTransfer)->to_property_tree()); if (note != boost::none) node.put("note", *note); return node; } - bool MoneroTxWallet::getIsOutgoing() const { + bool monero_tx_wallet::getIsOutgoing() const { return outgoingTransfer != boost::none; } - bool MoneroTxWallet::getIsIncoming() const { + bool monero_tx_wallet::getIsIncoming() const { return !incomingTransfers.empty(); } - void MoneroTxWallet::merge(const shared_ptr& self, const shared_ptr& other) { - merge(static_pointer_cast(self), static_pointer_cast(other)); + void monero_tx_wallet::merge(const shared_ptr& self, const shared_ptr& other) { + merge(static_pointer_cast(self), static_pointer_cast(other)); } - void MoneroTxWallet::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_tx_wallet::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; // merge base classes - MoneroTx::merge(self, other); + monero_tx::merge(self, other); // merge wallet extensions - note = MoneroUtils::reconcile(note, other->note); + note = monero_utils::reconcile(note, other->note); // merge incoming transfers if (!other->incomingTransfers.empty()) { - for (const shared_ptr& transfer : other->incomingTransfers) { // NOTE: not using reference so shared_ptr is not deleted when tx is dereferenced + for (const shared_ptr& transfer : other->incomingTransfers) { // NOTE: not using reference so shared_ptr is not deleted when tx is dereferenced transfer->tx = self; mergeIncomingTransfer(self->incomingTransfers, transfer); } @@ -184,20 +184,20 @@ namespace monero { // -------------------------- MONERO TX REQUEST ----------------------------- - shared_ptr MoneroTxRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_tx_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroTxRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_tx_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroTxRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroTxRequest::copy(const shared_ptr& src, const shared_ptr& tgt)"); + shared_ptr monero_tx_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_tx_request::copy(const shared_ptr& src, const shared_ptr& tgt)"); if (this != src.get()) throw runtime_error("this != src"); // copy base class - MoneroTxWallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + monero_tx_wallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); // copy request extensions tgt->isOutgoing = src->isOutgoing; @@ -209,27 +209,27 @@ namespace monero { tgt->minHeight = src->minHeight; tgt->maxHeight = src->maxHeight; tgt->includeOutputs = src->includeOutputs; - if (src->transferRequest != boost::none) tgt->transferRequest = src->transferRequest.get()->copy(src->transferRequest.get(), make_shared()); - if (src->outputRequest != boost::none) tgt->outputRequest = src->outputRequest.get()->copy(src->outputRequest.get(), make_shared()); + if (src->transferRequest != boost::none) tgt->transferRequest = src->transferRequest.get()->copy(src->transferRequest.get(), make_shared()); + if (src->outputRequest != boost::none) tgt->outputRequest = src->outputRequest.get()->copy(src->outputRequest.get(), make_shared()); return tgt; }; - boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const { - boost::property_tree::ptree node = MoneroTxWallet::toPropertyTree(); + boost::property_tree::ptree monero_tx_request::to_property_tree() const { + boost::property_tree::ptree node = monero_tx_wallet::to_property_tree(); if (isOutgoing != boost::none) node.put("isOutgoing", *isOutgoing); if (isIncoming != boost::none) node.put("isIncoming", *isIncoming); - if (!txIds.empty()) node.add_child("txIds", MoneroUtils::toPropertyTree(txIds)); + if (!txIds.empty()) node.add_child("txIds", monero_utils::to_property_tree(txIds)); if (hasPaymentId != boost::none) node.put("hasPaymentId", *hasPaymentId); - if (!paymentIds.empty()) node.add_child("paymentIds", MoneroUtils::toPropertyTree(paymentIds)); + if (!paymentIds.empty()) node.add_child("paymentIds", monero_utils::to_property_tree(paymentIds)); if (height != boost::none) node.put("height", *height); if (minHeight != boost::none) node.put("minHeight", *minHeight); if (maxHeight != boost::none) node.put("maxHeight", *maxHeight); if (includeOutputs != boost::none) node.put("includeOutputs", *includeOutputs); - if (transferRequest != boost::none) node.add_child("transferRequest", (*transferRequest)->toPropertyTree()); + if (transferRequest != boost::none) node.add_child("transferRequest", (*transferRequest)->to_property_tree()); return node; } - bool MoneroTxRequest::meetsCriteria(MoneroTxWallet* tx) const { + bool monero_tx_request::meetsCriteria(monero_tx_wallet* tx) const { if (tx == nullptr) return false; // filter on tx @@ -246,7 +246,7 @@ namespace monero { bool matchFound = false; if (tx->outgoingTransfer != boost::none && (*transferRequest)->meetsCriteria((*tx->outgoingTransfer).get())) matchFound = true; else if (!tx->incomingTransfers.empty()) { - for (const shared_ptr& incomingTransfer : tx->incomingTransfers) { + for (const shared_ptr& incomingTransfer : tx->incomingTransfers) { if ((*transferRequest)->meetsCriteria(incomingTransfer.get())) { matchFound = true; break; @@ -269,7 +269,7 @@ namespace monero { if (isOutgoing != boost::none && isOutgoing != tx->getIsOutgoing()) return false; // filter on remaining fields - boost::optional txHeight = tx->getHeight(); + boost::optional txHeight = tx->get_height(); if (!txIds.empty() && find(txIds.begin(), txIds.end(), *tx->id) == txIds.end()) return false; if (!paymentIds.empty() && (tx->paymentId == boost::none || find(paymentIds.begin(), paymentIds.end(), *tx->paymentId) == paymentIds.end())) return false; if (height != boost::none && (txHeight == boost::none || *txHeight != *height)) return false; @@ -282,15 +282,15 @@ namespace monero { // -------------------------- MONERO DESTINATION ---------------------------- - shared_ptr MoneroDestination::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroDestination::copy(const shared_ptr& src, const shared_ptr& tgt)"); + shared_ptr monero_destination::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_destination::copy(const shared_ptr& src, const shared_ptr& tgt)"); if (this != src.get()) throw runtime_error("this != src"); tgt->address = src->address; tgt->amount = src->amount; return tgt; }; - boost::property_tree::ptree MoneroDestination::toPropertyTree() const { + boost::property_tree::ptree monero_destination::to_property_tree() const { boost::property_tree::ptree node; if (address != boost::none) node.put("address", *address); if (amount != boost::none) node.put("amount", *amount); @@ -299,8 +299,8 @@ namespace monero { // ---------------------------- MONERO TRANSFER ----------------------------- - shared_ptr MoneroTransfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroTransfer::copy(const shared_ptr& src, const shared_ptr& tgt)"); + shared_ptr monero_transfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_transfer::copy(const shared_ptr& src, const shared_ptr& tgt)"); tgt->tx = src->tx; // reference parent tx by default tgt->amount = src->amount; tgt->accountIndex = src->accountIndex; @@ -308,7 +308,7 @@ namespace monero { return tgt; } - boost::property_tree::ptree MoneroTransfer::toPropertyTree() const { + boost::property_tree::ptree monero_transfer::to_property_tree() const { boost::property_tree::ptree node; if (amount != boost::none) node.put("amount", *amount); if (accountIndex != boost::none) node.put("accountIndex", *accountIndex); @@ -316,7 +316,7 @@ namespace monero { return node; } - void MoneroTransfer::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_transfer::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; @@ -327,96 +327,96 @@ namespace monero { } // otherwise merge transfer fields - accountIndex = MoneroUtils::reconcile(accountIndex, other->accountIndex, "acountIndex"); + accountIndex = monero_utils::reconcile(accountIndex, other->accountIndex, "acountIndex"); // TODO monero core: failed tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount/numSuggestedConfirmations of 0 if (amount != boost::none && other->amount != boost::none && *amount != *other->amount && (*amount == 0 || *other->amount == 0)) { - accountIndex = MoneroUtils::reconcile(accountIndex, other->accountIndex, boost::none, boost::none, true, "acountIndex"); - numSuggestedConfirmations = MoneroUtils::reconcile(numSuggestedConfirmations, other->numSuggestedConfirmations, boost::none, boost::none, true, "numSuggestedConfirmations"); + accountIndex = monero_utils::reconcile(accountIndex, other->accountIndex, boost::none, boost::none, true, "acountIndex"); + numSuggestedConfirmations = monero_utils::reconcile(numSuggestedConfirmations, other->numSuggestedConfirmations, boost::none, boost::none, true, "numSuggestedConfirmations"); MWARNING("WARNING: failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/numSuggestedConfirmations of 0"); } else { - amount = MoneroUtils::reconcile(amount, other->amount, "transfer amount"); - numSuggestedConfirmations = MoneroUtils::reconcile(numSuggestedConfirmations, other->numSuggestedConfirmations, boost::none, boost::none, false, "numSuggestedConfirmations"); + amount = monero_utils::reconcile(amount, other->amount, "transfer amount"); + numSuggestedConfirmations = monero_utils::reconcile(numSuggestedConfirmations, other->numSuggestedConfirmations, boost::none, boost::none, false, "numSuggestedConfirmations"); } } // ----------------------- MONERO INCOMING TRANSFER ------------------------- - shared_ptr MoneroIncomingTransfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_incoming_transfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return copy(static_pointer_cast(src), static_pointer_cast(tgt)); } - shared_ptr MoneroIncomingTransfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { + shared_ptr monero_incoming_transfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { - throw runtime_error("MoneroIncomingTransfer::copy(inTransfer) not implemented"); + throw runtime_error("monero_incoming_transfer::copy(inTransfer) not implemented"); }; - boost::optional MoneroIncomingTransfer::getIsIncoming() const { return true; } + boost::optional monero_incoming_transfer::getIsIncoming() const { return true; } - boost::property_tree::ptree MoneroIncomingTransfer::toPropertyTree() const { - boost::property_tree::ptree node = MoneroTransfer::toPropertyTree(); + boost::property_tree::ptree monero_incoming_transfer::to_property_tree() const { + boost::property_tree::ptree node = monero_transfer::to_property_tree(); if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex); if (address != boost::none) node.put("address", *address); return node; } - void MoneroIncomingTransfer::merge(const shared_ptr& self, const shared_ptr& other) { - merge(static_pointer_cast(self), static_pointer_cast(other)); + void monero_incoming_transfer::merge(const shared_ptr& self, const shared_ptr& other) { + merge(static_pointer_cast(self), static_pointer_cast(other)); } - void MoneroIncomingTransfer::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_incoming_transfer::merge(const shared_ptr& self, const shared_ptr& other) { if (self == other) return; - MoneroTransfer::merge(self, other); - subaddressIndex = MoneroUtils::reconcile(subaddressIndex, other->subaddressIndex, "incoming transfer subaddressIndex"); - address = MoneroUtils::reconcile(address, other->address); + monero_transfer::merge(self, other); + subaddressIndex = monero_utils::reconcile(subaddressIndex, other->subaddressIndex, "incoming transfer subaddressIndex"); + address = monero_utils::reconcile(address, other->address); } // ----------------------- MONERO OUTGOING TRANSFER ------------------------- - shared_ptr MoneroOutgoingTransfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_outgoing_transfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroOutgoingTransfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { - throw runtime_error("MoneroOutgoingTransfer::copy(outTransfer) not implemented"); + shared_ptr monero_outgoing_transfer::copy(const shared_ptr& src, const shared_ptr& tgt) const { + throw runtime_error("monero_outgoing_transfer::copy(outTransfer) not implemented"); }; - boost::optional MoneroOutgoingTransfer::getIsIncoming() const { return false; } + boost::optional monero_outgoing_transfer::getIsIncoming() const { return false; } - boost::property_tree::ptree MoneroOutgoingTransfer::toPropertyTree() const { - boost::property_tree::ptree node = MoneroTransfer::toPropertyTree(); - if (!subaddressIndices.empty()) node.add_child("subaddressIndices", MoneroUtils::toPropertyTree(subaddressIndices)); - if (!addresses.empty()) node.add_child("addresses", MoneroUtils::toPropertyTree(addresses)); - if (!destinations.empty()) node.add_child("destinations", MoneroUtils::toPropertyTree(destinations)); + boost::property_tree::ptree monero_outgoing_transfer::to_property_tree() const { + boost::property_tree::ptree node = monero_transfer::to_property_tree(); + if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices)); + if (!addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(addresses)); + if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations)); return node; } - void MoneroOutgoingTransfer::merge(const shared_ptr& self, const shared_ptr& other) { - merge(static_pointer_cast(self), static_pointer_cast(other)); + void monero_outgoing_transfer::merge(const shared_ptr& self, const shared_ptr& other) { + merge(static_pointer_cast(self), static_pointer_cast(other)); } - void MoneroOutgoingTransfer::merge(const shared_ptr& self, const shared_ptr& other) { + void monero_outgoing_transfer::merge(const shared_ptr& self, const shared_ptr& other) { if (self == other) return; - MoneroTransfer::merge(self, other); - subaddressIndices = MoneroUtils::reconcile(subaddressIndices, other->subaddressIndices); - addresses = MoneroUtils::reconcile(addresses, other->addresses); - destinations = MoneroUtils::reconcile(destinations, other->destinations); + monero_transfer::merge(self, other); + subaddressIndices = monero_utils::reconcile(subaddressIndices, other->subaddressIndices); + addresses = monero_utils::reconcile(addresses, other->addresses); + destinations = monero_utils::reconcile(destinations, other->destinations); } // ----------------------- MONERO TRANSFER REQUEST -------------------------- - shared_ptr MoneroTransferRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_transfer_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroTransferRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroTransferRequest::copy(const shared_ptr& src, const shared_ptr& tgt)"); + shared_ptr monero_transfer_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_transfer_request::copy(const shared_ptr& src, const shared_ptr& tgt)"); if (this != src.get()) throw runtime_error("this != src"); // copy base class - MoneroTransfer::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + monero_transfer::copy(static_pointer_cast(src), static_pointer_cast(tgt)); // copy extensions tgt->isIncoming = src->isIncoming; @@ -425,8 +425,8 @@ namespace monero { tgt->subaddressIndex = src->subaddressIndex; if (!src->subaddressIndices.empty()) tgt->subaddressIndices = vector(src->subaddressIndices); if (!src->destinations.empty()) { - for (const shared_ptr& destination : src->destinations) { - tgt->destinations.push_back(destination->copy(destination, make_shared())); + for (const shared_ptr& destination : src->destinations) { + tgt->destinations.push_back(destination->copy(destination, make_shared())); } } tgt->hasDestinations = src->hasDestinations; @@ -434,21 +434,21 @@ namespace monero { return tgt; }; - boost::optional MoneroTransferRequest::getIsIncoming() const { return isIncoming; } + boost::optional monero_transfer_request::getIsIncoming() const { return isIncoming; } - boost::property_tree::ptree MoneroTransferRequest::toPropertyTree() const { - boost::property_tree::ptree node = MoneroTransfer::toPropertyTree(); + boost::property_tree::ptree monero_transfer_request::to_property_tree() const { + boost::property_tree::ptree node = monero_transfer::to_property_tree(); if (getIsIncoming() != boost::none) node.put("isIncoming", *getIsIncoming()); if (address != boost::none) node.put("address", *address); if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex); if (hasDestinations != boost::none) node.put("hasDestinations", *hasDestinations); - if (!subaddressIndices.empty()) node.add_child("subaddressIndices", MoneroUtils::toPropertyTree(subaddressIndices)); - if (!addresses.empty()) node.add_child("addresses", MoneroUtils::toPropertyTree(addresses)); - if (!destinations.empty()) node.add_child("destinations", MoneroUtils::toPropertyTree(destinations)); + if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices)); + if (!addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(addresses)); + if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations)); return node; } - bool MoneroTransferRequest::meetsCriteria(MoneroTransfer* transfer) const { + bool monero_transfer_request::meetsCriteria(monero_transfer* transfer) const { if (transfer == nullptr) throw runtime_error("transfer is null"); if (txRequest != boost::none && (*txRequest)->transferRequest != boost::none) throw runtime_error("Transfer request's tx request cannot have a circular transfer request"); // TODO: could auto detect and handle this. port to java/js @@ -459,7 +459,7 @@ namespace monero { if (accountIndex != boost::none && *accountIndex != *transfer->accountIndex) return false; // filter on incoming fields - MoneroIncomingTransfer* inTransfer = dynamic_cast(transfer); + monero_incoming_transfer* inTransfer = dynamic_cast(transfer); if (inTransfer != nullptr) { if (hasDestinations != boost::none) return false; if (address != boost::none && *address != *inTransfer->address) return false; @@ -469,7 +469,7 @@ namespace monero { } // filter on outgoing fields - MoneroOutgoingTransfer* outTransfer = dynamic_cast(transfer); + monero_outgoing_transfer* outTransfer = dynamic_cast(transfer); if (outTransfer != nullptr) { // filter on addresses @@ -513,7 +513,7 @@ namespace monero { } // validate type - if (inTransfer == nullptr && outTransfer == nullptr) throw runtime_error("Transfer must be MoneroIncomingTransfer or MoneroOutgoingTransfer"); + if (inTransfer == nullptr && outTransfer == nullptr) throw runtime_error("Transfer must be monero_incoming_transfer or monero_outgoing_transfer"); // filter with tx request if (txRequest != boost::none && !(*txRequest)->meetsCriteria(transfer->tx.get())) return false; @@ -522,17 +522,17 @@ namespace monero { // ------------------------- MONERO OUTPUT WALLET --------------------------- - shared_ptr MoneroOutputWallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroOutputWallet::copy(output)"); - return MoneroOutputWallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_output_wallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_output_wallet::copy(output)"); + return monero_output_wallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroOutputWallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroOutputWallet::copy(outputWallet)"); + shared_ptr monero_output_wallet::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_output_wallet::copy(outputWallet)"); if (this != src.get()) throw runtime_error("this != src"); // copy base class - MoneroOutput::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + monero_output::copy(static_pointer_cast(src), static_pointer_cast(tgt)); // copy extensions tgt->accountIndex = src->accountIndex; @@ -543,8 +543,8 @@ namespace monero { return tgt; }; - boost::property_tree::ptree MoneroOutputWallet::toPropertyTree() const { - boost::property_tree::ptree node = MoneroOutput::toPropertyTree(); + boost::property_tree::ptree monero_output_wallet::to_property_tree() const { + boost::property_tree::ptree node = monero_output::to_property_tree(); if (accountIndex != boost::none) node.put("accountIndex", *accountIndex); if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex); if (isSpent != boost::none) node.put("isSpent", *isSpent); @@ -553,43 +553,43 @@ namespace monero { return node; } - void MoneroOutputWallet::merge(const shared_ptr& self, const shared_ptr& other) { - merge(static_pointer_cast(self), static_pointer_cast(other)); + void monero_output_wallet::merge(const shared_ptr& self, const shared_ptr& other) { + merge(static_pointer_cast(self), static_pointer_cast(other)); } - void MoneroOutputWallet::merge(const shared_ptr& self, const shared_ptr& other) { - throw runtime_error("MoneroOutputWallet::merge(self, other) not implemented"); + void monero_output_wallet::merge(const shared_ptr& self, const shared_ptr& other) { + throw runtime_error("monero_output_wallet::merge(self, other) not implemented"); } // ------------------------ MONERO OUTPUT REQUEST --------------------------- - shared_ptr MoneroOutputRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return MoneroOutputRequest::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_output_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return monero_output_request::copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroOutputRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - return MoneroOutputRequest::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + shared_ptr monero_output_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + return monero_output_request::copy(static_pointer_cast(src), static_pointer_cast(tgt)); }; - shared_ptr MoneroOutputRequest::copy(const shared_ptr& src, const shared_ptr& tgt) const { - MTRACE("MoneroOutputRequest::copy(outputRequest)"); + shared_ptr monero_output_request::copy(const shared_ptr& src, const shared_ptr& tgt) const { + MTRACE("monero_output_request::copy(outputRequest)"); if (this != src.get()) throw runtime_error("this != src"); // copy base class - MoneroOutputWallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); + monero_output_wallet::copy(static_pointer_cast(src), static_pointer_cast(tgt)); // copy extensions if (!src->subaddressIndices.empty()) tgt->subaddressIndices = vector(src->subaddressIndices); return tgt; }; - boost::property_tree::ptree MoneroOutputRequest::toPropertyTree() const { - boost::property_tree::ptree node = MoneroOutputWallet::toPropertyTree(); - if (!subaddressIndices.empty()) node.add_child("subaddressIndices", MoneroUtils::toPropertyTree(subaddressIndices)); + boost::property_tree::ptree monero_output_request::to_property_tree() const { + boost::property_tree::ptree node = monero_output_wallet::to_property_tree(); + if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices)); return node; } - bool MoneroOutputRequest::meetsCriteria(MoneroOutputWallet* output) const { + bool monero_output_request::meetsCriteria(monero_output_wallet* output) const { // filter on output if (accountIndex != boost::none && *accountIndex != *output->accountIndex) return false; @@ -609,7 +609,7 @@ namespace monero { if (!subaddressIndices.empty() && find(subaddressIndices.begin(), subaddressIndices.end(), *output->subaddressIndex) == subaddressIndices.end()) return false; // filter with tx request - if (txRequest != boost::none && !(*txRequest)->meetsCriteria(static_pointer_cast(output->tx).get())) return false; + if (txRequest != boost::none && !(*txRequest)->meetsCriteria(static_pointer_cast(output->tx).get())) return false; // output meets request return true; @@ -617,15 +617,15 @@ namespace monero { // ------------------------- MONERO SEND REQUEST ---------------------------- - boost::property_tree::ptree MoneroSendRequest::toPropertyTree() const { + boost::property_tree::ptree monero_send_request::to_property_tree() const { boost::property_tree::ptree node; - if (!destinations.empty()) node.add_child("destinations", MoneroUtils::toPropertyTree(destinations)); + if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations)); if (paymentId != boost::none) node.put("paymentId", *paymentId); if (priority != boost::none) node.put("priority", *priority); if (mixin != boost::none) node.put("mixin", *mixin); if (ringSize != boost::none) node.put("ringSize", *ringSize); if (accountIndex != boost::none) node.put("accountIndex", *accountIndex); - if (!subaddressIndices.empty()) node.add_child("subaddressIndices", MoneroUtils::toPropertyTree(subaddressIndices)); + if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices)); if (unlockTime != boost::none) node.put("unlockTime", *unlockTime); if (canSplit != boost::none) node.put("canSplit", *canSplit); if (doNotRelay != boost::none) node.put("doNotRelay", *doNotRelay); @@ -639,7 +639,7 @@ namespace monero { // ---------------------- MONERO INTEGRATED ADDRESS ------------------------- - boost::property_tree::ptree MoneroIntegratedAddress::toPropertyTree() const { + boost::property_tree::ptree monero_integrated_address::to_property_tree() const { boost::property_tree::ptree node; node.put("standardAddress", standardAddress); node.put("paymentId", paymentId); @@ -649,7 +649,7 @@ namespace monero { // -------------------- MONERO KEY IMAGE IMPORT RESULT ---------------------- - boost::property_tree::ptree MoneroKeyImageImportResult::toPropertyTree() const { + boost::property_tree::ptree monero_key_image_import_result::to_property_tree() const { boost::property_tree::ptree node; if (height != boost::none) node.put("height", *height); if (spentAmount != boost::none) node.put("spentAmount", *spentAmount); @@ -659,7 +659,7 @@ namespace monero { // ----------------------------- MONERO CHECK ------------------------------- - boost::property_tree::ptree MoneroCheck::toPropertyTree() const { + boost::property_tree::ptree monero_check::to_property_tree() const { boost::property_tree::ptree node; node.put("isGood", isGood); return node; @@ -667,8 +667,8 @@ namespace monero { // --------------------------- MONERO CHECK TX ------------------------------ - boost::property_tree::ptree MoneroCheckTx::toPropertyTree() const { - boost::property_tree::ptree node = MoneroCheck::toPropertyTree();; + boost::property_tree::ptree monero_check_tx::to_property_tree() const { + boost::property_tree::ptree node = monero_check::to_property_tree();; if (inTxPool != boost::none) node.put("inTxPool", *inTxPool); if (numConfirmations != boost::none) node.put("numConfirmations", *numConfirmations); if (receivedAmount != boost::none) node.put("receivedAmount", *receivedAmount); @@ -677,8 +677,8 @@ namespace monero { // ------------------------ MONERO CHECK RESERVE ---------------------------- - boost::property_tree::ptree MoneroCheckReserve::toPropertyTree() const { - boost::property_tree::ptree node = MoneroCheck::toPropertyTree(); + boost::property_tree::ptree monero_check_reserve::to_property_tree() const { + boost::property_tree::ptree node = monero_check::to_property_tree(); if (totalAmount != boost::none) node.put("totalAmount", *totalAmount); if (unconfirmedSpentAmount != boost::none) node.put("unconfirmedSpentAmount", *unconfirmedSpentAmount); return node; diff --git a/src/wallet/MoneroWalletModel.h b/src/wallet/monero_wallet_model.h similarity index 57% rename from src/wallet/MoneroWalletModel.h rename to src/wallet/monero_wallet_model.h index a5c885b..4f0e27d 100644 --- a/src/wallet/MoneroWalletModel.h +++ b/src/wallet/monero_wallet_model.h @@ -52,7 +52,7 @@ #pragma once -#include "daemon/MoneroDaemonModel.h" +#include "daemon/monero_daemon_model.h" using namespace std; using namespace monero; @@ -65,17 +65,17 @@ namespace monero { /** * Models a result of syncing a wallet. */ - struct MoneroSyncResult { + struct monero_sync_result { uint64_t numBlocksFetched; bool receivedMoney; - MoneroSyncResult() {} - MoneroSyncResult(const uint64_t numBlocksFetched, const bool receivedMoney) : numBlocksFetched(numBlocksFetched), receivedMoney(receivedMoney) {} + monero_sync_result() {} + monero_sync_result(const uint64_t numBlocksFetched, const bool receivedMoney) : numBlocksFetched(numBlocksFetched), receivedMoney(receivedMoney) {} }; /** * Models a Monero subaddress. */ - struct MoneroSubaddress : public SerializableStruct { + struct monero_subaddress : public serializable_struct { boost::optional accountIndex; boost::optional index; boost::optional address; @@ -97,20 +97,20 @@ namespace monero { // KV_SERIALIZE(numBlocksToUnlock) // END_KV_SERIALIZE_MAP() - boost::property_tree::ptree toPropertyTree() const; - //void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + //void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models a Monero account. */ - struct MoneroAccount : public SerializableStruct { + struct monero_account : public serializable_struct { boost::optional index; boost::optional primaryAddress; boost::optional balance; boost::optional unlockedBalance; boost::optional tag; - vector subaddresses; + vector subaddresses; // BEGIN_KV_SERIALIZE_MAP() // KV_SERIALIZE(index) // KV_SERIALIZE(primaryAddress) @@ -121,72 +121,72 @@ namespace monero { // KV_SERIALIZE(subaddresses) // END_KV_SERIALIZE_MAP() - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; // forward declarations - struct MoneroTxWallet; - struct MoneroTxRequest; + struct monero_tx_wallet; + struct monero_tx_request; /** * Models an outgoing transfer destination. */ - struct MoneroDestination { + struct monero_destination { boost::optional address; boost::optional amount; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; }; /** * Models a base transfer of funds to or from the wallet. */ - struct MoneroTransfer : SerializableStruct { - shared_ptr tx; + struct monero_transfer : serializable_struct { + shared_ptr tx; boost::optional amount; boost::optional accountIndex; boost::optional numSuggestedConfirmations; virtual boost::optional getIsIncoming() const = 0; // derived class must implement - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; boost::optional getIsOutgoing() const { if (getIsIncoming() == boost::none) return boost::none; return !(*getIsIncoming()); } - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models an incoming transfer of funds to the wallet. */ - struct MoneroIncomingTransfer : public MoneroTransfer { + struct monero_incoming_transfer : public monero_transfer { boost::optional subaddressIndex; boost::optional address; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; boost::optional getIsIncoming() const; - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); - void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); + void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models an outgoing transfer of funds from the wallet. */ - struct MoneroOutgoingTransfer : public MoneroTransfer { + struct monero_outgoing_transfer : public monero_transfer { vector subaddressIndices; vector addresses; - vector> destinations; + vector> destinations; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; boost::optional getIsIncoming() const; - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); - void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); + void merge(const shared_ptr& self, const shared_ptr& other); }; /** @@ -194,38 +194,38 @@ namespace monero { * * All transfers are returned except those that do not meet the criteria defined in this request. */ - struct MoneroTransferRequest : public MoneroTransfer { + struct monero_transfer_request : public monero_transfer { boost::optional isIncoming; boost::optional address; vector addresses; boost::optional subaddressIndex; vector subaddressIndices; - vector> destinations; + vector> destinations; boost::optional hasDestinations; - boost::optional> txRequest; + boost::optional> txRequest; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; boost::optional getIsIncoming() const; - boost::property_tree::ptree toPropertyTree() const; - bool meetsCriteria(MoneroTransfer* transfer) const; + boost::property_tree::ptree to_property_tree() const; + bool meetsCriteria(monero_transfer* transfer) const; }; /** * Models a Monero output with wallet extensions. */ - struct MoneroOutputWallet : public MoneroOutput { + struct monero_output_wallet : public monero_output { boost::optional accountIndex; boost::optional subaddressIndex; boost::optional isSpent; boost::optional isUnlocked; boost::optional isFrozen; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); - void merge(const shared_ptr& self, const shared_ptr& other); + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); + void merge(const shared_ptr& self, const shared_ptr& other); }; /** @@ -234,33 +234,33 @@ namespace monero { * * All outputs are returned except those that do not meet the criteria defined in this request. */ - struct MoneroOutputRequest : public MoneroOutputWallet { + struct monero_output_request : public monero_output_wallet { vector subaddressIndices; - boost::optional> txRequest; + boost::optional> txRequest; // TODO: necessary to override all super classes? - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; - bool meetsCriteria(MoneroOutputWallet* output) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; + bool meetsCriteria(monero_output_wallet* output) const; }; /** * Models a Monero transaction in the context of a wallet. */ - struct MoneroTxWallet : public MoneroTx { - vector> incomingTransfers; - boost::optional> outgoingTransfer; + struct monero_tx_wallet : public monero_tx { + vector> incomingTransfers; + boost::optional> outgoingTransfer; boost::optional note; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; bool getIsIncoming() const; bool getIsOutgoing() const; - boost::property_tree::ptree toPropertyTree() const; - void merge(const shared_ptr& self, const shared_ptr& other); - void merge(const shared_ptr& self, const shared_ptr& other); + boost::property_tree::ptree to_property_tree() const; + void merge(const shared_ptr& self, const shared_ptr& other); + void merge(const shared_ptr& self, const shared_ptr& other); }; /** @@ -268,7 +268,7 @@ namespace monero { * * All transactions are returned except those that do not meet the criteria defined in this request. */ - struct MoneroTxRequest : public MoneroTxWallet { + struct monero_tx_request : public monero_tx_wallet { boost::optional isOutgoing; boost::optional isIncoming; vector txIds; @@ -278,32 +278,32 @@ namespace monero { boost::optional minHeight; boost::optional maxHeight; boost::optional includeOutputs; - boost::optional> transferRequest; - boost::optional> outputRequest; + boost::optional> transferRequest; + boost::optional> outputRequest; // TODO: necessary to override all super classes? - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; - boost::property_tree::ptree toPropertyTree() const; - bool meetsCriteria(MoneroTxWallet* tx) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; + boost::property_tree::ptree to_property_tree() const; + bool meetsCriteria(monero_tx_wallet* tx) const; }; /** * Monero integrated address model. */ - struct MoneroIntegratedAddress : public SerializableStruct { + struct monero_integrated_address : public serializable_struct { string standardAddress; string paymentId; string integratedAddress; - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; /** * Enumerates Monero network types. */ - enum MoneroSendPriority : uint8_t { + enum monero_send_priority : uint8_t { DEFAULT = 0, UNIMPORTANT, NORMAL, @@ -313,10 +313,10 @@ namespace monero { /** * Configures a request to send/sweep funds or create a payment URI. */ - struct MoneroSendRequest : public SerializableStruct { - vector> destinations; + struct monero_send_request : public serializable_struct { + vector> destinations; boost::optional paymentId; - boost::optional priority; + boost::optional priority; boost::optional mixin; boost::optional ringSize; boost::optional fee; @@ -331,47 +331,47 @@ namespace monero { boost::optional sweepEachSubaddress; boost::optional keyImage; - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; /** * Models results from importing key images. */ - struct MoneroKeyImageImportResult : public SerializableStruct { + struct monero_key_image_import_result : public serializable_struct { boost::optional height; boost::optional spentAmount; boost::optional unspentAmount; - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; /** * Base class for results from checking a transaction or reserve proof. */ - struct MoneroCheck : public SerializableStruct { + struct monero_check : public serializable_struct { bool isGood; - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; /** * Results from checking a transaction key. */ - struct MoneroCheckTx : public MoneroCheck { + struct monero_check_tx : public monero_check { boost::optional inTxPool; boost::optional numConfirmations; boost::optional receivedAmount; - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; /** * Results from checking a reserve proof. */ - struct MoneroCheckReserve : public MoneroCheck { + struct monero_check_reserve : public monero_check { boost::optional totalAmount; boost::optional unconfirmedSpentAmount; - boost::property_tree::ptree toPropertyTree() const; + boost::property_tree::ptree to_property_tree() const; }; } diff --git a/test/Scratchpad.cpp b/test/scratchpad.cpp similarity index 64% rename from test/Scratchpad.cpp rename to test/scratchpad.cpp index 1bdecd4..ac4ad2a 100644 --- a/test/Scratchpad.cpp +++ b/test/scratchpad.cpp @@ -1,7 +1,7 @@ #include #include #include "wallet2.h" -#include "wallet/MoneroWallet.h" +#include "wallet/monero_wallet.h" //#include using namespace std; @@ -13,14 +13,14 @@ bool walletExists(string path) { return wallet_file_exists; } -void openWallet(string path, string password, int networkType) { - cout << "openWallet(" << path << ", " << password << ", " << networkType << ")" << endl; +void open_wallet(string path, string password, int networkType) { + cout << "open_wallet(" << path << ", " << password << ", " << networkType << ")" << endl; std::unique_ptr wallet; wallet.reset(new tools::wallet2(cryptonote::network_type::STAGENET, 1, true)); throw runtime_error("Not implemented"); } -void createWalletRandom(string language, int networkType) { +void create_wallet_random(string language, int networkType) { tools::wallet2* wallet = new tools::wallet2(static_cast(networkType), 1, true); wallet->set_seed_language(language); crypto::secret_key recovery_val, secret_key; @@ -57,57 +57,57 @@ int main(int argc, const char* argv[]) { MINFO("Wallet exists: " << walletExists(path)); -// openWallet(path, password, networkType); -// createWalletRandom(language, networkType); +// open_wallet(path, password, networkType); +// create_wallet_random(language, networkType); // // create wallet -// MoneroWallet* wallet = new MoneroWallet(); +// monero_wallet* wallet = new monero_wallet(); // // // get the mnemonic // epee::wipeable_string mnemonic; -// wallet->getMnemonic(mnemonic); +// wallet->get_mnemonic(mnemonic); // cout << "Mnemonic: " << string(mnemonic.data(), mnemonic.size()) << endl; // load wallet - MoneroWallet* wallet = MoneroWallet::openWallet("../../test_wallets/test_wallet_1", "supersecretpassword123", MoneroNetworkType::STAGENET); - wallet->setDaemonConnection("http://localhost:38081", "", ""); + monero_wallet* wallet = monero_wallet::open_wallet("../../test_wallets/test_wallet_1", "supersecretpassword123", MoneroNetworkType::STAGENET); + wallet->set_daemon_connection("http://localhost:38081", "", ""); // fetch txs - vector> txs = wallet->getTxs(); + vector> txs = wallet->get_txs(); MINFO("Wallet has " << txs.size() << " txs. Printing some."); for (int i = 0; i < txs.size() && i < 10; i++) { MINFO(txs[i]->serialize()); } -// shared_ptr transferRequest = shared_ptr(new MoneroTransferRequest()); +// shared_ptr transferRequest = shared_ptr(new monero_transfer_request()); // transferRequest->accountIndex = 0; -// shared_ptr txRequest = shared_ptr(new MoneroTxRequest()); +// shared_ptr txRequest = shared_ptr(new monero_tx_request()); // txRequest->isConfirmed = true; // transferRequest->txRequest = txRequest; // //txRequest->transferRequest = transferRequest; -// vector> transfers = wallet->getTransfers(*transferRequest); +// vector> transfers = wallet->get_transfers(*transferRequest); // if (transfers.empty()) throw runtime_error("Transfers should not be empty"); -// for (const shared_ptr& transfer : transfers) { +// for (const shared_ptr& transfer : transfers) { // if (*transfer->accountIndex != 0) throw runtime_error("Account should be 0"); // if (!*transfer->tx->isConfirmed) throw runtime_error("Transfer should be confirmed"); // } -// shared_ptr txRequest = shared_ptr(new MoneroTxRequest()); +// shared_ptr txRequest = shared_ptr(new monero_tx_request()); // txRequest->isConfirmed = true; -// vector> txs = wallet->getTxs(*txRequest); +// vector> txs = wallet->get_txs(*txRequest); // if (txs.empty()) throw runtime_error("Txs should not be empty"); -// for (const shared_ptr& tx : txs) { +// for (const shared_ptr& tx : txs) { // if (!*tx->isConfirmed) throw runtime_error("Tx should be confirmed"); // } // // debug simple block merging -// vector> txs = wallet->getTxs(); +// vector> txs = wallet->get_txs(); // if (txs.empty()) throw runtime_error("Txs should not be empty"); -// shared_ptr block = nullptr; -// for (const shared_ptr& tx : txs) { -// if (tx->getHeight().get() != 360559l) throw runtime_error("Anything other than 360559l should be filtered"); +// shared_ptr block = nullptr; +// for (const shared_ptr& tx : txs) { +// if (tx->get_height().get() != 360559l) throw runtime_error("Anything other than 360559l should be filtered"); // cout << "We have one!!!" << endl; // if (block == nullptr) block = tx->block.get(); // else {