prefix member variables with m_*

This commit is contained in:
woodser
2019-08-05 17:34:03 -04:00
parent fd399fcda9
commit 019cc76ae6
6 changed files with 1152 additions and 1152 deletions
+225 -225
View File
@@ -65,7 +65,7 @@ namespace monero {
void merge_tx(vector<shared_ptr<monero_tx>>& txs, const shared_ptr<monero_tx>& tx) {
for (const shared_ptr<monero_tx>& aTx : txs) {
if (aTx->id.get() == tx->id.get()) {
if (aTx->m_id.get() == tx->m_id.get()) {
aTx->merge(aTx, tx);
return;
}
@@ -87,58 +87,58 @@ namespace monero {
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);
if (timestamp != boost::none) node.put("timestamp", *timestamp);
if (size != boost::none) node.put("size", *size);
if (weight != boost::none) node.put("weight", *weight);
if (long_term_weight != boost::none) node.put("longTermWeight", *long_term_weight);
if (depth != boost::none) node.put("depth", *depth);
if (difficulty != boost::none) node.put("difficulty", *difficulty);
if (cumulative_difficulty != boost::none) node.put("cumulativeDifficulty", *height);
if (major_version != boost::none) node.put("majorVersion", *major_version);
if (minor_version != boost::none) node.put("minorVersion", *minor_version);
if (nonce != boost::none) node.put("nonce", *nonce);
if (miner_tx_id != boost::none) node.put("minerTxId", *miner_tx_id);
if (num_txs != boost::none) node.put("numTxs", *num_txs);
if (orphan_status != boost::none) node.put("orphanStatus", *orphan_status);
if (prev_id != boost::none) node.put("prevId", *prev_id);
if (reward != boost::none) node.put("reward", *reward);
if (pow_hash != boost::none) node.put("powHash", *pow_hash);
if (m_id != boost::none) node.put("id", *m_id);
if (m_height != boost::none) node.put("height", *m_height);
if (m_timestamp != boost::none) node.put("timestamp", *m_timestamp);
if (m_size != boost::none) node.put("size", *m_size);
if (m_weight != boost::none) node.put("weight", *m_weight);
if (m_long_term_weight != boost::none) node.put("longTermWeight", *m_long_term_weight);
if (m_depth != boost::none) node.put("depth", *m_depth);
if (m_difficulty != boost::none) node.put("difficulty", *m_difficulty);
if (m_cumulative_difficulty != boost::none) node.put("cumulativeDifficulty", *m_cumulative_difficulty);
if (m_major_version != boost::none) node.put("majorVersion", *m_major_version);
if (m_minor_version != boost::none) node.put("minorVersion", *m_minor_version);
if (m_nonce != boost::none) node.put("m_nonce", *m_nonce);
if (m_miner_tx_id != boost::none) node.put("minerTxId", *m_miner_tx_id);
if (m_num_txs != boost::none) node.put("numTxs", *m_num_txs);
if (m_orphan_status != boost::none) node.put("orphanStatus", *m_orphan_status);
if (m_prev_id != boost::none) node.put("prevId", *m_prev_id);
if (m_reward != boost::none) node.put("m_reward", *m_reward);
if (m_pow_hash != boost::none) node.put("powHash", *m_pow_hash);
return node;
}
void monero_block_header::merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other) {
if (this != self.get()) throw runtime_error("this != self");
if (self == other) return;
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");
long_term_weight = monero_utils::reconcile(long_term_weight, other->long_term_weight, "block header long term weight");
depth = monero_utils::reconcile(depth, other->depth, "block header depth");
difficulty = monero_utils::reconcile(difficulty, other->difficulty, "difficulty");
cumulative_difficulty = monero_utils::reconcile(cumulative_difficulty, other->cumulative_difficulty, "cumulative_difficulty");
major_version = monero_utils::reconcile(major_version, other->major_version, "major_version");
minor_version = monero_utils::reconcile(minor_version, other->minor_version, "minor_version");
nonce = monero_utils::reconcile(nonce, other->nonce, "nonce");
miner_tx_id = monero_utils::reconcile(miner_tx_id, other->miner_tx_id);
num_txs = monero_utils::reconcile(num_txs, other->num_txs, "block header num_txs");
orphan_status = monero_utils::reconcile(orphan_status, other->orphan_status);
prev_id = monero_utils::reconcile(prev_id, other->prev_id);
reward = monero_utils::reconcile(reward, other->reward, "block header reward");
pow_hash = monero_utils::reconcile(pow_hash, other->pow_hash);
m_id = monero_utils::reconcile(m_id, other->m_id);
m_height = monero_utils::reconcile(m_height, other->m_height, boost::none, boost::none, true, "block height"); // height can increase
m_timestamp = monero_utils::reconcile(m_timestamp, other->m_timestamp, boost::none, boost::none, true, "block header timestamp"); // timestamp can increase
m_size = monero_utils::reconcile(m_size, other->m_size, "block header size");
m_weight = monero_utils::reconcile(m_weight, other->m_weight, "block header weight");
m_long_term_weight = monero_utils::reconcile(m_long_term_weight, other->m_long_term_weight, "block header long term weight");
m_depth = monero_utils::reconcile(m_depth, other->m_depth, "block header depth");
m_difficulty = monero_utils::reconcile(m_difficulty, other->m_difficulty, "difficulty");
m_cumulative_difficulty = monero_utils::reconcile(m_cumulative_difficulty, other->m_cumulative_difficulty, "m_cumulative_difficulty");
m_major_version = monero_utils::reconcile(m_major_version, other->m_major_version, "m_major_version");
m_minor_version = monero_utils::reconcile(m_minor_version, other->m_minor_version, "m_minor_version");
m_nonce = monero_utils::reconcile(m_nonce, other->m_nonce, "m_nonce");
m_miner_tx_id = monero_utils::reconcile(m_miner_tx_id, other->m_miner_tx_id);
m_num_txs = monero_utils::reconcile(m_num_txs, other->m_num_txs, "block header m_num_txs");
m_orphan_status = monero_utils::reconcile(m_orphan_status, other->m_orphan_status);
m_prev_id = monero_utils::reconcile(m_prev_id, other->m_prev_id);
m_reward = monero_utils::reconcile(m_reward, other->m_reward, "block header m_reward");
m_pow_hash = monero_utils::reconcile(m_pow_hash, other->m_pow_hash);
}
// ----------------------------- MONERO BLOCK -------------------------------
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 (miner_tx != boost::none) node.add_child("minerTx", (*miner_tx)->to_property_tree());
if (!txs.empty()) node.add_child("txs", monero_utils::to_property_tree(txs));
if (!tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(tx_ids));
if (m_hex != boost::none) node.put("hex", *m_hex);
if (m_miner_tx != boost::none) node.add_child("minerTx", (*m_miner_tx)->to_property_tree());
if (!m_txs.empty()) node.add_child("txs", monero_utils::to_property_tree(m_txs));
if (!m_tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(m_tx_ids));
return node;
}
@@ -154,21 +154,21 @@ namespace monero {
monero_block_header::merge(self, other);
// merge reconcilable block extensions
hex = monero_utils::reconcile(hex, other->hex);
tx_ids = monero_utils::reconcile(tx_ids, other->tx_ids);
m_hex = monero_utils::reconcile(m_hex, other->m_hex);
m_tx_ids = monero_utils::reconcile(m_tx_ids, other->m_tx_ids);
// merge miner tx
if (miner_tx == boost::none) miner_tx = other->miner_tx;
if (other->miner_tx != boost::none) {
other->miner_tx.get()->block = self;
miner_tx.get()->merge(miner_tx.get(), other->miner_tx.get());
if (m_miner_tx == boost::none) m_miner_tx = other->m_miner_tx;
if (other->m_miner_tx != boost::none) {
other->m_miner_tx.get()->m_block = self;
m_miner_tx.get()->merge(m_miner_tx.get(), other->m_miner_tx.get());
}
// merge non-miner txs
if (!other->txs.empty()) {
for (const shared_ptr<monero_tx> otherTx : other->txs) { // NOTE: not using reference so shared_ptr is not deleted when block is dereferenced
otherTx->block = self;
merge_tx(self->txs, otherTx);
if (!other->m_txs.empty()) {
for (const shared_ptr<monero_tx> otherTx : other->m_txs) { // NOTE: not using reference so shared_ptr is not deleted when block is dereferenced
otherTx->m_block = self;
merge_tx(self->m_txs, otherTx);
}
}
}
@@ -177,105 +177,105 @@ namespace monero {
shared_ptr<monero_tx> monero_tx::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const {
MTRACE("monero_tx::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt)");
tgt->id = src->id;
tgt->version = src->version;
tgt->is_miner_tx = src->is_miner_tx;
tgt->payment_id = src->payment_id;
tgt->fee = src->fee;
tgt->mixin = src->mixin;
tgt->do_not_relay = src->do_not_relay;
tgt->is_relayed = src->is_relayed;
tgt->is_confirmed = src->is_confirmed;
tgt->in_tx_pool = src->in_tx_pool;
tgt->num_confirmations = src->num_confirmations;
tgt->unlock_time = src->unlock_time;
tgt->last_relayed_timestamp = src->last_relayed_timestamp;
tgt->received_timestamp = src->received_timestamp;
tgt->is_double_spend_seen = src->is_double_spend_seen;
tgt->key = src->key;
tgt->full_hex = src->full_hex;
tgt->pruned_hex = src->pruned_hex;
tgt->prunable_hex = src->prunable_hex;
tgt->prunable_hash = src->prunable_hash;
tgt->size = src->size;
tgt->weight = src->weight;
if (!src->vins.empty()) {
tgt->vins = vector<shared_ptr<monero_output>>();
for (const shared_ptr<monero_output>& vin : src->vins) {
tgt->m_id = src->m_id;
tgt->m_version = src->m_version;
tgt->m_is_miner_tx = src->m_is_miner_tx;
tgt->m_payment_id = src->m_payment_id;
tgt->m_fee = src->m_fee;
tgt->m_mixin = src->m_mixin;
tgt->m_do_not_relay = src->m_do_not_relay;
tgt->m_is_relayed = src->m_is_relayed;
tgt->m_is_confirmed = src->m_is_confirmed;
tgt->m_in_tx_pool = src->m_in_tx_pool;
tgt->m_num_confirmations = src->m_num_confirmations;
tgt->m_unlock_time = src->m_unlock_time;
tgt->m_last_relayed_timestamp = src->m_last_relayed_timestamp;
tgt->m_received_timestamp = src->m_received_timestamp;
tgt->m_is_double_spend_seen = src->m_is_double_spend_seen;
tgt->m_key = src->m_key;
tgt->m_full_hex = src->m_full_hex;
tgt->m_pruned_hex = src->m_pruned_hex;
tgt->m_prunable_hex = src->m_prunable_hex;
tgt->m_prunable_hash = src->m_prunable_hash;
tgt->m_size = src->m_size;
tgt->m_weight = src->m_weight;
if (!src->m_vins.empty()) {
tgt->m_vins = vector<shared_ptr<monero_output>>();
for (const shared_ptr<monero_output>& vin : src->m_vins) {
shared_ptr<monero_output> vinCopy = vin->copy(vin, make_shared<monero_output>());
vinCopy->tx = tgt;
tgt->vins.push_back(vinCopy);
vinCopy->m_tx = tgt;
tgt->m_vins.push_back(vinCopy);
}
}
if (!src->vouts.empty()) {
tgt->vouts = vector<shared_ptr<monero_output>>();
for (const shared_ptr<monero_output>& vout : src->vouts) {
if (!src->m_vouts.empty()) {
tgt->m_vouts = vector<shared_ptr<monero_output>>();
for (const shared_ptr<monero_output>& vout : src->m_vouts) {
shared_ptr<monero_output> voutCopy = vout->copy(vout, make_shared<monero_output>());
voutCopy->tx = tgt;
tgt->vouts.push_back(voutCopy);
voutCopy->m_tx = tgt;
tgt->m_vouts.push_back(voutCopy);
}
}
if (!src->m_output_indices.empty()) tgt->m_output_indices = vector<uint32_t>(src->m_output_indices);
tgt->metadata = src->metadata;
tgt->common_tx_sets = src->common_tx_sets;
if (!src->extra.empty()) throw runtime_error("extra deep copy not implemented"); // TODO: implement extra
tgt->rct_signatures = src->rct_signatures;
tgt->rct_sig_prunable = src->rct_sig_prunable;
tgt->is_kept_by_block = src->is_kept_by_block;
tgt->is_failed = src->is_failed;
tgt->last_failed_height = src->last_failed_height;
tgt->last_failed_id = src->last_failed_id;
tgt->max_used_block_height = src->max_used_block_height;
tgt->max_used_block_id = src->max_used_block_id;
if (!src->signatures.empty()) tgt->signatures = vector<string>(src->signatures);
tgt->m_metadata = src->m_metadata;
tgt->m_common_tx_sets = src->m_common_tx_sets;
if (!src->m_extra.empty()) throw runtime_error("extra deep copy not implemented"); // TODO: implement extra
tgt->m_rct_signatures = src->m_rct_signatures;
tgt->m_rct_sig_prunable = src->m_rct_sig_prunable;
tgt->m_is_kept_by_block = src->m_is_kept_by_block;
tgt->m_is_failed = src->m_is_failed;
tgt->m_last_failed_height = src->m_last_failed_height;
tgt->m_last_failed_id = src->m_last_failed_id;
tgt->m_max_used_block_height = src->m_max_used_block_height;
tgt->m_max_used_block_id = src->m_max_used_block_id;
if (!src->m_signatures.empty()) tgt->m_signatures = vector<string>(src->m_signatures);
return tgt;
}
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);
if (is_miner_tx != boost::none) node.put("isMinerTx", *is_miner_tx);
if (payment_id != boost::none) node.put("paymentId", *payment_id);
if (fee != boost::none) node.put("fee", *fee);
if (mixin != boost::none) node.put("mixin", *mixin);
if (do_not_relay != boost::none) node.put("doNotRelay", *do_not_relay);
if (is_relayed != boost::none) node.put("isRelayed", *is_relayed);
if (is_confirmed != boost::none) node.put("isConfirmed", *is_confirmed);
if (in_tx_pool != boost::none) node.put("inTxPool", *in_tx_pool);
if (num_confirmations != boost::none) node.put("numConfirmations", *num_confirmations);
if (unlock_time != boost::none) node.put("unlockTime", *unlock_time);
if (last_relayed_timestamp != boost::none) node.put("lastRelayedTimestamp", *last_relayed_timestamp);
if (received_timestamp != boost::none) node.put("receivedTimestamp", *received_timestamp);
if (is_double_spend_seen != boost::none) node.put("isDoubleSpendSeen", *is_double_spend_seen);
if (key != boost::none) node.put("key", *key);
if (full_hex != boost::none) node.put("fullHex", *full_hex);
if (pruned_hex != boost::none) node.put("prunedHex", *pruned_hex);
if (prunable_hex != boost::none) node.put("prunableHex", *prunable_hex);
if (prunable_hash != boost::none) node.put("prunableHash", *prunable_hash);
if (size != boost::none) node.put("size", *size);
if (weight != boost::none) node.put("weight", *weight);
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 (m_id != boost::none) node.put("id", *m_id);
if (m_version != boost::none) node.put("version", *m_version);
if (m_is_miner_tx != boost::none) node.put("isMinerTx", *m_is_miner_tx);
if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id);
if (m_fee != boost::none) node.put("fee", *m_fee);
if (m_mixin != boost::none) node.put("m_mixin", *m_mixin);
if (m_do_not_relay != boost::none) node.put("doNotRelay", *m_do_not_relay);
if (m_is_relayed != boost::none) node.put("isRelayed", *m_is_relayed);
if (m_is_confirmed != boost::none) node.put("isConfirmed", *m_is_confirmed);
if (m_in_tx_pool != boost::none) node.put("inTxPool", *m_in_tx_pool);
if (m_num_confirmations != boost::none) node.put("numConfirmations", *m_num_confirmations);
if (m_unlock_time != boost::none) node.put("unlockTime", *m_unlock_time);
if (m_last_relayed_timestamp != boost::none) node.put("lastRelayedTimestamp", *m_last_relayed_timestamp);
if (m_received_timestamp != boost::none) node.put("receivedTimestamp", *m_received_timestamp);
if (m_is_double_spend_seen != boost::none) node.put("isDoubleSpendSeen", *m_is_double_spend_seen);
if (m_key != boost::none) node.put("key", *m_key);
if (m_full_hex != boost::none) node.put("fullHex", *m_full_hex);
if (m_pruned_hex != boost::none) node.put("prunedHex", *m_pruned_hex);
if (m_prunable_hex != boost::none) node.put("prunableHex", *m_prunable_hex);
if (m_prunable_hash != boost::none) node.put("prunableHash", *m_prunable_hash);
if (m_size != boost::none) node.put("size", *m_size);
if (m_weight != boost::none) node.put("weight", *m_weight);
if (!m_vins.empty()) node.add_child("vins", monero_utils::to_property_tree(m_vins));
if (!m_vouts.empty()) node.add_child("vouts", monero_utils::to_property_tree(m_vouts));
if (!m_output_indices.empty()) throw runtime_error("m_output_indices not implemented");
if (metadata != boost::none) node.put("metadata", *metadata);
if (common_tx_sets != boost::none) throw runtime_error("common_tx_sets not implemented");
if (!extra.empty()) node.add_child("extra", monero_utils::to_property_tree(extra));
if (rct_signatures != boost::none) throw runtime_error("rct_signatures not implemented");
if (rct_sig_prunable != boost::none) throw runtime_error("rct_sig_prunable not implemented");
if (is_kept_by_block != boost::none) node.put("isKeptByBlock", *is_kept_by_block);
if (is_failed != boost::none) node.put("isFailed", *is_failed);
if (last_failed_height != boost::none) node.put("lastFailedHeight", *last_failed_height);
if (last_failed_id != boost::none) node.put("lastFailedId", *last_failed_id);
if (max_used_block_height != boost::none) node.put("maxUsedBlockHeight", *max_used_block_height);
if (max_used_block_id != boost::none) node.put("maxUsedBlockId", *max_used_block_id);
if (!signatures.empty()) throw runtime_error("signatures not implemented");
if (m_metadata != boost::none) node.put("metadata", *m_metadata);
if (m_common_tx_sets != boost::none) throw runtime_error("m_common_tx_sets not implemented");
if (!m_extra.empty()) node.add_child("extra", monero_utils::to_property_tree(m_extra));
if (m_rct_signatures != boost::none) throw runtime_error("m_rct_signatures not implemented");
if (m_rct_sig_prunable != boost::none) throw runtime_error("m_rct_sig_prunable not implemented");
if (m_is_kept_by_block != boost::none) node.put("isKeptByBlock", *m_is_kept_by_block);
if (m_is_failed != boost::none) node.put("isFailed", *m_is_failed);
if (m_last_failed_height != boost::none) node.put("lastFailedHeight", *m_last_failed_height);
if (m_last_failed_id != boost::none) node.put("lastFailedId", *m_last_failed_id);
if (m_max_used_block_height != boost::none) node.put("maxUsedBlockHeight", *m_max_used_block_height);
if (m_max_used_block_id != boost::none) node.put("maxUsedBlockId", *m_max_used_block_id);
if (!m_signatures.empty()) throw runtime_error("m_signatures not implemented");
return node;
}
boost::optional<uint64_t> monero_tx::get_height() const {
if (block == boost::none) return boost::none;
return *((*block)->height);
if (m_block == boost::none) return boost::none;
return *((*m_block)->m_height);
}
void monero_tx::merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other) {
@@ -283,127 +283,127 @@ namespace monero {
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<monero_block>();
block.get()->txs.push_back(self);
block.get()->height = other->get_height();
if (m_block != other->m_block) {
if (m_block == boost::none) {
m_block = make_shared<monero_block>();
m_block.get()->m_txs.push_back(self);
m_block.get()->m_height = other->get_height();
}
if (other->block == boost::none) {
other->block = make_shared<monero_block>();
other->block.get()->txs.push_back(other);
other->block.get()->height = self->get_height();
if (other->m_block == boost::none) {
other->m_block = make_shared<monero_block>();
other->m_block.get()->m_txs.push_back(other);
other->m_block.get()->m_height = self->get_height();
}
block.get()->merge(block.get(), other->block.get());
m_block.get()->merge(m_block.get(), other->m_block.get());
return;
}
// otherwise merge tx fields
id = monero_utils::reconcile(id, other->id);
version = monero_utils::reconcile(version, other->version);
payment_id = monero_utils::reconcile(payment_id, other->payment_id);
fee = monero_utils::reconcile(fee, other->fee, "tx fee");
mixin = monero_utils::reconcile(mixin, other->mixin, "tx mixin");
is_confirmed = monero_utils::reconcile(is_confirmed, other->is_confirmed);
do_not_relay = monero_utils::reconcile(do_not_relay, other->do_not_relay);
is_relayed = monero_utils::reconcile(is_relayed, other->is_relayed);
is_double_spend_seen = monero_utils::reconcile(is_double_spend_seen, other->is_double_spend_seen);
key = monero_utils::reconcile(key, other->key);
full_hex = monero_utils::reconcile(full_hex, other->full_hex);
pruned_hex = monero_utils::reconcile(pruned_hex, other->pruned_hex);
prunable_hex = monero_utils::reconcile(prunable_hex, other->prunable_hex);
prunable_hash = monero_utils::reconcile(prunable_hash, other->prunable_hash);
size = monero_utils::reconcile(size, other->size, "tx size");
weight = monero_utils::reconcile(weight, other->weight, "tx weight");
m_id = monero_utils::reconcile(m_id, other->m_id);
m_version = monero_utils::reconcile(m_version, other->m_version);
m_payment_id = monero_utils::reconcile(m_payment_id, other->m_payment_id);
m_fee = monero_utils::reconcile(m_fee, other->m_fee, "tx fee");
m_mixin = monero_utils::reconcile(m_mixin, other->m_mixin, "tx m_mixin");
m_is_confirmed = monero_utils::reconcile(m_is_confirmed, other->m_is_confirmed);
m_do_not_relay = monero_utils::reconcile(m_do_not_relay, other->m_do_not_relay);
m_is_relayed = monero_utils::reconcile(m_is_relayed, other->m_is_relayed);
m_is_double_spend_seen = monero_utils::reconcile(m_is_double_spend_seen, other->m_is_double_spend_seen);
m_key = monero_utils::reconcile(m_key, other->m_key);
m_full_hex = monero_utils::reconcile(m_full_hex, other->m_full_hex);
m_pruned_hex = monero_utils::reconcile(m_pruned_hex, other->m_pruned_hex);
m_prunable_hex = monero_utils::reconcile(m_prunable_hex, other->m_prunable_hex);
m_prunable_hash = monero_utils::reconcile(m_prunable_hash, other->m_prunable_hash);
m_size = monero_utils::reconcile(m_size, other->m_size, "tx size");
m_weight = monero_utils::reconcile(m_weight, other->m_weight, "tx weight");
//m_output_indices = monero_utils::reconcile(m_output_indices, other->m_output_indices); // TODO
metadata = monero_utils::reconcile(metadata, other->metadata);
common_tx_sets = monero_utils::reconcile(common_tx_sets, other->common_tx_sets);
//extra = monero_utils::reconcile(extra, other->extra); // TODO
rct_signatures = monero_utils::reconcile(rct_signatures, other->rct_signatures);
rct_sig_prunable = monero_utils::reconcile(rct_sig_prunable, other->rct_sig_prunable);
is_kept_by_block = monero_utils::reconcile(is_kept_by_block, other->is_kept_by_block);
is_failed = monero_utils::reconcile(is_failed, other->is_failed);
last_failed_height = monero_utils::reconcile(last_failed_height, other->last_failed_height, "last_failed_height");
last_failed_id = monero_utils::reconcile(last_failed_id, other->last_failed_id);
max_used_block_height = monero_utils::reconcile(max_used_block_height, other->max_used_block_height, "max_used_block_height");
max_used_block_id = monero_utils::reconcile(max_used_block_id, other->max_used_block_id);
//signatures = monero_utils::reconcile(signatures, other->signatures); // TODO
unlock_time = monero_utils::reconcile(unlock_time, other->unlock_time, "unlock_time");
num_confirmations = monero_utils::reconcile(num_confirmations, other->num_confirmations, "num_confirmations");
m_metadata = monero_utils::reconcile(m_metadata, other->m_metadata);
m_common_tx_sets = monero_utils::reconcile(m_common_tx_sets, other->m_common_tx_sets);
//m_extra = monero_utils::reconcile(m_extra, other->m_extra); // TODO
m_rct_signatures = monero_utils::reconcile(m_rct_signatures, other->m_rct_signatures);
m_rct_sig_prunable = monero_utils::reconcile(m_rct_sig_prunable, other->m_rct_sig_prunable);
m_is_kept_by_block = monero_utils::reconcile(m_is_kept_by_block, other->m_is_kept_by_block);
m_is_failed = monero_utils::reconcile(m_is_failed, other->m_is_failed);
m_last_failed_height = monero_utils::reconcile(m_last_failed_height, other->m_last_failed_height, "m_last_failed_height");
m_last_failed_id = monero_utils::reconcile(m_last_failed_id, other->m_last_failed_id);
m_max_used_block_height = monero_utils::reconcile(m_max_used_block_height, other->m_max_used_block_height, "max_used_block_height");
m_max_used_block_id = monero_utils::reconcile(m_max_used_block_id, other->m_max_used_block_id);
//m_signatures = monero_utils::reconcile(m_signatures, other->m_signatures); // TODO
m_unlock_time = monero_utils::reconcile(m_unlock_time, other->m_unlock_time, "m_unlock_time");
m_num_confirmations = monero_utils::reconcile(m_num_confirmations, other->m_num_confirmations, "m_num_confirmations");
// merge vins
if (!other->vins.empty()) {
for (const shared_ptr<monero_output>& merger : other->vins) {
if (!other->m_vins.empty()) {
for (const shared_ptr<monero_output>& merger : other->m_vins) {
bool merged = false;
merger->tx = self;
for (const shared_ptr<monero_output>& mergee : vins) {
if ((*mergee->key_image)->hex == (*merger->key_image)->hex) {
merger->m_tx = self;
for (const shared_ptr<monero_output>& mergee : m_vins) {
if ((*mergee->m_key_image)->m_hex == (*merger->m_key_image)->m_hex) {
mergee->merge(mergee, merger);
merged = true;
break;
}
}
if (!merged) vins.push_back(merger);
if (!merged) m_vins.push_back(merger);
}
}
// merge vouts
if (!other->vouts.empty()) {
for (const shared_ptr<monero_output>& vout : other->vouts) vout->tx = self;
if (vouts.empty()) vouts = other->vouts;
if (!other->m_vouts.empty()) {
for (const shared_ptr<monero_output>& vout : other->m_vouts) vout->m_tx = self;
if (m_vouts.empty()) m_vouts = other->m_vouts;
else {
// determine if key images present
int numKeyImages = 0;
for (const shared_ptr<monero_output> vout : vouts) {
if (vout->key_image != boost::none) {
if ((*vout->key_image)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
for (const shared_ptr<monero_output> vout : m_vouts) {
if (vout->m_key_image != boost::none) {
if ((*vout->m_key_image)->m_hex == boost::none) throw runtime_error("Key image hex cannot be null");
numKeyImages++;
}
}
for (const shared_ptr<monero_output>& vout : other->vouts) {
if (vout->key_image != boost::none) {
if ((*vout->key_image)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
for (const shared_ptr<monero_output>& vout : other->m_vouts) {
if (vout->m_key_image != boost::none) {
if ((*vout->m_key_image)->m_hex == boost::none) throw runtime_error("Key image hex cannot be null");
numKeyImages++;
}
}
if (numKeyImages != 0 && vouts.size() + other->vouts.size() != numKeyImages) throw runtime_error("Some vouts have a key image and some do not");
if (numKeyImages != 0 && m_vouts.size() + other->m_vouts.size() != numKeyImages) throw runtime_error("Some vouts have a key image and some do not");
// merge by key images
if (numKeyImages > 0) {
for (const shared_ptr<monero_output>& merger : other->vouts) {
for (const shared_ptr<monero_output>& merger : other->m_vouts) {
bool merged = false;
merger->tx = self;
for (const shared_ptr<monero_output>& mergee : vouts) {
if ((*mergee->key_image)->hex == (*merger->key_image)->hex) {
merger->m_tx = self;
for (const shared_ptr<monero_output>& mergee : m_vouts) {
if ((*mergee->m_key_image)->m_hex == (*merger->m_key_image)->m_hex) {
mergee->merge(mergee, merger);
merged = true;
break;
}
}
if (!merged) vouts.push_back(merger);
if (!merged) m_vouts.push_back(merger);
}
}
// merge by position
else {
if (vouts.size() != other->vouts.size()) throw runtime_error("Vout sizes are different");
for (int i = 0; i < other->vouts.size(); i++) {
vouts.at(i)->merge(vouts.at(i), other->vouts.at(i));
if (m_vouts.size() != other->m_vouts.size()) throw runtime_error("Vout sizes are different");
for (int i = 0; i < other->m_vouts.size(); i++) {
m_vouts.at(i)->merge(m_vouts.at(i), other->m_vouts.at(i));
}
}
}
}
// handle unrelayed -> relayed -> confirmed
if (*is_confirmed) {
in_tx_pool = false;
received_timestamp = boost::none;
last_relayed_timestamp = boost::none;
if (*m_is_confirmed) {
m_in_tx_pool = false;
m_received_timestamp = boost::none;
m_last_relayed_timestamp = boost::none;
} else {
in_tx_pool = monero_utils::reconcile(in_tx_pool, other->in_tx_pool, boost::none, true, boost::none); // unrelayed -> tx pool
received_timestamp = monero_utils::reconcile(received_timestamp, other->received_timestamp, boost::none, boost::none, false, "received_timestamp"); // take earliest receive time
last_relayed_timestamp = monero_utils::reconcile(last_relayed_timestamp, other->last_relayed_timestamp, boost::none, boost::none, true, "last_relayed_timestamp"); // take latest relay time
m_in_tx_pool = monero_utils::reconcile(m_in_tx_pool, other->m_in_tx_pool, boost::none, true, boost::none); // unrelayed -> tx pool
m_received_timestamp = monero_utils::reconcile(m_received_timestamp, other->m_received_timestamp, boost::none, boost::none, false, "m_received_timestamp"); // take earliest receive time
m_last_relayed_timestamp = monero_utils::reconcile(m_last_relayed_timestamp, other->m_last_relayed_timestamp, boost::none, boost::none, true, "m_last_relayed_timestamp"); // take latest relay time
}
}
@@ -411,15 +411,15 @@ namespace monero {
shared_ptr<monero_key_image> monero_key_image::copy(const shared_ptr<monero_key_image>& src, const shared_ptr<monero_key_image>& tgt) const {
if (this != src.get()) throw runtime_error("this != src");
tgt->hex = src->hex;
tgt->signature = src->signature;
tgt->m_hex = src->m_hex;
tgt->m_signature = src->m_signature;
return tgt;
}
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);
if (m_hex != boost::none) node.put("hex", *m_hex);
if (m_signature != boost::none) node.put("signature", *m_signature);
return node;
}
@@ -431,22 +431,22 @@ namespace monero {
shared_ptr<monero_output> monero_output::copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const {
if (this != src.get()) throw runtime_error("this != src");
tgt->tx = src->tx; // reference same parent tx by default
if (src->key_image != boost::none) tgt->key_image = src->key_image.get()->copy(src->key_image.get(), make_shared<monero_key_image>());
tgt->amount = src->amount;
tgt->index = src->index;
if (!src->ring_output_indices.empty()) tgt->ring_output_indices = vector<uint64_t>(src->ring_output_indices);
tgt->stealth_public_key = src->stealth_public_key;
tgt->m_tx = src->m_tx; // reference same parent tx by default
if (src->m_key_image != boost::none) tgt->m_key_image = src->m_key_image.get()->copy(src->m_key_image.get(), make_shared<monero_key_image>());
tgt->m_amount = src->m_amount;
tgt->m_index = src->m_index;
if (!src->m_ring_output_indices.empty()) tgt->m_ring_output_indices = vector<uint64_t>(src->m_ring_output_indices);
tgt->m_stealth_public_key = src->m_stealth_public_key;
return tgt;
}
boost::property_tree::ptree monero_output::to_property_tree() const {
boost::property_tree::ptree node;
if (key_image != boost::none) node.add_child("keyImage", (*key_image)->to_property_tree());
if (amount != boost::none) node.put("amount", *amount);
if (index != boost::none) node.put("index", *index);
if (!ring_output_indices.empty()) node.add_child("ringOutputIndices", monero_utils::to_property_tree(ring_output_indices));
if (stealth_public_key != boost::none) node.put("stealthPublicKey", *stealth_public_key);
if (m_key_image != boost::none) node.add_child("keyImage", (*m_key_image)->to_property_tree());
if (m_amount != boost::none) node.put("amount", *m_amount);
if (m_index != boost::none) node.put("index", *m_index);
if (!m_ring_output_indices.empty()) node.add_child("ringOutputIndices", monero_utils::to_property_tree(m_ring_output_indices));
if (m_stealth_public_key != boost::none) node.put("stealthPublicKey", *m_stealth_public_key);
return node;
}
@@ -455,15 +455,15 @@ namespace monero {
if (self == other) return;
// merge txs if they're different which comes back to merging outputs
if (tx != other->tx) {
tx->merge(tx, other->tx);
if (m_tx != other->m_tx) {
m_tx->merge(m_tx, other->m_tx);
return;
}
// otherwise merge output fields
if (key_image == boost::none) key_image = other->key_image;
else if (other->key_image != boost::none) key_image.get()->merge(key_image.get(), other->key_image.get());
amount = monero_utils::reconcile(amount, other->amount, "output amount");
index = monero_utils::reconcile(index, other->index, "output index");
if (m_key_image == boost::none) m_key_image = other->m_key_image;
else if (other->m_key_image != boost::none) m_key_image.get()->merge(m_key_image.get(), other->m_key_image.get());
m_amount = monero_utils::reconcile(m_amount, other->m_amount, "output amount");
m_index = monero_utils::reconcile(m_index, other->m_index, "output index");
}
}
+71 -71
View File
@@ -97,10 +97,10 @@ namespace monero {
* TODO: switch to boost::optional<string>
*/
struct monero_rpc_connection {
string uri;
boost::optional<string> username;
boost::optional<string> password;
monero_rpc_connection(const string& uri = "", const boost::optional<string>& username = boost::none, const boost::optional<string>& password = boost::none) : uri(uri), username(username), password(password) {}
string m_uri;
boost::optional<string> m_username;
boost::optional<string> m_password;
monero_rpc_connection(const string& uri = "", const boost::optional<string>& username = boost::none, const boost::optional<string>& password = boost::none) : m_uri(uri), m_username(username), m_password(password) {}
};
// forward declarations
@@ -113,24 +113,24 @@ namespace monero {
* TODO: a header that is transmitted may have fewer fields like cryptonote::block_header; separate?
*/
struct monero_block_header : public serializable_struct {
boost::optional<string> id;
boost::optional<uint64_t> height;
boost::optional<uint64_t> timestamp;
boost::optional<uint64_t> size;
boost::optional<uint64_t> weight;
boost::optional<uint64_t> long_term_weight;
boost::optional<uint64_t> depth;
boost::optional<uint64_t> difficulty;
boost::optional<uint64_t> cumulative_difficulty;
boost::optional<uint32_t> major_version;
boost::optional<uint32_t> minor_version;
boost::optional<uint64_t> nonce;
boost::optional<string> miner_tx_id;
boost::optional<uint32_t> num_txs;
boost::optional<bool> orphan_status;
boost::optional<string> prev_id;
boost::optional<uint64_t> reward;
boost::optional<string> pow_hash;
boost::optional<string> m_id;
boost::optional<uint64_t> m_height;
boost::optional<uint64_t> m_timestamp;
boost::optional<uint64_t> m_size;
boost::optional<uint64_t> m_weight;
boost::optional<uint64_t> m_long_term_weight;
boost::optional<uint64_t> m_depth;
boost::optional<uint64_t> m_difficulty;
boost::optional<uint64_t> m_cumulative_difficulty;
boost::optional<uint32_t> m_major_version;
boost::optional<uint32_t> m_minor_version;
boost::optional<uint64_t> m_nonce;
boost::optional<string> m_miner_tx_id;
boost::optional<uint32_t> m_num_txs;
boost::optional<bool> m_orphan_status;
boost::optional<string> m_prev_id;
boost::optional<uint64_t> m_reward;
boost::optional<string> m_pow_hash;
boost::property_tree::ptree to_property_tree() const;
virtual void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
@@ -140,10 +140,10 @@ namespace monero {
* Models a Monero block in the blockchain.
*/
struct monero_block : public monero_block_header {
boost::optional<string> hex;
boost::optional<shared_ptr<monero_tx>> miner_tx;
vector<shared_ptr<monero_tx>> txs;
vector<string> tx_ids;
boost::optional<string> m_hex;
boost::optional<shared_ptr<monero_tx>> m_miner_tx;
vector<shared_ptr<monero_tx>> m_txs;
vector<string> m_tx_ids;
boost::property_tree::ptree to_property_tree() const;
void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
@@ -155,44 +155,44 @@ namespace monero {
*/
struct monero_tx : public serializable_struct {
static const string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
boost::optional<shared_ptr<monero_block>> block;
boost::optional<string> id;
boost::optional<uint32_t> version;
boost::optional<bool> is_miner_tx;
boost::optional<string> payment_id;
boost::optional<uint64_t> fee;
boost::optional<uint32_t> mixin;
boost::optional<bool> do_not_relay;
boost::optional<bool> is_relayed;
boost::optional<bool> is_confirmed;
boost::optional<bool> in_tx_pool;
boost::optional<uint64_t> num_confirmations;
boost::optional<uint64_t> unlock_time;
boost::optional<uint64_t> last_relayed_timestamp;
boost::optional<uint64_t> received_timestamp;
boost::optional<bool> is_double_spend_seen;
boost::optional<string> key;
boost::optional<string> full_hex;
boost::optional<string> pruned_hex;
boost::optional<string> prunable_hex;
boost::optional<string> prunable_hash;
boost::optional<uint32_t> size;
boost::optional<uint32_t> weight;
vector<shared_ptr<monero_output>> vins;
vector<shared_ptr<monero_output>> vouts;
boost::optional<shared_ptr<monero_block>> m_block;
boost::optional<string> m_id;
boost::optional<uint32_t> m_version;
boost::optional<bool> m_is_miner_tx;
boost::optional<string> m_payment_id;
boost::optional<uint64_t> m_fee;
boost::optional<uint32_t> m_mixin;
boost::optional<bool> m_do_not_relay;
boost::optional<bool> m_is_relayed;
boost::optional<bool> m_is_confirmed;
boost::optional<bool> m_in_tx_pool;
boost::optional<uint64_t> m_num_confirmations;
boost::optional<uint64_t> m_unlock_time;
boost::optional<uint64_t> m_last_relayed_timestamp;
boost::optional<uint64_t> m_received_timestamp;
boost::optional<bool> m_is_double_spend_seen;
boost::optional<string> m_key;
boost::optional<string> m_full_hex;
boost::optional<string> m_pruned_hex;
boost::optional<string> m_prunable_hex;
boost::optional<string> m_prunable_hash;
boost::optional<uint32_t> m_size;
boost::optional<uint32_t> m_weight;
vector<shared_ptr<monero_output>> m_vins;
vector<shared_ptr<monero_output>> m_vouts;
vector<uint32_t> m_output_indices;
boost::optional<string> metadata;
boost::optional<string> common_tx_sets;
vector<uint8_t> extra;
boost::optional<string> rct_signatures; // TODO: implement
boost::optional<string> rct_sig_prunable; // TODO: implement
boost::optional<bool> is_kept_by_block;
boost::optional<bool> is_failed;
boost::optional<uint32_t> last_failed_height;
boost::optional<string> last_failed_id;
boost::optional<uint32_t> max_used_block_height;
boost::optional<string> max_used_block_id;
vector<string> signatures;
boost::optional<string> m_metadata;
boost::optional<string> m_common_tx_sets;
vector<uint8_t> m_extra;
boost::optional<string> m_rct_signatures; // TODO: implement
boost::optional<string> m_rct_sig_prunable; // TODO: implement
boost::optional<bool> m_is_kept_by_block;
boost::optional<bool> m_is_failed;
boost::optional<uint32_t> m_last_failed_height;
boost::optional<string> m_last_failed_id;
boost::optional<uint32_t> m_max_used_block_height;
boost::optional<string> m_max_used_block_id;
vector<string> m_signatures;
shared_ptr<monero_tx> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
boost::property_tree::ptree to_property_tree() const;
@@ -204,8 +204,8 @@ namespace monero {
* Models a Monero key image.
*/
struct monero_key_image : public serializable_struct {
boost::optional<string> hex;
boost::optional<string> signature;
boost::optional<string> m_hex;
boost::optional<string> m_signature;
shared_ptr<monero_key_image> copy(const shared_ptr<monero_key_image>& src, const shared_ptr<monero_key_image>& tgt) const;
boost::property_tree::ptree to_property_tree() const;
@@ -216,12 +216,12 @@ namespace monero {
* Models a Monero transaction output.
*/
struct monero_output : public serializable_struct {
shared_ptr<monero_tx> tx;
boost::optional<shared_ptr<monero_key_image>> key_image;
boost::optional<uint64_t> amount;
boost::optional<uint64_t> index;
vector<uint64_t> ring_output_indices;
boost::optional<string> stealth_public_key;
shared_ptr<monero_tx> m_tx;
boost::optional<shared_ptr<monero_key_image>> m_key_image;
boost::optional<uint64_t> m_amount;
boost::optional<uint64_t> m_index;
vector<uint64_t> m_ring_output_indices;
boost::optional<string> m_stealth_public_key;
shared_ptr<monero_output> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
boost::property_tree::ptree to_property_tree() const;
+111 -111
View File
@@ -66,45 +66,45 @@ void node_to_transfer(const boost::property_tree::ptree& node, shared_ptr<monero
// initialize transfer from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("accountIndex")) transfer->account_index = it->second.get_value<uint32_t>();
if (key == string("accountIndex")) transfer->m_account_index = it->second.get_value<uint32_t>();
}
}
shared_ptr<monero_transfer_request> node_to_transfer_request(const boost::property_tree::ptree& node) {
shared_ptr<monero_transfer_request> transfer_request = make_shared<monero_transfer_request>();
node_to_transfer(node, transfer_request);
shared_ptr<monero_transfer_request> m_transfer_request = make_shared<monero_transfer_request>();
node_to_transfer(node, m_transfer_request);
// initialize request from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("isIncoming")) transfer_request->is_incoming = it->second.get_value<bool>();
else if (key == string("address")) transfer_request->address = it->second.data();
if (key == string("isIncoming")) m_transfer_request->m_is_incoming = it->second.get_value<bool>();
else if (key == string("address")) m_transfer_request->m_address = it->second.data();
else if (key == string("addresses")) throw runtime_error("addresses not implemented");
else if (key == string("subaddressIndex")) transfer_request->subaddress_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndex")) m_transfer_request->m_subaddress_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndices")) {
vector<uint32_t> subaddress_indices;
for (const auto& child : it->second) subaddress_indices.push_back(child.second.get_value<uint32_t>());
transfer_request->subaddress_indices = subaddress_indices;
vector<uint32_t> m_subaddress_indices;
for (const auto& child : it->second) m_subaddress_indices.push_back(child.second.get_value<uint32_t>());
m_transfer_request->m_subaddress_indices = m_subaddress_indices;
}
else if (key == string("destinations")) throw runtime_error("destinations not implemented");
else if (key == string("hasDestinations")) transfer_request->has_destinations = it->second.get_value<bool>();
else if (key == string("hasDestinations")) m_transfer_request->m_has_destinations = it->second.get_value<bool>();
else if (key == string("txRequest")) throw runtime_error("txRequest not implemented");
}
return transfer_request;
return m_transfer_request;
}
shared_ptr<monero_key_image> node_to_key_image(const boost::property_tree::ptree& node) {
// initialize key image from node
shared_ptr<monero_key_image> key_image = make_shared<monero_key_image>();
shared_ptr<monero_key_image> m_key_image = make_shared<monero_key_image>();
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("hex")) key_image->hex = it->second.data();
else if (key == string("signature")) key_image->signature = it->second.data();
if (key == string("hex")) m_key_image->m_hex = it->second.data();
else if (key == string("signature")) m_key_image->m_signature = it->second.data();
}
return key_image;
return m_key_image;
}
void node_to_output(const boost::property_tree::ptree& node, shared_ptr<monero_output> output) {
@@ -112,9 +112,9 @@ void node_to_output(const boost::property_tree::ptree& node, shared_ptr<monero_o
// initialize output from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("keyImage")) output->key_image = node_to_key_image(it->second);
else if (key == string("amount")) output->amount = it->second.get_value<uint64_t>();
else if (key == string("index")) output->index = it->second.get_value<uint32_t>();
if (key == string("keyImage")) output->m_key_image = node_to_key_image(it->second);
else if (key == string("amount")) output->m_amount = it->second.get_value<uint64_t>();
else if (key == string("index")) output->m_index = it->second.get_value<uint32_t>();
else if (key == string("ringOutputIndices")) throw runtime_error("node_to_tx() deserialize ringOutputIndices not implemented");
else if (key == string("stealthPublicKey")) throw runtime_error("node_to_tx() deserialize stealthPublicKey not implemented");
}
@@ -124,26 +124,26 @@ void node_to_output_wallet(const boost::property_tree::ptree& node, shared_ptr<m
node_to_output(node, output_wallet);
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("accountIndex")) output_wallet->account_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndex")) output_wallet->subaddress_index = it->second.get_value<uint32_t>();
else if (key == string("isSpent")) output_wallet->is_spent = it->second.get_value<bool>();
else if (key == string("isUnlocked")) output_wallet->is_unlocked = it->second.get_value<bool>();
else if (key == string("isFrozen")) output_wallet->is_frozen = it->second.get_value<bool>();
if (key == string("accountIndex")) output_wallet->m_account_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndex")) output_wallet->m_subaddress_index = it->second.get_value<uint32_t>();
else if (key == string("isSpent")) output_wallet->m_is_spent = it->second.get_value<bool>();
else if (key == string("isUnlocked")) output_wallet->m_is_unlocked = it->second.get_value<bool>();
else if (key == string("isFrozen")) output_wallet->m_is_frozen = it->second.get_value<bool>();
}
}
shared_ptr<monero_output_request> node_to_output_request(const boost::property_tree::ptree& node) {
shared_ptr<monero_output_request> output_request = make_shared<monero_output_request>();
node_to_output_wallet(node, output_request);
shared_ptr<monero_output_request> m_output_request = make_shared<monero_output_request>();
node_to_output_wallet(node, m_output_request);
// initialize request from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) output_request->subaddress_indices.push_back(it2->second.get_value<uint32_t>());
if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_output_request->m_subaddress_indices.push_back(it2->second.get_value<uint32_t>());
else if (key == string("txRequest")) {} // ignored
}
return output_request;
return m_output_request;
}
void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
@@ -151,26 +151,26 @@ void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> t
// initialize tx from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("id")) tx->id = it->second.data();
if (key == string("id")) tx->m_id = it->second.data();
else if (key == string("version")) throw runtime_error("version deserializationn not implemented");
else if (key == string("isMinerTx")) tx->is_miner_tx = it->second.get_value<bool>();
else if (key == string("isMinerTx")) tx->m_is_miner_tx = it->second.get_value<bool>();
else if (key == string("paymentId")) throw runtime_error("paymentId deserializationn not implemented");
else if (key == string("fee")) throw runtime_error("fee deserialization not implemented");
else if (key == string("mixin")) throw runtime_error("mixin deserialization not implemented");
else if (key == string("doNotRelay")) tx->do_not_relay = it->second.get_value<bool>();
else if (key == string("isRelayed")) tx->is_relayed = it->second.get_value<bool>();
else if (key == string("isConfirmed")) tx->is_confirmed = it->second.get_value<bool>();
else if (key == string("inTxPool")) tx->in_tx_pool = it->second.get_value<bool>();
else if (key == string("doNotRelay")) tx->m_do_not_relay = it->second.get_value<bool>();
else if (key == string("isRelayed")) tx->m_is_relayed = it->second.get_value<bool>();
else if (key == string("isConfirmed")) tx->m_is_confirmed = it->second.get_value<bool>();
else if (key == string("inTxPool")) tx->m_in_tx_pool = it->second.get_value<bool>();
else if (key == string("numConfirmations")) throw runtime_error("numConfirmations deserialization not implemented");
else if (key == string("unlockTime")) throw runtime_error("unlockTime deserialization not implemented");
else if (key == string("lastRelayedTimestamp")) throw runtime_error("lastRelayedTimestamp deserialization not implemented");
else if (key == string("receivedTimestamp")) throw runtime_error("receivedTimestamp deserializationn not implemented");
else if (key == string("isDoubleSpendSeen")) tx->is_double_spend_seen = it->second.get_value<bool>();
else if (key == string("key")) tx->key = it->second.data();
else if (key == string("fullHex")) tx->full_hex = it->second.data();
else if (key == string("prunedHex")) tx->pruned_hex = it->second.data();
else if (key == string("prunableHex")) tx->prunable_hex = it->second.data();
else if (key == string("prunableHash")) tx->prunable_hash = it->second.data();
else if (key == string("isDoubleSpendSeen")) tx->m_is_double_spend_seen = it->second.get_value<bool>();
else if (key == string("key")) tx->m_key = it->second.data();
else if (key == string("fullHex")) tx->m_full_hex = it->second.data();
else if (key == string("prunedHex")) tx->m_pruned_hex = it->second.data();
else if (key == string("prunableHex")) tx->m_prunable_hex = it->second.data();
else if (key == string("prunableHash")) tx->m_prunable_hash = it->second.data();
else if (key == string("size")) throw runtime_error("size deserialization not implemented");
else if (key == string("weight")) throw runtime_error("weight deserialization not implemented");
else if (key == string("vins")) throw runtime_error("vins deserializationn not implemented");
@@ -181,12 +181,12 @@ void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> t
else if (key == string("extra")) throw runtime_error("extra deserialization not implemented");
else if (key == string("rctSignatures")) throw runtime_error("rctSignatures deserialization not implemented");
else if (key == string("rctSigPrunable")) throw runtime_error("rctSigPrunable deserialization not implemented");
else if (key == string("isKeptByBlock")) tx->is_kept_by_block = it->second.get_value<bool>();
else if (key == string("isFailed")) tx->is_failed = it->second.get_value<bool>();
else if (key == string("isKeptByBlock")) tx->m_is_kept_by_block = it->second.get_value<bool>();
else if (key == string("isFailed")) tx->m_is_failed = it->second.get_value<bool>();
else if (key == string("lastFailedHeight")) throw runtime_error("lastFailedHeight deserialization not implemented");
else if (key == string("lastFailedId")) tx->last_failed_id = it->second.data();
else if (key == string("lastFailedId")) tx->m_last_failed_id = it->second.data();
else if (key == string("maxUsedBlockHeight")) throw runtime_error("maxUsedBlockHeight deserialization not implemented");
else if (key == string("maxUsedBlockId")) tx->max_used_block_id = it->second.data();
else if (key == string("maxUsedBlockId")) tx->m_max_used_block_id = it->second.data();
else if (key == string("signatures")) throw runtime_error("signatures deserialization not implemented");
}
}
@@ -197,31 +197,31 @@ void node_to_tx_wallet(const boost::property_tree::ptree& node, shared_ptr<moner
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
//if (key == string("id")) tx->id = it->second.data();
//if (key == string("id")) tx->m_id = it->second.data();
}
}
shared_ptr<monero_tx_request> node_to_tx_request(const boost::property_tree::ptree& node) {
shared_ptr<monero_tx_request> tx_request = make_shared<monero_tx_request>();
node_to_tx_wallet(node, tx_request);
shared_ptr<monero_tx_request> m_tx_request = make_shared<monero_tx_request>();
node_to_tx_wallet(node, m_tx_request);
// initialize request from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("isOutgoing")) tx_request->is_outgoing = it->second.get_value<bool>();
else if (key == string("isIncoming")) tx_request->is_incoming = it->second.get_value<bool>();
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_request->tx_ids.push_back(it2->second.data());
else if (key == string("hasPaymentId")) tx_request->has_payment_id = it->second.get_value<bool>();
else if (key == string("paymentIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_request->payment_ids.push_back(it2->second.data());
else if (key == string("height")) tx_request->height = it->second.get_value<uint64_t>();
else if (key == string("minHeight")) tx_request->min_height = it->second.get_value<uint64_t>();
else if (key == string("maxHeight")) tx_request->max_height = it->second.get_value<uint64_t>();
else if (key == string("includeOutputs")) tx_request->include_outputs = it->second.get_value<bool>();
else if (key == string("transferRequest")) tx_request->transfer_request = node_to_transfer_request(it->second);
else if (key == string("outputRequest")) tx_request->output_request = node_to_output_request(it->second);
if (key == string("isOutgoing")) m_tx_request->m_is_outgoing = it->second.get_value<bool>();
else if (key == string("isIncoming")) m_tx_request->m_is_incoming = it->second.get_value<bool>();
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_tx_request->m_tx_ids.push_back(it2->second.data());
else if (key == string("hasPaymentId")) m_tx_request->m_has_payment_id = it->second.get_value<bool>();
else if (key == string("paymentIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_tx_request->m_payment_ids.push_back(it2->second.data());
else if (key == string("height")) m_tx_request->m_height = it->second.get_value<uint64_t>();
else if (key == string("minHeight")) m_tx_request->m_min_height = it->second.get_value<uint64_t>();
else if (key == string("maxHeight")) m_tx_request->m_max_height = it->second.get_value<uint64_t>();
else if (key == string("includeOutputs")) m_tx_request->m_include_outputs = it->second.get_value<bool>();
else if (key == string("transferRequest")) m_tx_request->m_transfer_request = node_to_transfer_request(it->second);
else if (key == string("outputRequest")) m_tx_request->m_output_request = node_to_output_request(it->second);
}
return tx_request;
return m_tx_request;
}
shared_ptr<monero_block> node_to_block_request(const boost::property_tree::ptree& node) {
@@ -231,7 +231,7 @@ shared_ptr<monero_block> node_to_block_request(const boost::property_tree::ptree
if (key == string("txs")) {
boost::property_tree::ptree txsNode = it->second;
for (boost::property_tree::ptree::const_iterator it2 = txsNode.begin(); it2 != txsNode.end(); ++it2) {
block->txs.push_back(node_to_tx_request(it2->second));
block->m_txs.push_back(node_to_tx_request(it2->second));
}
}
}
@@ -242,8 +242,8 @@ shared_ptr<monero_destination> node_to_destination(const boost::property_tree::p
shared_ptr<monero_destination> destination = make_shared<monero_destination>();
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();
else if (key == string("amount")) destination->amount = it->second.get_value<uint64_t>();
if (key == string("address")) destination->m_address = it->second.data();
else if (key == string("amount")) destination->m_amount = it->second.get_value<uint64_t>();
}
return destination;
}
@@ -325,7 +325,7 @@ shared_ptr<monero_tx_request> monero_utils::deserialize_tx_request(const string&
shared_ptr<monero_block> block = node_to_block_request(blockNode);
// get tx request
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->txs[0]);
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->m_txs[0]);
// return deserialized request
return tx_request;
@@ -342,17 +342,17 @@ shared_ptr<monero_transfer_request> monero_utils::deserialize_transfer_request(c
shared_ptr<monero_block> block = node_to_block_request(blockNode);
// return mpty request if no txs
if (block->txs.empty()) return make_shared<monero_transfer_request>();
if (block->m_txs.empty()) return make_shared<monero_transfer_request>();
// get tx request
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->txs[0]);
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->m_txs[0]);
// get / create transfer request
shared_ptr<monero_transfer_request> transfer_request = tx_request->transfer_request == boost::none ? make_shared<monero_transfer_request>() : *tx_request->transfer_request;
shared_ptr<monero_transfer_request> transfer_request = tx_request->m_transfer_request == boost::none ? make_shared<monero_transfer_request>() : *tx_request->m_transfer_request;
// transfer request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
transfer_request->tx_request = tx_request;
tx_request->transfer_request = boost::none;
transfer_request->m_tx_request = tx_request;
tx_request->m_transfer_request = boost::none;
// return deserialized request
return transfer_request;
@@ -369,17 +369,17 @@ shared_ptr<monero_output_request> monero_utils::deserialize_output_request(const
shared_ptr<monero_block> block = node_to_block_request(blockNode);
// empty request if no txs
if (block->txs.empty()) return make_shared<monero_output_request>();
if (block->m_txs.empty()) return make_shared<monero_output_request>();
// get tx request
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->txs[0]);
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->m_txs[0]);
// get / create output request
shared_ptr<monero_output_request> output_request = tx_request->output_request == boost::none ? make_shared<monero_output_request>() : *tx_request->output_request;
shared_ptr<monero_output_request> output_request = tx_request->m_output_request == boost::none ? make_shared<monero_output_request>() : *tx_request->m_output_request;
// output request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
output_request->tx_request = tx_request;
tx_request->output_request = boost::none;
output_request->m_tx_request = tx_request;
tx_request->m_output_request = boost::none;
// return deserialized request
return output_request;
@@ -399,24 +399,24 @@ shared_ptr<monero_send_request> monero_utils::deserialize_send_request(const str
if (key == string("destinations")) {
boost::property_tree::ptree destinationsNode = it->second;
for (boost::property_tree::ptree::const_iterator it2 = destinationsNode.begin(); it2 != destinationsNode.end(); ++it2) {
send_request->destinations.push_back(node_to_destination(it2->second));
send_request->m_destinations.push_back(node_to_destination(it2->second));
}
}
else if (key == string("paymentId")) send_request->payment_id = it->second.data();
else if (key == string("paymentId")) send_request->m_payment_id = it->second.data();
else if (key == string("priority")) throw runtime_error("deserialize_send_request() priority not implemented");
else if (key == string("mixin")) send_request->mixin = it->second.get_value<uint32_t>();
else if (key == string("ringSize")) send_request->ring_size = it->second.get_value<uint32_t>();
else if (key == string("fee")) send_request->fee = it->second.get_value<uint64_t>();
else if (key == string("accountIndex")) send_request->account_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) send_request->subaddress_indices.push_back(it2->second.get_value<uint32_t>());
else if (key == string("unlockTime")) send_request->unlock_time = it->second.get_value<uint64_t>();
else if (key == string("canSplit")) send_request->can_split = it->second.get_value<bool>();
else if (key == string("doNotRelay")) send_request->do_not_relay = it->second.get_value<bool>();
else if (key == string("note")) send_request->note = it->second.data();
else if (key == string("recipientName")) send_request->recipient_name = it->second.data();
else if (key == string("belowAmount")) send_request->below_amount = it->second.get_value<uint64_t>();
else if (key == string("sweepEachSubaddress")) send_request->sweep_each_subaddress = it->second.get_value<bool>();
else if (key == string("keyImage")) send_request->key_image = it->second.data();
else if (key == string("mixin")) send_request->m_mixin = it->second.get_value<uint32_t>();
else if (key == string("ringSize")) send_request->m_ring_size = it->second.get_value<uint32_t>();
else if (key == string("fee")) send_request->m_fee = it->second.get_value<uint64_t>();
else if (key == string("accountIndex")) send_request->m_account_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) send_request->m_subaddress_indices.push_back(it2->second.get_value<uint32_t>());
else if (key == string("unlockTime")) send_request->m_unlock_time = it->second.get_value<uint64_t>();
else if (key == string("canSplit")) send_request->m_can_split = it->second.get_value<bool>();
else if (key == string("doNotRelay")) send_request->m_do_not_relay = it->second.get_value<bool>();
else if (key == string("note")) send_request->m_note = it->second.data();
else if (key == string("recipientName")) send_request->m_recipient_name = it->second.data();
else if (key == string("belowAmount")) send_request->m_below_amount = it->second.get_value<uint64_t>();
else if (key == string("sweepEachSubaddress")) send_request->m_sweep_each_subaddress = it->second.get_value<bool>();
else if (key == string("keyImage")) send_request->m_key_image = it->second.data();
}
return send_request;
@@ -495,55 +495,55 @@ shared_ptr<monero_block> monero_utils::cn_block_to_block(const cryptonote::block
cryptonote::block temp = cn_block;
cout << cryptonote::obj_to_json_str(temp) << endl;
shared_ptr<monero_block> block = make_shared<monero_block>();
block->major_version = cn_block.major_version;
block->minor_version = cn_block.minor_version;
block->timestamp = cn_block.timestamp;
block->prev_id = epee::string_tools::pod_to_hex(cn_block.prev_id);
block->nonce = cn_block.nonce;
block->miner_tx = monero_utils::cn_tx_to_tx(cn_block.miner_tx);
block->m_major_version = cn_block.major_version;
block->m_minor_version = cn_block.minor_version;
block->m_timestamp = cn_block.timestamp;
block->m_prev_id = epee::string_tools::pod_to_hex(cn_block.prev_id);
block->m_nonce = cn_block.nonce;
block->m_miner_tx = monero_utils::cn_tx_to_tx(cn_block.miner_tx);
for (const crypto::hash& tx_hash : cn_block.tx_hashes) {
block->tx_ids.push_back(epee::string_tools::pod_to_hex(tx_hash));
block->m_tx_ids.push_back(epee::string_tools::pod_to_hex(tx_hash));
}
return block;
}
shared_ptr<monero_tx> monero_utils::cn_tx_to_tx(const cryptonote::transaction& cn_tx, bool init_as_tx_wallet) {
shared_ptr<monero_tx> tx = init_as_tx_wallet ? make_shared<monero_tx_wallet>() : make_shared<monero_tx>();
tx->version = cn_tx.version;
tx->unlock_time = cn_tx.unlock_time;
tx->id = epee::string_tools::pod_to_hex(cn_tx.hash);
tx->extra = cn_tx.extra;
tx->m_version = cn_tx.version;
tx->m_unlock_time = cn_tx.unlock_time;
tx->m_id = epee::string_tools::pod_to_hex(cn_tx.hash);
tx->m_extra = cn_tx.extra;
// init vins
for (const txin_v& cnVin : cn_tx.vin) {
if (cnVin.which() != 0 && cnVin.which() != 3) throw runtime_error("Unsupported variant type");
if (tx->is_miner_tx == boost::none) tx->is_miner_tx = cnVin.which() == 0;
if (tx->m_is_miner_tx == boost::none) tx->m_is_miner_tx = 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<monero_output> vin = init_as_tx_wallet ? make_shared<monero_output_wallet>() : make_shared<monero_output>();
vin->tx = tx;
tx->vins.push_back(vin);
vin->m_tx = tx;
tx->m_vins.push_back(vin);
const txin_to_key& txin = boost::get<txin_to_key>(cnVin);
vin->amount = txin.amount;
vin->ring_output_indices = txin.key_offsets;
vin->m_amount = txin.amount;
vin->m_ring_output_indices = txin.key_offsets;
crypto::key_image cnKeyImage = txin.k_image;
vin->key_image = make_shared<monero_key_image>();
vin->key_image.get()->hex = epee::string_tools::pod_to_hex(cnKeyImage);
vin->m_key_image = make_shared<monero_key_image>();
vin->m_key_image.get()->m_hex = epee::string_tools::pod_to_hex(cnKeyImage);
}
// init vouts
for (const tx_out& cnVout : cn_tx.vout) {
shared_ptr<monero_output> vout = init_as_tx_wallet ? make_shared<monero_output_wallet>() : make_shared<monero_output>();
vout->tx = tx;
tx->vouts.push_back(vout);
vout->amount = cnVout.amount;
vout->m_tx = tx;
tx->m_vouts.push_back(vout);
vout->m_amount = cnVout.amount;
const crypto::public_key& cnStealthPublicKey = boost::get<txout_to_key>(cnVout.target).key;
vout->stealth_public_key = epee::string_tools::pod_to_hex(cnStealthPublicKey);
vout->m_stealth_public_key = epee::string_tools::pod_to_hex(cnStealthPublicKey);
}
return tx;
// TODO: finish this, cryptonote::transaction has:
// std::vector<std::vector<crypto::signature> > signatures;
// rct::rctSig rct_signatures;
// std::vector<std::vector<crypto::signature> > m_signatures;
// rct::rctSig m_rct_signatures;
// mutable size_t blob_size;
}
File diff suppressed because it is too large Load Diff
+201 -201
View File
@@ -67,7 +67,7 @@ namespace monero {
void merge_incoming_transfer(vector<shared_ptr<monero_incoming_transfer>>& transfers, const shared_ptr<monero_incoming_transfer>& transfer) {
for (const shared_ptr<monero_incoming_transfer>& aTransfer : transfers) {
if (aTransfer->account_index.get() == transfer->account_index.get() && aTransfer->subaddress_index.get() == transfer->subaddress_index.get()) {
if (aTransfer->m_account_index.get() == transfer->m_account_index.get() && aTransfer->m_subaddress_index.get() == transfer->m_subaddress_index.get()) {
aTransfer->merge(aTransfer, transfer);
return;
}
@@ -79,11 +79,11 @@ namespace monero {
boost::property_tree::ptree monero_account::to_property_tree() const {
boost::property_tree::ptree node;
if (index != boost::none) node.put("index", *index);
if (primary_address != boost::none) node.put("primaryAddress", *primary_address);
if (balance != boost::none) node.put("balance", *balance);
if (unlocked_balance != boost::none) node.put("unlockedBalance", *unlocked_balance);
if (!subaddresses.empty()) node.add_child("subaddresses", monero_utils::to_property_tree(subaddresses));
if (m_index != boost::none) node.put("index", *m_index);
if (m_primary_address != boost::none) node.put("primaryAddress", *m_primary_address);
if (m_balance != boost::none) node.put("balance", *m_balance);
if (m_unlocked_balance != boost::none) node.put("unlockedBalance", *m_unlocked_balance);
if (!m_subaddresses.empty()) node.add_child("subaddresses", monero_utils::to_property_tree(m_subaddresses));
return node;
}
@@ -91,15 +91,15 @@ namespace monero {
boost::property_tree::ptree monero_subaddress::to_property_tree() const {
boost::property_tree::ptree node;
if (account_index != boost::none) node.put("accountIndex", *account_index);
if (index != boost::none) node.put("index", *index);
if (address != boost::none) node.put("address", *address);
if (label != boost::none) node.put("label", *label);
if (balance != boost::none) node.put("balance", *balance);
if (unlocked_balance != boost::none) node.put("unlockedBalance", *unlocked_balance);
if (num_unspent_outputs != boost::none) node.put("numUnspentOutputs", *num_unspent_outputs);
if (is_used != boost::none) node.put("isUsed", *is_used);
if (num_blocks_to_unlock != boost::none) node.put("numBlocksToUnlock", *num_blocks_to_unlock);
if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
if (m_index != boost::none) node.put("index", *m_index);
if (m_address != boost::none) node.put("address", *m_address);
if (m_label != boost::none) node.put("label", *m_label);
if (m_balance != boost::none) node.put("balance", *m_balance);
if (m_unlocked_balance != boost::none) node.put("unlockedBalance", *m_unlocked_balance);
if (m_num_unspent_outputs != boost::none) node.put("numUnspentOutputs", *m_num_unspent_outputs);
if (m_is_used != boost::none) node.put("isUsed", *m_is_used);
if (m_num_blocks_to_unlock != boost::none) node.put("numBlocksToUnlock", *m_num_blocks_to_unlock);
return node;
}
@@ -118,38 +118,38 @@ namespace monero {
monero_tx::copy(static_pointer_cast<monero_tx>(src), static_pointer_cast<monero_tx>(tgt));
// copy wallet extensions
if (!src->incoming_transfers.empty()) {
tgt->incoming_transfers = vector<shared_ptr<monero_incoming_transfer>>();
for (const shared_ptr<monero_incoming_transfer>& transfer : src->incoming_transfers) {
if (!src->m_incoming_transfers.empty()) {
tgt->m_incoming_transfers = vector<shared_ptr<monero_incoming_transfer>>();
for (const shared_ptr<monero_incoming_transfer>& transfer : src->m_incoming_transfers) {
shared_ptr<monero_incoming_transfer> transferCopy = transfer->copy(transfer, make_shared<monero_incoming_transfer>());
transferCopy->tx = tgt;
tgt->incoming_transfers.push_back(transferCopy);
transferCopy->m_tx = tgt;
tgt->m_incoming_transfers.push_back(transferCopy);
}
}
if (src->outgoing_transfer != boost::none) {
shared_ptr<monero_outgoing_transfer> transferCopy = src->outgoing_transfer.get()->copy(src->outgoing_transfer.get(), make_shared<monero_outgoing_transfer>());
transferCopy->tx = tgt;
tgt->outgoing_transfer = transferCopy;
if (src->m_outgoing_transfer != boost::none) {
shared_ptr<monero_outgoing_transfer> transferCopy = src->m_outgoing_transfer.get()->copy(src->m_outgoing_transfer.get(), make_shared<monero_outgoing_transfer>());
transferCopy->m_tx = tgt;
tgt->m_outgoing_transfer = transferCopy;
}
tgt->note = src->note;
tgt->m_note = src->m_note;
return tgt;
};
boost::property_tree::ptree monero_tx_wallet::to_property_tree() const {
boost::property_tree::ptree node = monero_tx::to_property_tree();
if (!incoming_transfers.empty()) node.add_child("incomingTransfers", monero_utils::to_property_tree(incoming_transfers));
if (outgoing_transfer != boost::none) node.add_child("outgoingTransfer", (*outgoing_transfer)->to_property_tree());
if (note != boost::none) node.put("note", *note);
if (!m_incoming_transfers.empty()) node.add_child("incomingTransfers", monero_utils::to_property_tree(m_incoming_transfers));
if (m_outgoing_transfer != boost::none) node.add_child("outgoingTransfer", (*m_outgoing_transfer)->to_property_tree());
if (m_note != boost::none) node.put("note", *m_note);
return node;
}
bool monero_tx_wallet::getIsOutgoing() const {
return outgoing_transfer != boost::none;
return m_outgoing_transfer != boost::none;
}
bool monero_tx_wallet::getIsIncoming() const {
return !incoming_transfers.empty();
return !m_incoming_transfers.empty();
}
void monero_tx_wallet::merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other) {
@@ -164,21 +164,21 @@ namespace monero {
monero_tx::merge(self, other);
// merge wallet extensions
note = monero_utils::reconcile(note, other->note);
m_note = monero_utils::reconcile(m_note, other->m_note);
// merge incoming transfers
if (!other->incoming_transfers.empty()) {
for (const shared_ptr<monero_incoming_transfer>& transfer : other->incoming_transfers) { // NOTE: not using reference so shared_ptr is not deleted when tx is dereferenced
transfer->tx = self;
merge_incoming_transfer(self->incoming_transfers, transfer);
if (!other->m_incoming_transfers.empty()) {
for (const shared_ptr<monero_incoming_transfer>& transfer : other->m_incoming_transfers) { // NOTE: not using reference so shared_ptr is not deleted when tx is dereferenced
transfer->m_tx = self;
merge_incoming_transfer(self->m_incoming_transfers, transfer);
}
}
// merge outgoing transfer
if (other->outgoing_transfer != boost::none) {
other->outgoing_transfer.get()->tx = self;
if (self->outgoing_transfer == boost::none) self->outgoing_transfer = other->outgoing_transfer;
else self->outgoing_transfer.get()->merge(self->outgoing_transfer.get(), other->outgoing_transfer.get());
if (other->m_outgoing_transfer != boost::none) {
other->m_outgoing_transfer.get()->m_tx = self;
if (self->m_outgoing_transfer == boost::none) self->m_outgoing_transfer = other->m_outgoing_transfer;
else self->m_outgoing_transfer.get()->merge(self->m_outgoing_transfer.get(), other->m_outgoing_transfer.get());
}
}
@@ -200,32 +200,32 @@ namespace monero {
monero_tx_wallet::copy(static_pointer_cast<monero_tx>(src), static_pointer_cast<monero_tx>(tgt));
// copy request extensions
tgt->is_outgoing = src->is_outgoing;
tgt->is_incoming = src->is_incoming;
if (!src->tx_ids.empty()) tgt->tx_ids = vector<string>(src->tx_ids);
tgt-> has_payment_id = src->has_payment_id;
if (!src->payment_ids.empty()) tgt->payment_ids = vector<string>(src->payment_ids);
tgt->height = src->height;
tgt->min_height = src->min_height;
tgt->max_height = src->max_height;
tgt->include_outputs = src->include_outputs;
if (src->transfer_request != boost::none) tgt->transfer_request = src->transfer_request.get()->copy(src->transfer_request.get(), make_shared<monero_transfer_request>());
if (src->output_request != boost::none) tgt->output_request = src->output_request.get()->copy(src->output_request.get(), make_shared<monero_output_request>());
tgt->m_is_outgoing = src->m_is_outgoing;
tgt->m_is_incoming = src->m_is_incoming;
if (!src->m_tx_ids.empty()) tgt->m_tx_ids = vector<string>(src->m_tx_ids);
tgt-> m_has_payment_id = src->m_has_payment_id;
if (!src->m_payment_ids.empty()) tgt->m_payment_ids = vector<string>(src->m_payment_ids);
tgt->m_height = src->m_height;
tgt->m_min_height = src->m_min_height;
tgt->m_max_height = src->m_max_height;
tgt->m_include_outputs = src->m_include_outputs;
if (src->m_transfer_request != boost::none) tgt->m_transfer_request = src->m_transfer_request.get()->copy(src->m_transfer_request.get(), make_shared<monero_transfer_request>());
if (src->m_output_request != boost::none) tgt->m_output_request = src->m_output_request.get()->copy(src->m_output_request.get(), make_shared<monero_output_request>());
return tgt;
};
boost::property_tree::ptree monero_tx_request::to_property_tree() const {
boost::property_tree::ptree node = monero_tx_wallet::to_property_tree();
if (is_outgoing != boost::none) node.put("isOutgoing", *is_outgoing);
if (is_incoming != boost::none) node.put("isIncoming", *is_incoming);
if (!tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(tx_ids));
if (has_payment_id != boost::none) node.put("hasPaymentId", *has_payment_id);
if (!payment_ids.empty()) node.add_child("paymentIds", monero_utils::to_property_tree(payment_ids));
if (height != boost::none) node.put("height", *height);
if (min_height != boost::none) node.put("minHeight", *min_height);
if (max_height != boost::none) node.put("maxHeight", *max_height);
if (include_outputs != boost::none) node.put("includeOutputs", *include_outputs);
if (transfer_request != boost::none) node.add_child("transferRequest", (*transfer_request)->to_property_tree());
if (m_is_outgoing != boost::none) node.put("isOutgoing", *m_is_outgoing);
if (m_is_incoming != boost::none) node.put("isIncoming", *m_is_incoming);
if (!m_tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(m_tx_ids));
if (m_has_payment_id != boost::none) node.put("hasPaymentId", *m_has_payment_id);
if (!m_payment_ids.empty()) node.add_child("paymentIds", monero_utils::to_property_tree(m_payment_ids));
if (m_height != boost::none) node.put("height", *m_height);
if (m_min_height != boost::none) node.put("minHeight", *m_min_height);
if (m_max_height != boost::none) node.put("maxHeight", *m_max_height);
if (m_include_outputs != boost::none) node.put("includeOutputs", *m_include_outputs);
if (m_transfer_request != boost::none) node.add_child("transferRequest", (*m_transfer_request)->to_property_tree());
return node;
}
@@ -233,21 +233,21 @@ namespace monero {
if (tx == nullptr) return false;
// filter on tx
if (id != boost::none && id != tx->id) return false;
if (payment_id != boost::none && payment_id != tx->payment_id) return false;
if (is_confirmed != boost::none && is_confirmed != tx->is_confirmed) return false;
if (in_tx_pool != boost::none && in_tx_pool != tx->in_tx_pool) return false;
if (do_not_relay != boost::none && do_not_relay != tx->do_not_relay) return false;
if (is_failed != boost::none && is_failed != tx->is_failed) return false;
if (is_miner_tx != boost::none && is_miner_tx != tx->is_miner_tx) return false;
if (m_id != boost::none && m_id != tx->m_id) return false;
if (m_payment_id != boost::none && m_payment_id != tx->m_payment_id) return false;
if (m_is_confirmed != boost::none && m_is_confirmed != tx->m_is_confirmed) return false;
if (m_in_tx_pool != boost::none && m_in_tx_pool != tx->m_in_tx_pool) return false;
if (m_do_not_relay != boost::none && m_do_not_relay != tx->m_do_not_relay) return false;
if (m_is_failed != boost::none && m_is_failed != tx->m_is_failed) return false;
if (m_is_miner_tx != boost::none && m_is_miner_tx != tx->m_is_miner_tx) return false;
// at least one transfer must meet transfer request if defined
if (transfer_request != boost::none) {
if (m_transfer_request != boost::none) {
bool matchFound = false;
if (tx->outgoing_transfer != boost::none && (*transfer_request)->meets_criteria((*tx->outgoing_transfer).get())) matchFound = true;
else if (!tx->incoming_transfers.empty()) {
for (const shared_ptr<monero_incoming_transfer>& incomingTransfer : tx->incoming_transfers) {
if ((*transfer_request)->meets_criteria(incomingTransfer.get())) {
if (tx->m_outgoing_transfer != boost::none && (*m_transfer_request)->meets_criteria((*tx->m_outgoing_transfer).get())) matchFound = true;
else if (!tx->m_incoming_transfers.empty()) {
for (const shared_ptr<monero_incoming_transfer>& incomingTransfer : tx->m_incoming_transfers) {
if ((*m_transfer_request)->meets_criteria(incomingTransfer.get())) {
matchFound = true;
break;
}
@@ -257,24 +257,24 @@ namespace monero {
}
// filter on having a payment id
if (has_payment_id != boost::none) {
if (*has_payment_id && tx->payment_id == boost::none) return false;
if (!*has_payment_id && tx->payment_id != boost::none) return false;
if (m_has_payment_id != boost::none) {
if (*m_has_payment_id && tx->m_payment_id == boost::none) return false;
if (!*m_has_payment_id && tx->m_payment_id != boost::none) return false;
}
// filter on incoming
if (is_incoming != boost::none && is_incoming != tx->getIsIncoming()) return false;
if (m_is_incoming != boost::none && m_is_incoming != tx->getIsIncoming()) return false;
// filter on outgoing
if (is_outgoing != boost::none && is_outgoing != tx->getIsOutgoing()) return false;
if (m_is_outgoing != boost::none && m_is_outgoing != tx->getIsOutgoing()) return false;
// filter on remaining fields
boost::optional<uint64_t> txHeight = tx->get_height();
if (!tx_ids.empty() && find(tx_ids.begin(), tx_ids.end(), *tx->id) == tx_ids.end()) return false;
if (!payment_ids.empty() && (tx->payment_id == boost::none || find(payment_ids.begin(), payment_ids.end(), *tx->payment_id) == payment_ids.end())) return false;
if (height != boost::none && (txHeight == boost::none || *txHeight != *height)) return false;
if (min_height != boost::none && (txHeight == boost::none || *txHeight < *min_height)) return false;
if (max_height != boost::none && (txHeight == boost::none || *txHeight > *max_height)) return false;
if (!m_tx_ids.empty() && find(m_tx_ids.begin(), m_tx_ids.end(), *tx->m_id) == m_tx_ids.end()) return false;
if (!m_payment_ids.empty() && (tx->m_payment_id == boost::none || find(m_payment_ids.begin(), m_payment_ids.end(), *tx->m_payment_id) == m_payment_ids.end())) return false;
if (m_height != boost::none && (txHeight == boost::none || *txHeight != *m_height)) return false;
if (m_min_height != boost::none && (txHeight == boost::none || *txHeight < *m_min_height)) return false;
if (m_max_height != boost::none && (txHeight == boost::none || *txHeight > *m_max_height)) return false;
// transaction meets request criteria
return true;
@@ -285,15 +285,15 @@ namespace monero {
shared_ptr<monero_destination> monero_destination::copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const {
MTRACE("monero_destination::copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt)");
if (this != src.get()) throw runtime_error("this != src");
tgt->address = src->address;
tgt->amount = src->amount;
tgt->m_address = src->m_address;
tgt->m_amount = src->m_amount;
return tgt;
};
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);
if (m_address != boost::none) node.put("address", *m_address);
if (m_amount != boost::none) node.put("amount", *m_amount);
return node;
}
@@ -301,18 +301,18 @@ namespace monero {
shared_ptr<monero_transfer> monero_transfer::copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const {
MTRACE("monero_transfer::copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt)");
tgt->tx = src->tx; // reference parent tx by default
tgt->amount = src->amount;
tgt->account_index = src->account_index;
tgt->num_suggested_confirmations = src->num_suggested_confirmations;
tgt->m_tx = src->m_tx; // reference parent tx by default
tgt->m_amount = src->m_amount;
tgt->m_account_index = src->m_account_index;
tgt->m_num_suggested_confirmations = src->m_num_suggested_confirmations;
return tgt;
}
boost::property_tree::ptree monero_transfer::to_property_tree() const {
boost::property_tree::ptree node;
if (amount != boost::none) node.put("amount", *amount);
if (account_index != boost::none) node.put("accountIndex", *account_index);
if (num_suggested_confirmations != boost::none) node.put("numSuggestedConfirmations", *num_suggested_confirmations);
if (m_amount != boost::none) node.put("amount", *m_amount);
if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
if (m_num_suggested_confirmations != boost::none) node.put("numSuggestedConfirmations", *m_num_suggested_confirmations);
return node;
}
@@ -321,22 +321,22 @@ namespace monero {
if (self == other) return;
// merge txs if they're different which comes back to merging transfers
if (tx != other->tx) {
tx->merge(tx, other->tx);
if (m_tx != other->m_tx) {
m_tx->merge(m_tx, other->m_tx);
return;
}
// otherwise merge transfer fields
account_index = monero_utils::reconcile(account_index, other->account_index, "acountIndex");
m_account_index = monero_utils::reconcile(m_account_index, other->m_account_index, "acountIndex");
// TODO monero core: failed tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount/num_suggested_confirmations of 0
if (amount != boost::none && other->amount != boost::none && *amount != *other->amount && (*amount == 0 || *other->amount == 0)) {
account_index = monero_utils::reconcile(account_index, other->account_index, boost::none, boost::none, true, "acountIndex");
num_suggested_confirmations = monero_utils::reconcile(num_suggested_confirmations, other->num_suggested_confirmations, boost::none, boost::none, true, "num_suggested_confirmations");
MWARNING("WARNING: failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/num_suggested_confirmations of 0");
// TODO monero core: failed m_tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount/m_num_suggested_confirmations of 0
if (m_amount != boost::none && other->m_amount != boost::none && *m_amount != *other->m_amount && (*m_amount == 0 || *other->m_amount == 0)) {
m_account_index = monero_utils::reconcile(m_account_index, other->m_account_index, boost::none, boost::none, true, "acountIndex");
m_num_suggested_confirmations = monero_utils::reconcile(m_num_suggested_confirmations, other->m_num_suggested_confirmations, boost::none, boost::none, true, "m_num_suggested_confirmations");
MWARNING("WARNING: failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/m_num_suggested_confirmations of 0");
} else {
amount = monero_utils::reconcile(amount, other->amount, "transfer amount");
num_suggested_confirmations = monero_utils::reconcile(num_suggested_confirmations, other->num_suggested_confirmations, boost::none, boost::none, false, "num_suggested_confirmations");
m_amount = monero_utils::reconcile(m_amount, other->m_amount, "transfer amount");
m_num_suggested_confirmations = monero_utils::reconcile(m_num_suggested_confirmations, other->m_num_suggested_confirmations, boost::none, boost::none, false, "m_num_suggested_confirmations");
}
}
@@ -357,8 +357,8 @@ namespace monero {
boost::property_tree::ptree monero_incoming_transfer::to_property_tree() const {
boost::property_tree::ptree node = monero_transfer::to_property_tree();
if (subaddress_index != boost::none) node.put("subaddressIndex", *subaddress_index);
if (address != boost::none) node.put("address", *address);
if (m_subaddress_index != boost::none) node.put("subaddressIndex", *m_subaddress_index);
if (m_address != boost::none) node.put("address", *m_address);
return node;
}
@@ -369,8 +369,8 @@ namespace monero {
void monero_incoming_transfer::merge(const shared_ptr<monero_incoming_transfer>& self, const shared_ptr<monero_incoming_transfer>& other) {
if (self == other) return;
monero_transfer::merge(self, other);
subaddress_index = monero_utils::reconcile(subaddress_index, other->subaddress_index, "incoming transfer subaddress_index");
address = monero_utils::reconcile(address, other->address);
m_subaddress_index = monero_utils::reconcile(m_subaddress_index, other->m_subaddress_index, "incoming transfer m_subaddress_index");
m_address = monero_utils::reconcile(m_address, other->m_address);
}
// ----------------------- MONERO OUTGOING TRANSFER -------------------------
@@ -387,9 +387,9 @@ namespace monero {
boost::property_tree::ptree monero_outgoing_transfer::to_property_tree() const {
boost::property_tree::ptree node = monero_transfer::to_property_tree();
if (!subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddress_indices));
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));
if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
if (!m_addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(m_addresses));
if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations));
return node;
}
@@ -400,9 +400,9 @@ namespace monero {
void monero_outgoing_transfer::merge(const shared_ptr<monero_outgoing_transfer>& self, const shared_ptr<monero_outgoing_transfer>& other) {
if (self == other) return;
monero_transfer::merge(self, other);
subaddress_indices = monero_utils::reconcile(subaddress_indices, other->subaddress_indices);
addresses = monero_utils::reconcile(addresses, other->addresses);
destinations = monero_utils::reconcile(destinations, other->destinations);
m_subaddress_indices = monero_utils::reconcile(m_subaddress_indices, other->m_subaddress_indices);
m_addresses = monero_utils::reconcile(m_addresses, other->m_addresses);
m_destinations = monero_utils::reconcile(m_destinations, other->m_destinations);
}
// ----------------------- MONERO TRANSFER REQUEST --------------------------
@@ -419,53 +419,53 @@ namespace monero {
monero_transfer::copy(static_pointer_cast<monero_transfer>(src), static_pointer_cast<monero_transfer>(tgt));
// copy extensions
tgt->is_incoming = src->is_incoming;
tgt->address = src->address;
if (!src->addresses.empty()) tgt->addresses = vector<string>(src->addresses);
tgt->subaddress_index = src->subaddress_index;
if (!src->subaddress_indices.empty()) tgt->subaddress_indices = vector<uint32_t>(src->subaddress_indices);
if (!src->destinations.empty()) {
for (const shared_ptr<monero_destination>& destination : src->destinations) {
tgt->destinations.push_back(destination->copy(destination, make_shared<monero_destination>()));
tgt->m_is_incoming = src->m_is_incoming;
tgt->m_address = src->m_address;
if (!src->m_addresses.empty()) tgt->m_addresses = vector<string>(src->m_addresses);
tgt->m_subaddress_index = src->m_subaddress_index;
if (!src->m_subaddress_indices.empty()) tgt->m_subaddress_indices = vector<uint32_t>(src->m_subaddress_indices);
if (!src->m_destinations.empty()) {
for (const shared_ptr<monero_destination>& destination : src->m_destinations) {
tgt->m_destinations.push_back(destination->copy(destination, make_shared<monero_destination>()));
}
}
tgt->has_destinations = src->has_destinations;
tgt->tx_request = src->tx_request;
tgt->m_has_destinations = src->m_has_destinations;
tgt->m_tx_request = src->m_tx_request;
return tgt;
};
boost::optional<bool> monero_transfer_request::getIsIncoming() const { return is_incoming; }
boost::optional<bool> monero_transfer_request::getIsIncoming() const { return m_is_incoming; }
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 (subaddress_index != boost::none) node.put("subaddressIndex", *subaddress_index);
if (has_destinations != boost::none) node.put("hasDestinations", *has_destinations);
if (!subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddress_indices));
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));
if (m_address != boost::none) node.put("address", *m_address);
if (m_subaddress_index != boost::none) node.put("subaddressIndex", *m_subaddress_index);
if (m_has_destinations != boost::none) node.put("hasDestinations", *m_has_destinations);
if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
if (!m_addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(m_addresses));
if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations));
return node;
}
bool monero_transfer_request::meets_criteria(monero_transfer* transfer) const {
if (transfer == nullptr) throw runtime_error("transfer is null");
if (tx_request != boost::none && (*tx_request)->transfer_request != 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
if (m_tx_request != boost::none && (*m_tx_request)->m_transfer_request != 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
// filter on common fields
if (getIsIncoming() != boost::none && *getIsIncoming() != *transfer->getIsIncoming()) return false;
if (getIsOutgoing() != boost::none && getIsOutgoing() != transfer->getIsOutgoing()) return false;
if (amount != boost::none && *amount != *transfer->amount) return false;
if (account_index != boost::none && *account_index != *transfer->account_index) return false;
if (m_amount != boost::none && *m_amount != *transfer->m_amount) return false;
if (m_account_index != boost::none && *m_account_index != *transfer->m_account_index) return false;
// filter on incoming fields
monero_incoming_transfer* inTransfer = dynamic_cast<monero_incoming_transfer*>(transfer);
if (inTransfer != nullptr) {
if (has_destinations != boost::none) return false;
if (address != boost::none && *address != *inTransfer->address) return false;
if (!addresses.empty() && find(addresses.begin(), addresses.end(), *inTransfer->address) == addresses.end()) return false;
if (subaddress_index != boost::none && *subaddress_index != *inTransfer->subaddress_index) return false;
if (!subaddress_indices.empty() && find(subaddress_indices.begin(), subaddress_indices.end(), *inTransfer->subaddress_index) == subaddress_indices.end()) return false;
if (m_has_destinations != boost::none) return false;
if (m_address != boost::none && *m_address != *inTransfer->m_address) return false;
if (!m_addresses.empty() && find(m_addresses.begin(), m_addresses.end(), *inTransfer->m_address) == m_addresses.end()) return false;
if (m_subaddress_index != boost::none && *m_subaddress_index != *inTransfer->m_subaddress_index) return false;
if (!m_subaddress_indices.empty() && find(m_subaddress_indices.begin(), m_subaddress_indices.end(), *inTransfer->m_subaddress_index) == m_subaddress_indices.end()) return false;
}
// filter on outgoing fields
@@ -473,11 +473,11 @@ namespace monero {
if (out_transfer != nullptr) {
// filter on addresses
if (address != boost::none && (out_transfer->addresses.empty() || find(out_transfer->addresses.begin(), out_transfer->addresses.end(), *address) == out_transfer->addresses.end())) return false; // TODO: will filter all transfers if they don't contain addresses
if (!addresses.empty()) {
if (m_address != boost::none && (out_transfer->m_addresses.empty() || find(out_transfer->m_addresses.begin(), out_transfer->m_addresses.end(), *m_address) == out_transfer->m_addresses.end())) return false; // TODO: will filter all transfers if they don't contain addresses
if (!m_addresses.empty()) {
bool intersects = false;
for (const string& addressReq : addresses) {
for (const string& address : out_transfer->addresses) {
for (const string& addressReq : m_addresses) {
for (const string& address : out_transfer->m_addresses) {
if (addressReq == address) {
intersects = true;
break;
@@ -488,12 +488,12 @@ namespace monero {
}
// filter on subaddress indices
if (subaddress_index != boost::none && (out_transfer->subaddress_indices.empty() || find(out_transfer->subaddress_indices.begin(), out_transfer->subaddress_indices.end(), *subaddress_index) == out_transfer->subaddress_indices.end())) return false; // TODO: will filter all transfers if they don't contain subaddress indices
if (!subaddress_indices.empty()) {
if (m_subaddress_index != boost::none && (out_transfer->m_subaddress_indices.empty() || find(out_transfer->m_subaddress_indices.begin(), out_transfer->m_subaddress_indices.end(), *m_subaddress_index) == out_transfer->m_subaddress_indices.end())) return false; // TODO: will filter all transfers if they don't contain subaddress indices
if (!m_subaddress_indices.empty()) {
bool intersects = false;
for (const uint32_t& subaddressIndexReq : subaddress_indices) {
for (const uint32_t& subaddress_index : out_transfer->subaddress_indices) {
if (subaddressIndexReq == subaddress_index) {
for (const uint32_t& subaddressIndexReq : m_subaddress_indices) {
for (const uint32_t& m_subaddress_index : out_transfer->m_subaddress_indices) {
if (subaddressIndexReq == m_subaddress_index) {
intersects = true;
break;
}
@@ -503,9 +503,9 @@ namespace monero {
}
// filter on having destinations
if (has_destinations != boost::none) {
if (*has_destinations && out_transfer->destinations.empty()) return false;
if (!*has_destinations && !out_transfer->destinations.empty()) return false;
if (m_has_destinations != boost::none) {
if (*m_has_destinations && out_transfer->m_destinations.empty()) return false;
if (!*m_has_destinations && !out_transfer->m_destinations.empty()) return false;
}
// filter on destinations TODO: start with test for this
@@ -516,7 +516,7 @@ namespace monero {
if (inTransfer == nullptr && out_transfer == nullptr) throw runtime_error("Transfer must be monero_incoming_transfer or monero_outgoing_transfer");
// filter with tx request
if (tx_request != boost::none && !(*tx_request)->meets_criteria(transfer->tx.get())) return false;
if (m_tx_request != boost::none && !(*m_tx_request)->meets_criteria(transfer->m_tx.get())) return false;
return true;
}
@@ -535,21 +535,21 @@ namespace monero {
monero_output::copy(static_pointer_cast<monero_output>(src), static_pointer_cast<monero_output>(tgt));
// copy extensions
tgt->account_index = src->account_index;
tgt->subaddress_index = src->subaddress_index;
tgt->is_spent = src->is_spent;
tgt->is_unlocked = src->is_unlocked;
tgt->is_frozen = src->is_frozen;
tgt->m_account_index = src->m_account_index;
tgt->m_subaddress_index = src->m_subaddress_index;
tgt->m_is_spent = src->m_is_spent;
tgt->m_is_unlocked = src->m_is_unlocked;
tgt->m_is_frozen = src->m_is_frozen;
return tgt;
};
boost::property_tree::ptree monero_output_wallet::to_property_tree() const {
boost::property_tree::ptree node = monero_output::to_property_tree();
if (account_index != boost::none) node.put("accountIndex", *account_index);
if (subaddress_index != boost::none) node.put("subaddressIndex", *subaddress_index);
if (is_spent != boost::none) node.put("isSpent", *is_spent);
if (is_unlocked != boost::none) node.put("isUnlocked", *is_unlocked);
if (is_frozen != boost::none) node.put("isFrozen", *is_frozen);
if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
if (m_subaddress_index != boost::none) node.put("subaddressIndex", *m_subaddress_index);
if (m_is_spent != boost::none) node.put("isSpent", *m_is_spent);
if (m_is_unlocked != boost::none) node.put("isUnlocked", *m_is_unlocked);
if (m_is_frozen != boost::none) node.put("isFrozen", *m_is_frozen);
return node;
}
@@ -579,37 +579,37 @@ namespace monero {
monero_output_wallet::copy(static_pointer_cast<monero_output>(src), static_pointer_cast<monero_output>(tgt));
// copy extensions
if (!src->subaddress_indices.empty()) tgt->subaddress_indices = vector<uint32_t>(src->subaddress_indices);
if (!src->m_subaddress_indices.empty()) tgt->m_subaddress_indices = vector<uint32_t>(src->m_subaddress_indices);
return tgt;
};
boost::property_tree::ptree monero_output_request::to_property_tree() const {
boost::property_tree::ptree node = monero_output_wallet::to_property_tree();
if (!subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddress_indices));
if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
return node;
}
bool monero_output_request::meets_criteria(monero_output_wallet* output) const {
// filter on output
if (account_index != boost::none && *account_index != *output->account_index) return false;
if (subaddress_index != boost::none && *subaddress_index != *output->subaddress_index) return false;
if (amount != boost::none && *amount != *output->amount) return false;
if (is_spent != boost::none && *is_spent != *output->is_spent) return false;
if (is_unlocked != boost::none && *is_unlocked != *output->is_unlocked) return false;
if (m_account_index != boost::none && *m_account_index != *output->m_account_index) return false;
if (m_subaddress_index != boost::none && *m_subaddress_index != *output->m_subaddress_index) return false;
if (m_amount != boost::none && *m_amount != *output->m_amount) return false;
if (m_is_spent != boost::none && *m_is_spent != *output->m_is_spent) return false;
if (m_is_unlocked != boost::none && *m_is_unlocked != *output->m_is_unlocked) return false;
// filter on output key image
if (key_image != boost::none) {
if (output->key_image == boost::none) return false;
if ((*key_image)->hex != boost::none && ((*output->key_image)->hex == boost::none || *(*key_image)->hex != *(*output->key_image)->hex)) return false;
if ((*key_image)->signature != boost::none && ((*output->key_image)->signature == boost::none || *(*key_image)->signature != *(*output->key_image)->signature)) return false;
if (m_key_image != boost::none) {
if (output->m_key_image == boost::none) return false;
if ((*m_key_image)->m_hex != boost::none && ((*output->m_key_image)->m_hex == boost::none || *(*m_key_image)->m_hex != *(*output->m_key_image)->m_hex)) return false;
if ((*m_key_image)->m_signature != boost::none && ((*output->m_key_image)->m_signature == boost::none || *(*m_key_image)->m_signature != *(*output->m_key_image)->m_signature)) return false;
}
// filter on extensions
if (!subaddress_indices.empty() && find(subaddress_indices.begin(), subaddress_indices.end(), *output->subaddress_index) == subaddress_indices.end()) return false;
if (!m_subaddress_indices.empty() && find(m_subaddress_indices.begin(), m_subaddress_indices.end(), *output->m_subaddress_index) == m_subaddress_indices.end()) return false;
// filter with tx request
if (tx_request != boost::none && !(*tx_request)->meets_criteria(static_pointer_cast<monero_tx_wallet>(output->tx).get())) return false;
if (m_tx_request != boost::none && !(*m_tx_request)->meets_criteria(static_pointer_cast<monero_tx_wallet>(output->m_tx).get())) return false;
// output meets request
return true;
@@ -619,21 +619,21 @@ namespace monero {
boost::property_tree::ptree monero_send_request::to_property_tree() const {
boost::property_tree::ptree node;
if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations));
if (payment_id != boost::none) node.put("paymentId", *payment_id);
if (priority != boost::none) node.put("priority", *priority);
if (mixin != boost::none) node.put("mixin", *mixin);
if (ring_size != boost::none) node.put("ringSize", *ring_size);
if (account_index != boost::none) node.put("accountIndex", *account_index);
if (!subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddress_indices));
if (unlock_time != boost::none) node.put("unlockTime", *unlock_time);
if (can_split != boost::none) node.put("canSplit", *can_split);
if (do_not_relay != boost::none) node.put("doNotRelay", *do_not_relay);
if (note != boost::none) node.put("note", *note);
if (recipient_name != boost::none) node.put("recipientName", *recipient_name);
if (below_amount != boost::none) node.put("belowAmount", *below_amount);
if (sweep_each_subaddress != boost::none) node.put("sweepEachSubaddress", *sweep_each_subaddress);
if (key_image != boost::none) node.put("keyImage", *key_image);
if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations));
if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id);
if (m_priority != boost::none) node.put("priority", *m_priority);
if (m_mixin != boost::none) node.put("m_mixin", *m_mixin);
if (m_ring_size != boost::none) node.put("ringSize", *m_ring_size);
if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
if (m_unlock_time != boost::none) node.put("unlockTime", *m_unlock_time);
if (m_can_split != boost::none) node.put("canSplit", *m_can_split);
if (m_do_not_relay != boost::none) node.put("doNotRelay", *m_do_not_relay);
if (m_note != boost::none) node.put("note", *m_note);
if (m_recipient_name != boost::none) node.put("recipientName", *m_recipient_name);
if (m_below_amount != boost::none) node.put("belowAmount", *m_below_amount);
if (m_sweep_each_subaddress != boost::none) node.put("sweepEachSubaddress", *m_sweep_each_subaddress);
if (m_key_image != boost::none) node.put("keyImage", *m_key_image);
return node;
}
@@ -641,9 +641,9 @@ namespace monero {
boost::property_tree::ptree monero_integrated_address::to_property_tree() const {
boost::property_tree::ptree node;
node.put("standardAddress", standard_address);
node.put("paymentId", payment_id);
node.put("integratedAddress", integrated_address);
node.put("standardAddress", m_standard_address);
node.put("paymentId", m_payment_id);
node.put("integratedAddress", m_integrated_address);
return node;
}
@@ -651,9 +651,9 @@ namespace monero {
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 (spent_amount != boost::none) node.put("spentAmount", *spent_amount);
if (unspent_amount != boost::none) node.put("unspentAmount", *unspent_amount);
if (m_height != boost::none) node.put("height", *m_height);
if (m_spent_amount != boost::none) node.put("spentAmount", *m_spent_amount);
if (m_unspent_amount != boost::none) node.put("unspentAmount", *m_unspent_amount);
return node;
}
@@ -661,7 +661,7 @@ namespace monero {
boost::property_tree::ptree monero_check::to_property_tree() const {
boost::property_tree::ptree node;
node.put("isGood", is_good);
node.put("isGood", m_is_good);
return node;
}
@@ -669,9 +669,9 @@ namespace monero {
boost::property_tree::ptree monero_check_tx::to_property_tree() const {
boost::property_tree::ptree node = monero_check::to_property_tree();;
if (in_tx_pool != boost::none) node.put("inTxPool", *in_tx_pool);
if (num_confirmations != boost::none) node.put("numConfirmations", *num_confirmations);
if (received_amount != boost::none) node.put("receivedAmount", *received_amount);
if (m_in_tx_pool != boost::none) node.put("inTxPool", *m_in_tx_pool);
if (m_num_confirmations != boost::none) node.put("numConfirmations", *m_num_confirmations);
if (m_received_amount != boost::none) node.put("receivedAmount", *m_received_amount);
return node;
}
@@ -679,8 +679,8 @@ namespace monero {
boost::property_tree::ptree monero_check_reserve::to_property_tree() const {
boost::property_tree::ptree node = monero_check::to_property_tree();
if (total_amount != boost::none) node.put("totalAmount", *total_amount);
if (unconfirmed_spent_amount != boost::none) node.put("unconfirmedSpentAmount", *unconfirmed_spent_amount);
if (m_total_amount != boost::none) node.put("totalAmount", *m_total_amount);
if (m_unconfirmed_spent_amount != boost::none) node.put("unconfirmedSpentAmount", *m_unconfirmed_spent_amount);
return node;
}
}
+93 -93
View File
@@ -66,35 +66,35 @@ namespace monero {
* Models a result of syncing a wallet.
*/
struct monero_sync_result {
uint64_t num_blocks_fetched;
bool received_money;
uint64_t m_num_blocks_fetched;
bool m_received_money;
monero_sync_result() {}
monero_sync_result(const uint64_t num_blocks_fetched, const bool received_money) : num_blocks_fetched(num_blocks_fetched), received_money(received_money) {}
monero_sync_result(const uint64_t num_blocks_fetched, const bool received_money) : m_num_blocks_fetched(num_blocks_fetched), m_received_money(received_money) {}
};
/**
* Models a Monero subaddress.
*/
struct monero_subaddress : public serializable_struct {
boost::optional<uint32_t> account_index;
boost::optional<uint32_t> index;
boost::optional<string> address;
boost::optional<string> label;
boost::optional<uint64_t> balance;
boost::optional<uint64_t> unlocked_balance;
boost::optional<uint32_t> num_unspent_outputs;
boost::optional<bool> is_used;
boost::optional<uint32_t> num_blocks_to_unlock;
boost::optional<uint32_t> m_account_index;
boost::optional<uint32_t> m_index;
boost::optional<string> m_address;
boost::optional<string> m_label;
boost::optional<uint64_t> m_balance;
boost::optional<uint64_t> m_unlocked_balance;
boost::optional<uint32_t> m_num_unspent_outputs;
boost::optional<bool> m_is_used;
boost::optional<uint32_t> m_num_blocks_to_unlock;
// BEGIN_KV_SERIALIZE_MAP()
// KV_SERIALIZE(account_index)
// KV_SERIALIZE(m_account_index)
// KV_SERIALIZE(index)
// KV_SERIALIZE(address)
// KV_SERIALIZE(label)
// KV_SERIALIZE(balance)
// KV_SERIALIZE(unlocked_balance)
// KV_SERIALIZE(num_unspent_outputs)
// KV_SERIALIZE(is_used)
// KV_SERIALIZE(num_blocks_to_unlock)
// KV_SERIALIZE(m_unlocked_balance)
// KV_SERIALIZE(m_num_unspent_outputs)
// KV_SERIALIZE(m_is_used)
// KV_SERIALIZE(m_num_blocks_to_unlock)
// END_KV_SERIALIZE_MAP()
boost::property_tree::ptree to_property_tree() const;
@@ -105,18 +105,18 @@ namespace monero {
* Models a Monero account.
*/
struct monero_account : public serializable_struct {
boost::optional<uint32_t> index;
boost::optional<string> primary_address;
boost::optional<uint64_t> balance;
boost::optional<uint64_t> unlocked_balance;
boost::optional<string> tag;
vector<monero_subaddress> subaddresses;
boost::optional<uint32_t> m_index;
boost::optional<string> m_primary_address;
boost::optional<uint64_t> m_balance;
boost::optional<uint64_t> m_unlocked_balance;
boost::optional<string> m_tag;
vector<monero_subaddress> m_subaddresses;
// BEGIN_KV_SERIALIZE_MAP()
// KV_SERIALIZE(index)
// KV_SERIALIZE(primary_address)
// KV_SERIALIZE(m_primary_address)
// KV_SERIALIZE(label)
// KV_SERIALIZE(balance)
// KV_SERIALIZE(unlocked_balance)
// KV_SERIALIZE(m_unlocked_balance)
// KV_SERIALIZE(tag)
// KV_SERIALIZE(subaddresses)
// END_KV_SERIALIZE_MAP()
@@ -132,8 +132,8 @@ namespace monero {
* Models an outgoing transfer destination.
*/
struct monero_destination {
boost::optional<string> address;
boost::optional<uint64_t> amount;
boost::optional<string> m_address;
boost::optional<uint64_t> m_amount;
shared_ptr<monero_destination> copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const;
boost::property_tree::ptree to_property_tree() const;
@@ -143,10 +143,10 @@ namespace monero {
* Models a base transfer of funds to or from the wallet.
*/
struct monero_transfer : serializable_struct {
shared_ptr<monero_tx_wallet> tx;
boost::optional<uint64_t> amount;
boost::optional<uint32_t> account_index;
boost::optional<uint32_t> num_suggested_confirmations;
shared_ptr<monero_tx_wallet> m_tx;
boost::optional<uint64_t> m_amount;
boost::optional<uint32_t> m_account_index;
boost::optional<uint32_t> m_num_suggested_confirmations;
virtual boost::optional<bool> getIsIncoming() const = 0; // derived class must implement
shared_ptr<monero_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
@@ -162,8 +162,8 @@ namespace monero {
* Models an incoming transfer of funds to the wallet.
*/
struct monero_incoming_transfer : public monero_transfer {
boost::optional<uint32_t> subaddress_index;
boost::optional<string> address;
boost::optional<uint32_t> m_subaddress_index;
boost::optional<string> m_address;
shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_incoming_transfer>& src, const shared_ptr<monero_incoming_transfer>& tgt) const;
@@ -177,9 +177,9 @@ namespace monero {
* Models an outgoing transfer of funds from the wallet.
*/
struct monero_outgoing_transfer : public monero_transfer {
vector<uint32_t> subaddress_indices;
vector<string> addresses;
vector<shared_ptr<monero_destination>> destinations;
vector<uint32_t> m_subaddress_indices;
vector<string> m_addresses;
vector<shared_ptr<monero_destination>> m_destinations;
shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_outgoing_transfer>& src, const shared_ptr<monero_outgoing_transfer>& tgt) const;
@@ -195,14 +195,14 @@ namespace monero {
* All transfers are returned except those that do not meet the criteria defined in this request.
*/
struct monero_transfer_request : public monero_transfer {
boost::optional<bool> is_incoming;
boost::optional<string> address;
vector<string> addresses;
boost::optional<uint32_t> subaddress_index;
vector<uint32_t> subaddress_indices;
vector<shared_ptr<monero_destination>> destinations;
boost::optional<bool> has_destinations;
boost::optional<shared_ptr<monero_tx_request>> tx_request;
boost::optional<bool> m_is_incoming;
boost::optional<string> m_address;
vector<string> m_addresses;
boost::optional<uint32_t> m_subaddress_index;
vector<uint32_t> m_subaddress_indices;
vector<shared_ptr<monero_destination>> m_destinations;
boost::optional<bool> m_has_destinations;
boost::optional<shared_ptr<monero_tx_request>> m_tx_request;
shared_ptr<monero_transfer_request> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
shared_ptr<monero_transfer_request> copy(const shared_ptr<monero_transfer_request>& src, const shared_ptr<monero_transfer_request>& tgt) const;
@@ -215,11 +215,11 @@ namespace monero {
* Models a Monero output with wallet extensions.
*/
struct monero_output_wallet : public monero_output {
boost::optional<uint32_t> account_index;
boost::optional<uint32_t> subaddress_index;
boost::optional<bool> is_spent;
boost::optional<bool> is_unlocked;
boost::optional<bool> is_frozen;
boost::optional<uint32_t> m_account_index;
boost::optional<uint32_t> m_subaddress_index;
boost::optional<bool> m_is_spent;
boost::optional<bool> m_is_unlocked;
boost::optional<bool> m_is_frozen;
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
@@ -235,8 +235,8 @@ namespace monero {
* All outputs are returned except those that do not meet the criteria defined in this request.
*/
struct monero_output_request : public monero_output_wallet {
vector<uint32_t> subaddress_indices;
boost::optional<shared_ptr<monero_tx_request>> tx_request;
vector<uint32_t> m_subaddress_indices;
boost::optional<shared_ptr<monero_tx_request>> m_tx_request;
// TODO: necessary to override all super classes?
shared_ptr<monero_output_request> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
@@ -250,9 +250,9 @@ namespace monero {
* Models a Monero transaction in the context of a wallet.
*/
struct monero_tx_wallet : public monero_tx {
vector<shared_ptr<monero_incoming_transfer>> incoming_transfers;
boost::optional<shared_ptr<monero_outgoing_transfer>> outgoing_transfer;
boost::optional<string> note;
vector<shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
boost::optional<shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
boost::optional<string> m_note;
shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
@@ -269,17 +269,17 @@ namespace monero {
* All transactions are returned except those that do not meet the criteria defined in this request.
*/
struct monero_tx_request : public monero_tx_wallet {
boost::optional<bool> is_outgoing;
boost::optional<bool> is_incoming;
vector<string> tx_ids;
boost::optional<bool> has_payment_id;
vector<string> payment_ids;
boost::optional<uint64_t> height;
boost::optional<uint64_t> min_height;
boost::optional<uint64_t> max_height;
boost::optional<uint64_t> include_outputs;
boost::optional<shared_ptr<monero_transfer_request>> transfer_request;
boost::optional<shared_ptr<monero_output_request>> output_request;
boost::optional<bool> m_is_outgoing;
boost::optional<bool> m_is_incoming;
vector<string> m_tx_ids;
boost::optional<bool> m_has_payment_id;
vector<string> m_payment_ids;
boost::optional<uint64_t> m_height;
boost::optional<uint64_t> m_min_height;
boost::optional<uint64_t> m_max_height;
boost::optional<uint64_t> m_include_outputs;
boost::optional<shared_ptr<monero_transfer_request>> m_transfer_request;
boost::optional<shared_ptr<monero_output_request>> m_output_request;
// TODO: necessary to override all super classes?
shared_ptr<monero_tx_request> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
@@ -293,9 +293,9 @@ namespace monero {
* Monero integrated address model.
*/
struct monero_integrated_address : public serializable_struct {
string standard_address;
string payment_id;
string integrated_address;
string m_standard_address;
string m_payment_id;
string m_integrated_address;
boost::property_tree::ptree to_property_tree() const;
};
@@ -314,22 +314,22 @@ namespace monero {
* Configures a request to send/sweep funds or create a payment URI.
*/
struct monero_send_request : public serializable_struct {
vector<shared_ptr<monero_destination>> destinations;
boost::optional<string> payment_id;
boost::optional<monero_send_priority> priority;
boost::optional<uint32_t> mixin;
boost::optional<uint32_t> ring_size;
boost::optional<uint64_t> fee;
boost::optional<uint32_t> account_index;
vector<uint32_t> subaddress_indices;
boost::optional<uint64_t> unlock_time;
boost::optional<bool> can_split;
boost::optional<bool> do_not_relay;
boost::optional<string> note;
boost::optional<string> recipient_name;
boost::optional<uint64_t> below_amount;
boost::optional<bool> sweep_each_subaddress;
boost::optional<string> key_image;
vector<shared_ptr<monero_destination>> m_destinations;
boost::optional<string> m_payment_id;
boost::optional<monero_send_priority> m_priority;
boost::optional<uint32_t> m_mixin;
boost::optional<uint32_t> m_ring_size;
boost::optional<uint64_t> m_fee;
boost::optional<uint32_t> m_account_index;
vector<uint32_t> m_subaddress_indices;
boost::optional<uint64_t> m_unlock_time;
boost::optional<bool> m_can_split;
boost::optional<bool> m_do_not_relay;
boost::optional<string> m_note;
boost::optional<string> m_recipient_name;
boost::optional<uint64_t> m_below_amount;
boost::optional<bool> m_sweep_each_subaddress;
boost::optional<string> m_key_image;
boost::property_tree::ptree to_property_tree() const;
};
@@ -338,9 +338,9 @@ namespace monero {
* Models results from importing key images.
*/
struct monero_key_image_import_result : public serializable_struct {
boost::optional<uint64_t> height;
boost::optional<uint64_t> spent_amount;
boost::optional<uint64_t> unspent_amount;
boost::optional<uint64_t> m_height;
boost::optional<uint64_t> m_spent_amount;
boost::optional<uint64_t> m_unspent_amount;
boost::property_tree::ptree to_property_tree() const;
};
@@ -349,7 +349,7 @@ namespace monero {
* Base class for results from checking a transaction or reserve proof.
*/
struct monero_check : public serializable_struct {
bool is_good;
bool m_is_good;
boost::property_tree::ptree to_property_tree() const;
};
@@ -358,9 +358,9 @@ namespace monero {
* Results from checking a transaction key.
*/
struct monero_check_tx : public monero_check {
boost::optional<bool> in_tx_pool;
boost::optional<uint64_t> num_confirmations;
boost::optional<uint64_t> received_amount;
boost::optional<bool> m_in_tx_pool;
boost::optional<uint64_t> m_num_confirmations;
boost::optional<uint64_t> m_received_amount;
boost::property_tree::ptree to_property_tree() const;
};
@@ -369,8 +369,8 @@ namespace monero {
* Results from checking a reserve proof.
*/
struct monero_check_reserve : public monero_check {
boost::optional<uint64_t> total_amount;
boost::optional<uint64_t> unconfirmed_spent_amount;
boost::optional<uint64_t> m_total_amount;
boost::optional<uint64_t> m_unconfirmed_spent_amount;
boost::property_tree::ptree to_property_tree() const;
};