diff --git a/src/daemon/monero_daemon_model.cpp b/src/daemon/monero_daemon_model.cpp index d2e75ce..3ec5f4c 100644 --- a/src/daemon/monero_daemon_model.cpp +++ b/src/daemon/monero_daemon_model.cpp @@ -65,7 +65,7 @@ namespace monero { void merge_tx(vector>& txs, const shared_ptr& tx) { for (const shared_ptr& 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& self, const shared_ptr& 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 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 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::copy(const shared_ptr& src, const shared_ptr& tgt) const { MTRACE("monero_tx::copy(const shared_ptr& src, const shared_ptr& tgt)"); - tgt->id = src->id; - tgt->version = src->version; - tgt->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>(); - for (const shared_ptr& 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>(); + for (const shared_ptr& vin : src->m_vins) { shared_ptr vinCopy = vin->copy(vin, make_shared()); - 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>(); - for (const shared_ptr& vout : src->vouts) { + if (!src->m_vouts.empty()) { + tgt->m_vouts = vector>(); + for (const shared_ptr& vout : src->m_vouts) { shared_ptr voutCopy = vout->copy(vout, make_shared()); - 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(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(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(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 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& self, const shared_ptr& 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(); - 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(); + 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(); - 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(); + 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& merger : other->vins) { + if (!other->m_vins.empty()) { + for (const shared_ptr& merger : other->m_vins) { bool merged = false; - merger->tx = self; - for (const shared_ptr& mergee : vins) { - if ((*mergee->key_image)->hex == (*merger->key_image)->hex) { + merger->m_tx = self; + for (const shared_ptr& 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& vout : other->vouts) vout->tx = self; - if (vouts.empty()) vouts = other->vouts; + if (!other->m_vouts.empty()) { + for (const shared_ptr& 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 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 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& 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& 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& merger : other->vouts) { + for (const shared_ptr& merger : other->m_vouts) { bool merged = false; - merger->tx = self; - for (const shared_ptr& mergee : vouts) { - if ((*mergee->key_image)->hex == (*merger->key_image)->hex) { + merger->m_tx = self; + for (const shared_ptr& 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::copy(const shared_ptr& src, const shared_ptr& tgt) const { if (this != src.get()) throw runtime_error("this != src"); - tgt->hex = src->hex; - tgt->signature = src->signature; + 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::copy(const shared_ptr& src, const shared_ptr& tgt) const { if (this != src.get()) throw runtime_error("this != src"); - tgt->tx = src->tx; // reference same parent tx by default - if (src->key_image != boost::none) tgt->key_image = src->key_image.get()->copy(src->key_image.get(), make_shared()); - tgt->amount = src->amount; - tgt->index = src->index; - if (!src->ring_output_indices.empty()) tgt->ring_output_indices = vector(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()); + 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(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"); } } diff --git a/src/daemon/monero_daemon_model.h b/src/daemon/monero_daemon_model.h index 107c6b7..8c881a0 100644 --- a/src/daemon/monero_daemon_model.h +++ b/src/daemon/monero_daemon_model.h @@ -97,10 +97,10 @@ namespace monero { * TODO: switch to boost::optional */ struct monero_rpc_connection { - string uri; - boost::optional username; - boost::optional password; - monero_rpc_connection(const string& uri = "", const boost::optional& username = boost::none, const boost::optional& password = boost::none) : uri(uri), username(username), password(password) {} + string m_uri; + boost::optional m_username; + boost::optional m_password; + monero_rpc_connection(const string& uri = "", const boost::optional& username = boost::none, const boost::optional& 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 id; - boost::optional height; - boost::optional timestamp; - boost::optional size; - boost::optional weight; - boost::optional long_term_weight; - boost::optional depth; - boost::optional difficulty; - boost::optional cumulative_difficulty; - boost::optional major_version; - boost::optional minor_version; - boost::optional nonce; - boost::optional miner_tx_id; - boost::optional num_txs; - boost::optional orphan_status; - boost::optional prev_id; - boost::optional reward; - boost::optional pow_hash; + boost::optional m_id; + boost::optional m_height; + boost::optional m_timestamp; + boost::optional m_size; + boost::optional m_weight; + boost::optional m_long_term_weight; + boost::optional m_depth; + boost::optional m_difficulty; + boost::optional m_cumulative_difficulty; + boost::optional m_major_version; + boost::optional m_minor_version; + boost::optional m_nonce; + boost::optional m_miner_tx_id; + boost::optional m_num_txs; + boost::optional m_orphan_status; + boost::optional m_prev_id; + boost::optional m_reward; + boost::optional m_pow_hash; boost::property_tree::ptree to_property_tree() const; virtual void merge(const shared_ptr& self, const shared_ptr& other); @@ -140,10 +140,10 @@ namespace monero { * Models a Monero block in the blockchain. */ struct monero_block : public monero_block_header { - boost::optional hex; - boost::optional> miner_tx; - vector> txs; - vector tx_ids; + boost::optional m_hex; + boost::optional> m_miner_tx; + vector> m_txs; + vector m_tx_ids; boost::property_tree::ptree to_property_tree() const; void merge(const shared_ptr& self, const shared_ptr& 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> block; - boost::optional id; - boost::optional version; - boost::optional is_miner_tx; - boost::optional payment_id; - boost::optional fee; - boost::optional mixin; - boost::optional do_not_relay; - boost::optional is_relayed; - boost::optional is_confirmed; - boost::optional in_tx_pool; - boost::optional num_confirmations; - boost::optional unlock_time; - boost::optional last_relayed_timestamp; - boost::optional received_timestamp; - boost::optional is_double_spend_seen; - boost::optional key; - boost::optional full_hex; - boost::optional pruned_hex; - boost::optional prunable_hex; - boost::optional prunable_hash; - boost::optional size; - boost::optional weight; - vector> vins; - vector> vouts; + boost::optional> m_block; + boost::optional m_id; + boost::optional m_version; + boost::optional m_is_miner_tx; + boost::optional m_payment_id; + boost::optional m_fee; + boost::optional m_mixin; + boost::optional m_do_not_relay; + boost::optional m_is_relayed; + boost::optional m_is_confirmed; + boost::optional m_in_tx_pool; + boost::optional m_num_confirmations; + boost::optional m_unlock_time; + boost::optional m_last_relayed_timestamp; + boost::optional m_received_timestamp; + boost::optional m_is_double_spend_seen; + boost::optional m_key; + boost::optional m_full_hex; + boost::optional m_pruned_hex; + boost::optional m_prunable_hex; + boost::optional m_prunable_hash; + boost::optional m_size; + boost::optional m_weight; + vector> m_vins; + vector> m_vouts; vector m_output_indices; - boost::optional metadata; - boost::optional common_tx_sets; - vector extra; - boost::optional rct_signatures; // TODO: implement - boost::optional rct_sig_prunable; // TODO: implement - boost::optional is_kept_by_block; - boost::optional is_failed; - boost::optional last_failed_height; - boost::optional last_failed_id; - boost::optional max_used_block_height; - boost::optional max_used_block_id; - vector signatures; + boost::optional m_metadata; + boost::optional m_common_tx_sets; + vector m_extra; + boost::optional m_rct_signatures; // TODO: implement + boost::optional m_rct_sig_prunable; // TODO: implement + boost::optional m_is_kept_by_block; + boost::optional m_is_failed; + boost::optional m_last_failed_height; + boost::optional m_last_failed_id; + boost::optional m_max_used_block_height; + boost::optional m_max_used_block_id; + vector m_signatures; shared_ptr copy(const shared_ptr& src, const shared_ptr& 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 hex; - boost::optional signature; + boost::optional m_hex; + boost::optional m_signature; shared_ptr copy(const shared_ptr& src, const shared_ptr& 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 tx; - boost::optional> key_image; - boost::optional amount; - boost::optional index; - vector ring_output_indices; - boost::optional stealth_public_key; + shared_ptr m_tx; + boost::optional> m_key_image; + boost::optional m_amount; + boost::optional m_index; + vector m_ring_output_indices; + boost::optional m_stealth_public_key; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; boost::property_tree::ptree to_property_tree() const; diff --git a/src/utils/monero_utils.cpp b/src/utils/monero_utils.cpp index 9f17f14..6d0872c 100644 --- a/src/utils/monero_utils.cpp +++ b/src/utils/monero_utils.cpp @@ -66,45 +66,45 @@ void node_to_transfer(const boost::property_tree::ptree& node, shared_ptrfirst; - if (key == string("accountIndex")) transfer->account_index = it->second.get_value(); + if (key == string("accountIndex")) transfer->m_account_index = it->second.get_value(); } } shared_ptr node_to_transfer_request(const boost::property_tree::ptree& node) { - shared_ptr transfer_request = make_shared(); - node_to_transfer(node, transfer_request); + shared_ptr m_transfer_request = make_shared(); + 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(); - 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(); + 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(); + else if (key == string("subaddressIndex")) m_transfer_request->m_subaddress_index = it->second.get_value(); else if (key == string("subaddressIndices")) { - vector subaddress_indices; - for (const auto& child : it->second) subaddress_indices.push_back(child.second.get_value()); - transfer_request->subaddress_indices = subaddress_indices; + vector m_subaddress_indices; + for (const auto& child : it->second) m_subaddress_indices.push_back(child.second.get_value()); + 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(); + else if (key == string("hasDestinations")) m_transfer_request->m_has_destinations = it->second.get_value(); else if (key == string("txRequest")) throw runtime_error("txRequest not implemented"); } - return transfer_request; + return m_transfer_request; } shared_ptr node_to_key_image(const boost::property_tree::ptree& node) { // initialize key image from node - shared_ptr key_image = make_shared(); + shared_ptr m_key_image = make_shared(); 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 output) { @@ -112,9 +112,9 @@ void node_to_output(const boost::property_tree::ptree& node, shared_ptrfirst; - if (key == string("keyImage")) output->key_image = node_to_key_image(it->second); - else if (key == string("amount")) output->amount = it->second.get_value(); - else if (key == string("index")) output->index = it->second.get_value(); + 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(); + else if (key == string("index")) output->m_index = it->second.get_value(); 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_ptrfirst; - if (key == string("accountIndex")) output_wallet->account_index = it->second.get_value(); - else if (key == string("subaddressIndex")) output_wallet->subaddress_index = it->second.get_value(); - else if (key == string("isSpent")) output_wallet->is_spent = it->second.get_value(); - else if (key == string("isUnlocked")) output_wallet->is_unlocked = it->second.get_value(); - else if (key == string("isFrozen")) output_wallet->is_frozen = it->second.get_value(); + if (key == string("accountIndex")) output_wallet->m_account_index = it->second.get_value(); + else if (key == string("subaddressIndex")) output_wallet->m_subaddress_index = it->second.get_value(); + else if (key == string("isSpent")) output_wallet->m_is_spent = it->second.get_value(); + else if (key == string("isUnlocked")) output_wallet->m_is_unlocked = it->second.get_value(); + else if (key == string("isFrozen")) output_wallet->m_is_frozen = it->second.get_value(); } } shared_ptr node_to_output_request(const boost::property_tree::ptree& node) { - shared_ptr output_request = make_shared(); - node_to_output_wallet(node, output_request); + shared_ptr m_output_request = make_shared(); + 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()); + 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()); 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 tx) { @@ -151,26 +151,26 @@ void node_to_tx(const boost::property_tree::ptree& node, shared_ptr 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(); + else if (key == string("isMinerTx")) tx->m_is_miner_tx = it->second.get_value(); 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(); - else if (key == string("isRelayed")) tx->is_relayed = it->second.get_value(); - else if (key == string("isConfirmed")) tx->is_confirmed = it->second.get_value(); - else if (key == string("inTxPool")) tx->in_tx_pool = it->second.get_value(); + else if (key == string("doNotRelay")) tx->m_do_not_relay = it->second.get_value(); + else if (key == string("isRelayed")) tx->m_is_relayed = it->second.get_value(); + else if (key == string("isConfirmed")) tx->m_is_confirmed = it->second.get_value(); + else if (key == string("inTxPool")) tx->m_in_tx_pool = it->second.get_value(); 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(); - 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(); + 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 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(); - else if (key == string("isFailed")) tx->is_failed = it->second.get_value(); + else if (key == string("isKeptByBlock")) tx->m_is_kept_by_block = it->second.get_value(); + else if (key == string("isFailed")) tx->m_is_failed = it->second.get_value(); 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_ptrfirst; - //if (key == string("id")) tx->id = it->second.data(); + //if (key == string("id")) tx->m_id = it->second.data(); } } shared_ptr node_to_tx_request(const boost::property_tree::ptree& node) { - shared_ptr tx_request = make_shared(); - node_to_tx_wallet(node, tx_request); + shared_ptr m_tx_request = make_shared(); + 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(); - else if (key == string("isIncoming")) tx_request->is_incoming = it->second.get_value(); - 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(); - 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(); - else if (key == string("minHeight")) tx_request->min_height = it->second.get_value(); - else if (key == string("maxHeight")) tx_request->max_height = it->second.get_value(); - else if (key == string("includeOutputs")) tx_request->include_outputs = it->second.get_value(); - 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(); + else if (key == string("isIncoming")) m_tx_request->m_is_incoming = it->second.get_value(); + 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(); + 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(); + else if (key == string("minHeight")) m_tx_request->m_min_height = it->second.get_value(); + else if (key == string("maxHeight")) m_tx_request->m_max_height = it->second.get_value(); + else if (key == string("includeOutputs")) m_tx_request->m_include_outputs = it->second.get_value(); + 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 node_to_block_request(const boost::property_tree::ptree& node) { @@ -231,7 +231,7 @@ shared_ptr 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 node_to_destination(const boost::property_tree::p shared_ptr destination = make_shared(); for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { string key = it->first; - if (key == string("address")) destination->address = it->second.data(); - else if (key == string("amount")) destination->amount = it->second.get_value(); + if (key == string("address")) destination->m_address = it->second.data(); + else if (key == string("amount")) destination->m_amount = it->second.get_value(); } return destination; } @@ -325,7 +325,7 @@ shared_ptr monero_utils::deserialize_tx_request(const string& shared_ptr block = node_to_block_request(blockNode); // get tx request - shared_ptr tx_request = static_pointer_cast(block->txs[0]); + shared_ptr tx_request = static_pointer_cast(block->m_txs[0]); // return deserialized request return tx_request; @@ -342,17 +342,17 @@ shared_ptr monero_utils::deserialize_transfer_request(c shared_ptr block = node_to_block_request(blockNode); // return mpty request if no txs - if (block->txs.empty()) return make_shared(); + if (block->m_txs.empty()) return make_shared(); // get tx request - shared_ptr tx_request = static_pointer_cast(block->txs[0]); + shared_ptr tx_request = static_pointer_cast(block->m_txs[0]); // get / create transfer request - shared_ptr transfer_request = tx_request->transfer_request == boost::none ? make_shared() : *tx_request->transfer_request; + shared_ptr transfer_request = tx_request->m_transfer_request == boost::none ? make_shared() : *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_utils::deserialize_output_request(const shared_ptr block = node_to_block_request(blockNode); // empty request if no txs - if (block->txs.empty()) return make_shared(); + if (block->m_txs.empty()) return make_shared(); // get tx request - shared_ptr tx_request = static_pointer_cast(block->txs[0]); + shared_ptr tx_request = static_pointer_cast(block->m_txs[0]); // get / create output request - shared_ptr output_request = tx_request->output_request == boost::none ? make_shared() : *tx_request->output_request; + shared_ptr output_request = tx_request->m_output_request == boost::none ? make_shared() : *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_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(); - else if (key == string("ringSize")) send_request->ring_size = it->second.get_value(); - else if (key == string("fee")) send_request->fee = it->second.get_value(); - else if (key == string("accountIndex")) send_request->account_index = it->second.get_value(); - 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()); - else if (key == string("unlockTime")) send_request->unlock_time = it->second.get_value(); - else if (key == string("canSplit")) send_request->can_split = it->second.get_value(); - else if (key == string("doNotRelay")) send_request->do_not_relay = it->second.get_value(); - 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(); - else if (key == string("sweepEachSubaddress")) send_request->sweep_each_subaddress = it->second.get_value(); - 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(); + else if (key == string("ringSize")) send_request->m_ring_size = it->second.get_value(); + else if (key == string("fee")) send_request->m_fee = it->second.get_value(); + else if (key == string("accountIndex")) send_request->m_account_index = it->second.get_value(); + 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()); + else if (key == string("unlockTime")) send_request->m_unlock_time = it->second.get_value(); + else if (key == string("canSplit")) send_request->m_can_split = it->second.get_value(); + else if (key == string("doNotRelay")) send_request->m_do_not_relay = it->second.get_value(); + 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(); + else if (key == string("sweepEachSubaddress")) send_request->m_sweep_each_subaddress = it->second.get_value(); + else if (key == string("keyImage")) send_request->m_key_image = it->second.data(); } return send_request; @@ -495,55 +495,55 @@ shared_ptr monero_utils::cn_block_to_block(const cryptonote::block cryptonote::block temp = cn_block; cout << cryptonote::obj_to_json_str(temp) << endl; shared_ptr block = make_shared(); - 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_utils::cn_tx_to_tx(const cryptonote::transaction& cn_tx, bool init_as_tx_wallet) { shared_ptr tx = init_as_tx_wallet ? make_shared() : make_shared(); - 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 vin = init_as_tx_wallet ? make_shared() : make_shared(); - 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(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(); - vin->key_image.get()->hex = epee::string_tools::pod_to_hex(cnKeyImage); + vin->m_key_image = make_shared(); + 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 vout = init_as_tx_wallet ? make_shared() : make_shared(); - 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(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 > signatures; -// rct::rctSig rct_signatures; +// std::vector > m_signatures; +// rct::rctSig m_rct_signatures; // mutable size_t blob_size; } diff --git a/src/wallet/monero_wallet.cpp b/src/wallet/monero_wallet.cpp index 812eab7..510bea4 100644 --- a/src/wallet/monero_wallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -85,52 +85,52 @@ namespace monero { return opt_val == boost::none ? false : val == *opt_val; } - shared_ptr build_tx_with_incoming_transfer(const tools::wallet2& w2, uint64_t height, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) { + shared_ptr build_tx_with_incoming_transfer(const tools::wallet2& w2, uint64_t height, const crypto::hash &m_payment_id, const tools::wallet2::payment_details &pd) { // construct block shared_ptr block = make_shared(); - block->height = pd.m_block_height; - block->timestamp = pd.m_timestamp; + block->m_height = pd.m_block_height; + block->m_timestamp = pd.m_timestamp; // construct tx shared_ptr tx = make_shared(); - tx->block = block; - block->txs.push_back(tx); - tx->id = string_tools::pod_to_hex(pd.m_tx_hash); - tx->payment_id = string_tools::pod_to_hex(payment_id); - if (tx->payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->payment_id = tx->payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->payment_id = boost::none; // clear default payment id - tx->unlock_time = pd.m_unlock_time; - tx->fee = pd.m_fee; - tx->note = w2.get_tx_note(pd.m_tx_hash); - if (tx->note->empty()) tx->note = boost::none; // clear empty note - tx->is_miner_tx = pd.m_coinbase ? true : false; - tx->is_confirmed = true; - tx->is_failed = false; - tx->is_relayed = true; - tx->in_tx_pool = false; - tx->do_not_relay = false; - tx->is_double_spend_seen = false; + tx->m_block = block; + block->m_txs.push_back(tx); + tx->m_id = string_tools::pod_to_hex(pd.m_tx_hash); + tx->m_payment_id = string_tools::pod_to_hex(m_payment_id); + if (tx->m_payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->m_payment_id = tx->m_payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet + if (tx->m_payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->m_payment_id = boost::none; // clear default payment id + tx->m_unlock_time = pd.m_unlock_time; + tx->m_fee = pd.m_fee; + tx->m_note = w2.get_tx_note(pd.m_tx_hash); + if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note + tx->m_is_miner_tx = pd.m_coinbase ? true : false; + tx->m_is_confirmed = true; + tx->m_is_failed = false; + tx->m_is_relayed = true; + tx->m_in_tx_pool = false; + tx->m_do_not_relay = false; + tx->m_is_double_spend_seen = false; - // compute num_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 + // compute m_num_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 // TODO: factor out this duplicate code with build_tx_with_outgoing_transfer() - if (*block->height >= height || (*block->height == 0 && !*tx->in_tx_pool)) tx->num_confirmations = 0; - else tx->num_confirmations = height - *block->height; + if (*block->m_height >= height || (*block->m_height == 0 && !*tx->m_in_tx_pool)) tx->m_num_confirmations = 0; + else tx->m_num_confirmations = height - *block->m_height; // construct transfer shared_ptr incoming_transfer = make_shared(); - incoming_transfer->tx = tx; - tx->incoming_transfers.push_back(incoming_transfer); - incoming_transfer->amount = pd.m_amount; - incoming_transfer->account_index = pd.m_subaddr_index.major; - incoming_transfer->subaddress_index = pd.m_subaddr_index.minor; - incoming_transfer->address = w2.get_subaddress_as_str(pd.m_subaddr_index); + incoming_transfer->m_tx = tx; + tx->m_incoming_transfers.push_back(incoming_transfer); + incoming_transfer->m_amount = pd.m_amount; + incoming_transfer->m_account_index = pd.m_subaddr_index.major; + incoming_transfer->m_subaddress_index = pd.m_subaddr_index.minor; + incoming_transfer->m_address = w2.get_subaddress_as_str(pd.m_subaddr_index); - // compute num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 `set_confirmations` but it should be encapsulated in wallet2 + // compute m_num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 `set_confirmations` but it should be encapsulated in wallet2 // TODO: factor out this duplicate code with build_tx_with_outgoing_transfer() uint64_t block_reward = w2.get_last_block_reward(); - if (block_reward == 0) incoming_transfer->num_suggested_confirmations = 0; - else incoming_transfer->num_suggested_confirmations = (*incoming_transfer->amount + block_reward - 1) / block_reward; + if (block_reward == 0) incoming_transfer->m_num_suggested_confirmations = 0; + else incoming_transfer->m_num_suggested_confirmations = (*incoming_transfer->m_amount + block_reward - 1) / block_reward; // return pointer to new tx return tx; @@ -140,109 +140,109 @@ namespace monero { // construct block shared_ptr block = make_shared(); - block->height = pd.m_block_height; - block->timestamp = pd.m_timestamp; + block->m_height = pd.m_block_height; + block->m_timestamp = pd.m_timestamp; // construct tx shared_ptr tx = make_shared(); - tx->block = block; - block->txs.push_back(tx); - tx->id = string_tools::pod_to_hex(txid); - tx->payment_id = string_tools::pod_to_hex(pd.m_payment_id); - if (tx->payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->payment_id = tx->payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->payment_id = boost::none; // clear default payment id - tx->unlock_time = pd.m_unlock_time; - tx->fee = pd.m_amount_in - pd.m_amount_out; - tx->note = w2.get_tx_note(txid); - if (tx->note->empty()) tx->note = boost::none; // clear empty note - tx->is_miner_tx = false; - tx->is_confirmed = true; - tx->is_failed = false; - tx->is_relayed = true; - tx->in_tx_pool = false; - tx->do_not_relay = false; - tx->is_double_spend_seen = false; + tx->m_block = block; + block->m_txs.push_back(tx); + tx->m_id = string_tools::pod_to_hex(txid); + tx->m_payment_id = string_tools::pod_to_hex(pd.m_payment_id); + if (tx->m_payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->m_payment_id = tx->m_payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet + if (tx->m_payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->m_payment_id = boost::none; // clear default payment id + tx->m_unlock_time = pd.m_unlock_time; + tx->m_fee = pd.m_amount_in - pd.m_amount_out; + tx->m_note = w2.get_tx_note(txid); + if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note + tx->m_is_miner_tx = false; + tx->m_is_confirmed = true; + tx->m_is_failed = false; + tx->m_is_relayed = true; + tx->m_in_tx_pool = false; + tx->m_do_not_relay = false; + tx->m_is_double_spend_seen = false; - // compute num_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 - if (*block->height >= height || (*block->height == 0 && !*tx->in_tx_pool)) tx->num_confirmations = 0; - else tx->num_confirmations = height - *block->height; + // compute m_num_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 + if (*block->m_height >= height || (*block->m_height == 0 && !*tx->m_in_tx_pool)) tx->m_num_confirmations = 0; + else tx->m_num_confirmations = height - *block->m_height; // construct transfer - shared_ptr outgoing_transfer = make_shared(); - outgoing_transfer->tx = tx; - tx->outgoing_transfer = outgoing_transfer; + shared_ptr m_outgoing_transfer = make_shared(); + m_outgoing_transfer->m_tx = tx; + tx->m_outgoing_transfer = m_outgoing_transfer; uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known - outgoing_transfer->amount = pd.m_amount_in - change - *tx->fee; - outgoing_transfer->account_index = pd.m_subaddr_account; - vector subaddress_indices; + m_outgoing_transfer->m_amount = pd.m_amount_in - change - *tx->m_fee; + m_outgoing_transfer->m_account_index = pd.m_subaddr_account; + vector m_subaddress_indices; vector addresses; for (uint32_t i: pd.m_subaddr_indices) { - subaddress_indices.push_back(i); + m_subaddress_indices.push_back(i); addresses.push_back(w2.get_subaddress_as_str({pd.m_subaddr_account, i})); } - outgoing_transfer->subaddress_indices = subaddress_indices; - outgoing_transfer->addresses = addresses; + m_outgoing_transfer->m_subaddress_indices = m_subaddress_indices; + m_outgoing_transfer->m_addresses = addresses; // initialize destinations for (const auto &d: pd.m_dests) { shared_ptr destination = make_shared(); - destination->amount = d.amount; - destination->address = d.original.empty() ? cryptonote::get_account_address_as_str(w2.nettype(), d.is_subaddress, d.addr) : d.original; - outgoing_transfer->destinations.push_back(destination); + destination->m_amount = d.amount; + destination->m_address = d.original.empty() ? cryptonote::get_account_address_as_str(w2.nettype(), d.is_subaddress, d.addr) : d.original; + m_outgoing_transfer->m_destinations.push_back(destination); } // replace transfer amount with destination sum // TODO monero core: confirmed tx from/to same account has amount 0 but cached transfer destinations - if (*outgoing_transfer->amount == 0 && !outgoing_transfer->destinations.empty()) { + if (*m_outgoing_transfer->m_amount == 0 && !m_outgoing_transfer->m_destinations.empty()) { uint64_t amount = 0; - for (const shared_ptr& destination : outgoing_transfer->destinations) amount += *destination->amount; - outgoing_transfer->amount = amount; + for (const shared_ptr& destination : m_outgoing_transfer->m_destinations) amount += *destination->m_amount; + m_outgoing_transfer->m_amount = amount; } - // compute num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 + // compute m_num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 uint64_t block_reward = w2.get_last_block_reward(); - if (block_reward == 0) outgoing_transfer->num_suggested_confirmations = 0; - else outgoing_transfer->num_suggested_confirmations = (*outgoing_transfer->amount + block_reward - 1) / block_reward; + if (block_reward == 0) m_outgoing_transfer->m_num_suggested_confirmations = 0; + else m_outgoing_transfer->m_num_suggested_confirmations = (*m_outgoing_transfer->m_amount + block_reward - 1) / block_reward; // return pointer to new tx return tx; } - shared_ptr build_tx_with_incoming_transfer_unconfirmed(const tools::wallet2& w2, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &ppd) { + shared_ptr build_tx_with_incoming_transfer_unconfirmed(const tools::wallet2& w2, const crypto::hash &m_payment_id, const tools::wallet2::pool_payment_details &ppd) { // construct tx const tools::wallet2::payment_details &pd = ppd.m_pd; shared_ptr tx = make_shared(); - tx->id = string_tools::pod_to_hex(pd.m_tx_hash); - tx->payment_id = string_tools::pod_to_hex(payment_id); - if (tx->payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->payment_id = tx->payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->payment_id = boost::none; // clear default payment id - tx->unlock_time = pd.m_unlock_time; - tx->fee = pd.m_fee; - tx->note = w2.get_tx_note(pd.m_tx_hash); - if (tx->note->empty()) tx->note = boost::none; // clear empty note - tx->is_miner_tx = false; - tx->is_confirmed = false; - tx->is_failed = false; - tx->is_relayed = true; - tx->in_tx_pool = true; - tx->do_not_relay = false; - tx->is_double_spend_seen = ppd.m_double_spend_seen; - tx->num_confirmations = 0; + tx->m_id = string_tools::pod_to_hex(pd.m_tx_hash); + tx->m_payment_id = string_tools::pod_to_hex(m_payment_id); + if (tx->m_payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->m_payment_id = tx->m_payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet + if (tx->m_payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->m_payment_id = boost::none; // clear default payment id + tx->m_unlock_time = pd.m_unlock_time; + tx->m_fee = pd.m_fee; + tx->m_note = w2.get_tx_note(pd.m_tx_hash); + if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note + tx->m_is_miner_tx = false; + tx->m_is_confirmed = false; + tx->m_is_failed = false; + tx->m_is_relayed = true; + tx->m_in_tx_pool = true; + tx->m_do_not_relay = false; + tx->m_is_double_spend_seen = ppd.m_double_spend_seen; + tx->m_num_confirmations = 0; // construct transfer shared_ptr incoming_transfer = make_shared(); - incoming_transfer->tx = tx; - tx->incoming_transfers.push_back(incoming_transfer); - incoming_transfer->amount = pd.m_amount; - incoming_transfer->account_index = pd.m_subaddr_index.major; - incoming_transfer->subaddress_index = pd.m_subaddr_index.minor; - incoming_transfer->address = w2.get_subaddress_as_str(pd.m_subaddr_index); + incoming_transfer->m_tx = tx; + tx->m_incoming_transfers.push_back(incoming_transfer); + incoming_transfer->m_amount = pd.m_amount; + incoming_transfer->m_account_index = pd.m_subaddr_index.major; + incoming_transfer->m_subaddress_index = pd.m_subaddr_index.minor; + incoming_transfer->m_address = w2.get_subaddress_as_str(pd.m_subaddr_index); - // compute num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 + // compute m_num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 uint64_t block_reward = w2.get_last_block_reward(); - if (block_reward == 0) incoming_transfer->num_suggested_confirmations = 0; - else incoming_transfer->num_suggested_confirmations = (*incoming_transfer->amount + block_reward - 1) / block_reward; + if (block_reward == 0) incoming_transfer->m_num_suggested_confirmations = 0; + else incoming_transfer->m_num_suggested_confirmations = (*incoming_transfer->m_amount + block_reward - 1) / block_reward; // return pointer to new tx return tx; @@ -252,58 +252,58 @@ namespace monero { // construct tx shared_ptr tx = make_shared(); - tx->is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed; - tx->id = string_tools::pod_to_hex(txid); - tx->payment_id = string_tools::pod_to_hex(pd.m_payment_id); - if (tx->payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->payment_id = tx->payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet - if (tx->payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->payment_id = boost::none; // clear default payment id - tx->unlock_time = pd.m_tx.unlock_time; - tx->fee = pd.m_amount_in - pd.m_amount_out; - tx->note = w2.get_tx_note(txid); - if (tx->note->empty()) tx->note = boost::none; // clear empty note - tx->is_miner_tx = false; - tx->is_confirmed = false; - tx->is_relayed = !tx->is_failed.get(); - tx->in_tx_pool = !tx->is_failed.get(); - tx->do_not_relay = false; - if (!tx->is_failed.get() && tx->is_relayed.get()) tx->is_double_spend_seen = false; // TODO: test and handle if true - tx->num_confirmations = 0; + tx->m_is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed; + tx->m_id = string_tools::pod_to_hex(txid); + tx->m_payment_id = string_tools::pod_to_hex(pd.m_payment_id); + if (tx->m_payment_id->substr(16).find_first_not_of('0') == std::string::npos) tx->m_payment_id = tx->m_payment_id->substr(0, 16); // TODO monero core: this should be part of core wallet + if (tx->m_payment_id == monero_tx::DEFAULT_PAYMENT_ID) tx->m_payment_id = boost::none; // clear default payment id + tx->m_unlock_time = pd.m_tx.unlock_time; + tx->m_fee = pd.m_amount_in - pd.m_amount_out; + tx->m_note = w2.get_tx_note(txid); + if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note + tx->m_is_miner_tx = false; + tx->m_is_confirmed = false; + tx->m_is_relayed = !tx->m_is_failed.get(); + tx->m_in_tx_pool = !tx->m_is_failed.get(); + tx->m_do_not_relay = false; + if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true + tx->m_num_confirmations = 0; // construct transfer - shared_ptr outgoing_transfer = make_shared(); - outgoing_transfer->tx = tx; - tx->outgoing_transfer = outgoing_transfer; - outgoing_transfer->amount = pd.m_amount_in - pd.m_change - tx->fee.get(); - outgoing_transfer->account_index = pd.m_subaddr_account; - vector subaddress_indices; + shared_ptr m_outgoing_transfer = make_shared(); + m_outgoing_transfer->m_tx = tx; + tx->m_outgoing_transfer = m_outgoing_transfer; + m_outgoing_transfer->m_amount = pd.m_amount_in - pd.m_change - tx->m_fee.get(); + m_outgoing_transfer->m_account_index = pd.m_subaddr_account; + vector m_subaddress_indices; vector addresses; for (uint32_t i: pd.m_subaddr_indices) { - subaddress_indices.push_back(i); + m_subaddress_indices.push_back(i); addresses.push_back(w2.get_subaddress_as_str({pd.m_subaddr_account, i})); } - outgoing_transfer->subaddress_indices = subaddress_indices; - outgoing_transfer->addresses = addresses; + m_outgoing_transfer->m_subaddress_indices = m_subaddress_indices; + m_outgoing_transfer->m_addresses = addresses; // initialize destinations for (const auto &d: pd.m_dests) { shared_ptr destination = make_shared(); - destination->amount = d.amount; - destination->address = d.original.empty() ? cryptonote::get_account_address_as_str(w2.nettype(), d.is_subaddress, d.addr) : d.original; - outgoing_transfer->destinations.push_back(destination); + destination->m_amount = d.amount; + destination->m_address = d.original.empty() ? cryptonote::get_account_address_as_str(w2.nettype(), d.is_subaddress, d.addr) : d.original; + m_outgoing_transfer->m_destinations.push_back(destination); } // replace transfer amount with destination sum // TODO monero core: confirmed tx from/to same account has amount 0 but cached transfer destinations - if (*outgoing_transfer->amount == 0 && !outgoing_transfer->destinations.empty()) { + if (*m_outgoing_transfer->m_amount == 0 && !m_outgoing_transfer->m_destinations.empty()) { uint64_t amount = 0; - for (const shared_ptr& destination : outgoing_transfer->destinations) amount += *destination->amount; - outgoing_transfer->amount = amount; + for (const shared_ptr& destination : m_outgoing_transfer->m_destinations) amount += *destination->m_amount; + m_outgoing_transfer->m_amount = amount; } - // compute num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 + // compute m_num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2 uint64_t block_reward = w2.get_last_block_reward(); - if (block_reward == 0) outgoing_transfer->num_suggested_confirmations = 0; - else outgoing_transfer->num_suggested_confirmations = (*outgoing_transfer->amount + block_reward - 1) / block_reward; + if (block_reward == 0) m_outgoing_transfer->m_num_suggested_confirmations = 0; + else m_outgoing_transfer->m_num_suggested_confirmations = (*m_outgoing_transfer->m_amount + block_reward - 1) / block_reward; // return pointer to new tx return tx; @@ -313,34 +313,34 @@ namespace monero { // construct block shared_ptr block = make_shared(); - block->height = td.m_block_height; + block->m_height = td.m_block_height; // construct tx shared_ptr tx = make_shared(); - tx->block = block; - block->txs.push_back(tx); - tx->id = epee::string_tools::pod_to_hex(td.m_txid); - tx->is_confirmed = true; - tx->is_failed = false; - tx->is_relayed = true; - tx->in_tx_pool = false; - tx->do_not_relay = false; - tx->is_double_spend_seen = false; + tx->m_block = block; + block->m_txs.push_back(tx); + tx->m_id = epee::string_tools::pod_to_hex(td.m_txid); + tx->m_is_confirmed = true; + tx->m_is_failed = false; + tx->m_is_relayed = true; + tx->m_in_tx_pool = false; + tx->m_do_not_relay = false; + tx->m_is_double_spend_seen = false; // construct vout shared_ptr vout = make_shared(); - vout->tx = tx; - tx->vouts.push_back(vout); - vout->amount = td.amount(); - vout->index = td.m_global_output_index; - vout->account_index = td.m_subaddr_index.major; - vout->subaddress_index = td.m_subaddr_index.minor; - vout->is_spent = td.m_spent; - vout->is_unlocked = w2.is_transfer_unlocked(td); - vout->is_frozen = td.m_frozen; + vout->m_tx = tx; + tx->m_vouts.push_back(vout); + vout->m_amount = td.amount(); + vout->m_index = td.m_global_output_index; + vout->m_account_index = td.m_subaddr_index.major; + vout->m_subaddress_index = td.m_subaddr_index.minor; + vout->m_is_spent = td.m_spent; + vout->m_is_unlocked = w2.is_transfer_unlocked(td); + vout->m_is_frozen = td.m_frozen; if (td.m_key_image_known) { - vout->key_image = make_shared(); - vout->key_image.get()->hex = epee::string_tools::pod_to_hex(td.m_key_image); + vout->m_key_image = make_shared(); + vout->m_key_image.get()->m_hex = epee::string_tools::pod_to_hex(td.m_key_image); } // return pointer to new tx @@ -359,13 +359,13 @@ namespace monero { * @param skip_if_absent specifies if the tx should not be added if it doesn't already exist */ void merge_tx(const shared_ptr& tx, map>& tx_map, map>& block_map, bool skip_if_absent) { - if (tx->id == boost::none) throw runtime_error("Tx id is not initialized"); + if (tx->m_id == boost::none) throw runtime_error("Tx id is not initialized"); // if tx doesn't exist, add it (unless skipped) - map>::const_iterator tx_iter = tx_map.find(*tx->id); + map>::const_iterator tx_iter = tx_map.find(*tx->m_id); if (tx_iter == tx_map.end()) { if (!skip_if_absent) { - tx_map[*tx->id] = tx; + tx_map[*tx->m_id] = tx; } else { MWARNING("WARNING: tx does not already exist"); } @@ -373,7 +373,7 @@ namespace monero { // otherwise merge with existing tx else { - shared_ptr& a_tx = tx_map[*tx->id]; + shared_ptr& a_tx = tx_map[*tx->m_id]; a_tx->merge(a_tx, tx); } @@ -381,10 +381,10 @@ namespace monero { if (tx->get_height() != boost::none) { map>::const_iterator blockIter = block_map.find(tx->get_height().get()); if (blockIter == block_map.end()) { - block_map[tx->get_height().get()] = tx->block.get(); + block_map[tx->get_height().get()] = tx->m_block.get(); } else { shared_ptr& a_block = block_map[tx->get_height().get()]; - a_block->merge(a_block, tx->block.get()); + a_block->merge(a_block, tx->m_block.get()); } } } @@ -393,8 +393,8 @@ namespace monero { * Returns true iff tx1's height is known to be less than tx2's height for sorting. */ bool tx_height_less_than(const shared_ptr& tx1, const shared_ptr& tx2) { - if (tx1->block != boost::none && tx2->block != boost::none) return tx1->get_height() < tx2->get_height(); - else if (tx1->block == boost::none) return false; + if (tx1->m_block != boost::none && tx2->m_block != boost::none) return tx1->get_height() < tx2->get_height(); + else if (tx1->m_block == boost::none) return false; else return true; } @@ -404,11 +404,11 @@ namespace monero { bool incoming_transfer_before(const shared_ptr& transfer1, const shared_ptr& transfer2) { // compare by height - if (tx_height_less_than(transfer1->tx, transfer2->tx)) return true; + if (tx_height_less_than(transfer1->m_tx, transfer2->m_tx)) return true; // compare by account and subaddress index - if (transfer1->account_index.get() < transfer2->account_index.get()) return true; - else if (transfer1->account_index.get() == transfer2->account_index.get()) return transfer1->subaddress_index.get() < transfer2->subaddress_index.get(); + if (transfer1->m_account_index.get() < transfer2->m_account_index.get()) return true; + else if (transfer1->m_account_index.get() == transfer2->m_account_index.get()) return transfer1->m_subaddress_index.get() < transfer2->m_subaddress_index.get(); else return false; } @@ -420,13 +420,13 @@ namespace monero { shared_ptr ow2 = static_pointer_cast(o2); // compare by height - if (tx_height_less_than(ow1->tx, ow2->tx)) return true; + if (tx_height_less_than(ow1->m_tx, ow2->m_tx)) return true; // compare by account index, subaddress index, and output - if (ow1->account_index.get() < ow2->account_index.get()) return true; - else if (ow1->account_index.get() == ow2->account_index.get()) { - if (ow1->subaddress_index.get() < ow2->subaddress_index.get()) return true; - if (ow1->subaddress_index.get() == ow2->subaddress_index.get() && ow1->index.get() < ow2->index.get()) return true; + if (ow1->m_account_index.get() < ow2->m_account_index.get()) return true; + else if (ow1->m_account_index.get() == ow2->m_account_index.get()) { + if (ow1->m_subaddress_index.get() < ow2->m_subaddress_index.get()) return true; + if (ow1->m_subaddress_index.get() == ow2->m_subaddress_index.get() && ow1->m_index.get() < ow2->m_index.get()) return true; } return false; } @@ -716,18 +716,18 @@ namespace monero { // create native library tx shared_ptr block = make_shared(); - block->height = height; + block->m_height = height; shared_ptr tx = static_pointer_cast(monero_utils::cn_tx_to_tx(cn_tx, true)); - block->txs.push_back(tx); - tx->block = block; - tx->id = epee::string_tools::pod_to_hex(txid); - tx->unlock_time = unlock_time; + block->m_txs.push_back(tx); + tx->m_block = block; + tx->m_id = epee::string_tools::pod_to_hex(txid); + tx->m_unlock_time = unlock_time; shared_ptr output = make_shared(); - tx->vouts.push_back(output); - output->tx = tx; - output->amount = amount; - output->account_index = subaddr_index.major; - output->subaddress_index = subaddr_index.minor; + tx->m_vouts.push_back(output); + output->m_tx = tx; + output->m_amount = amount; + output->m_account_index = subaddr_index.major; + output->m_subaddress_index = subaddr_index.minor; // notify listener of output listener->on_output_received(*output); @@ -739,17 +739,17 @@ namespace monero { // create native library tx shared_ptr block = make_shared(); - block->height = height; + block->m_height = height; shared_ptr tx = static_pointer_cast(monero_utils::cn_tx_to_tx(cn_tx_in, true)); - block->txs.push_back(tx); - tx->block = block; - tx->id = epee::string_tools::pod_to_hex(txid); + block->m_txs.push_back(tx); + tx->m_block = block; + tx->m_id = epee::string_tools::pod_to_hex(txid); shared_ptr output = make_shared(); - tx->vins.push_back(output); - output->tx = tx; - output->amount = amount; - output->account_index = subaddr_index.major; - output->subaddress_index = subaddr_index.minor; + tx->m_vins.push_back(output); + output->m_tx = tx; + output->m_amount = amount; + output->m_account_index = subaddr_index.major; + output->m_subaddress_index = subaddr_index.minor; // notify listener of output listener->on_output_spent(*output); @@ -934,19 +934,19 @@ namespace monero { } void monero_wallet::set_daemon_connection(const monero_rpc_connection& connection) { - set_daemon_connection(connection.uri, connection.username == boost::none ? "" : connection.username.get(), connection.password == boost::none ? "" : connection.password.get()); + set_daemon_connection(connection.m_uri, connection.m_username == boost::none ? "" : connection.m_username.get(), connection.m_password == boost::none ? "" : connection.m_password.get()); } shared_ptr monero_wallet::get_daemon_connection() const { MTRACE("monero_wallet::get_daemon_connection()"); if (w2->get_daemon_address().empty()) return nullptr; shared_ptr connection = make_shared(); - if (!w2->get_daemon_address().empty()) connection->uri = w2->get_daemon_address(); + if (!w2->get_daemon_address().empty()) connection->m_uri = w2->get_daemon_address(); if (w2->get_daemon_login()) { - if (!w2->get_daemon_login()->username.empty()) connection->username = w2->get_daemon_login()->username; + if (!w2->get_daemon_login()->username.empty()) connection->m_username = w2->get_daemon_login()->username; epee::wipeable_string wipeablePassword = w2->get_daemon_login()->password; string password = string(wipeablePassword.data(), wipeablePassword.size()); - if (!password.empty()) connection->password = password; + if (!password.empty()) connection->m_password = password; } return connection; } @@ -1027,8 +1027,8 @@ namespace monero { // return indices in subaddress monero_subaddress subaddress; cryptonote::subaddress_index cn_index = *index; - subaddress.account_index = cn_index.major; - subaddress.index = cn_index.minor; + subaddress.m_account_index = cn_index.major; + subaddress.m_index = cn_index.minor; return subaddress; } @@ -1072,9 +1072,9 @@ namespace monero { // initialize and return result monero_integrated_address result; - result.standard_address = cryptonote::get_account_address_as_str(w2->nettype(), info.is_subaddress, info.address); - result.payment_id = epee::string_tools::pod_to_hex(info.payment_id); - result.integrated_address = integrated_address; + result.m_standard_address = cryptonote::get_account_address_as_str(w2->nettype(), info.is_subaddress, info.address); + result.m_payment_id = epee::string_tools::pod_to_hex(info.payment_id); + result.m_integrated_address = integrated_address; return result; } @@ -1236,11 +1236,11 @@ namespace monero { vector accounts; for (uint32_t account_idx = 0; account_idx < w2->get_num_subaddress_accounts(); account_idx++) { monero_account account; - account.index = account_idx; - account.primary_address = get_address(account_idx, 0); - account.balance = w2->balance(account_idx); - account.unlocked_balance = w2->unlocked_balance(account_idx); - if (include_subaddresses) account.subaddresses = get_subaddresses_aux(account_idx, vector(), transfers); + account.m_index = account_idx; + account.m_primary_address = get_address(account_idx, 0); + account.m_balance = w2->balance(account_idx); + account.m_unlocked_balance = w2->unlocked_balance(account_idx); + if (include_subaddresses) account.m_subaddresses = get_subaddresses_aux(account_idx, vector(), transfers); accounts.push_back(account); } @@ -1260,11 +1260,11 @@ namespace monero { // build and return account monero_account account; - account.index = account_idx; - account.primary_address = get_address(account_idx, 0); - account.balance = w2->balance(account_idx); - account.unlocked_balance = w2->unlocked_balance(account_idx); - if (include_subaddresses) account.subaddresses = get_subaddresses_aux(account_idx, vector(), transfers); + account.m_index = account_idx; + account.m_primary_address = get_address(account_idx, 0); + account.m_balance = w2->balance(account_idx); + account.m_unlocked_balance = w2->unlocked_balance(account_idx); + if (include_subaddresses) account.m_subaddresses = get_subaddresses_aux(account_idx, vector(), transfers); return account; } @@ -1276,10 +1276,10 @@ namespace monero { // initialize and return result monero_account account; - account.index = w2->get_num_subaddress_accounts() - 1; - account.primary_address = w2->get_subaddress_as_str({account.index.get(), 0}); - account.balance = 0; - account.unlocked_balance = 0; + account.m_index = w2->get_num_subaddress_accounts() - 1; + account.m_primary_address = w2->get_subaddress_as_str({account.m_index.get(), 0}); + account.m_balance = 0; + account.m_unlocked_balance = 0; return account; } @@ -1310,15 +1310,15 @@ namespace monero { // initialize and return result monero_subaddress subaddress; - subaddress.account_index = account_idx; - subaddress.index = w2->get_num_subaddresses(account_idx) - 1; - subaddress.address = w2->get_subaddress_as_str({account_idx, subaddress.index.get()}); - subaddress.label = label; - subaddress.balance = 0; - subaddress.unlocked_balance = 0; - subaddress.num_unspent_outputs = 0; - subaddress.is_used = false; - subaddress.num_blocks_to_unlock = 0; + subaddress.m_account_index = account_idx; + subaddress.m_index = w2->get_num_subaddresses(account_idx) - 1; + subaddress.m_address = w2->get_subaddress_as_str({account_idx, subaddress.m_index.get()}); + subaddress.m_label = label; + subaddress.m_balance = 0; + subaddress.m_unlocked_balance = 0; + subaddress.m_num_unspent_outputs = 0; + subaddress.m_is_used = false; + subaddress.m_num_blocks_to_unlock = 0; return subaddress; } @@ -1333,28 +1333,28 @@ namespace monero { // copy and normalize tx request shared_ptr requestSp = make_shared(request); // convert to shared pointer for copy shared_ptr req = requestSp->copy(requestSp, make_shared()); - if (req->transfer_request == boost::none) req->transfer_request = make_shared(); - shared_ptr transfer_req = req->transfer_request.get(); + if (req->m_transfer_request == boost::none) req->m_transfer_request = make_shared(); + shared_ptr transfer_req = req->m_transfer_request.get(); // print req - if (req->block != boost::none) MTRACE("Tx req's rooted at [block]: " << req->block.get()->serialize()); + if (req->m_block != boost::none) MTRACE("Tx req's rooted at [block]: " << req->m_block.get()->serialize()); else MTRACE("Tx req: " << req->serialize()); // temporarily disable transfer request - req->transfer_request = boost::none; + req->m_transfer_request = boost::none; // fetch all transfers that meet tx request monero_transfer_request temp_transfer_req; - temp_transfer_req.tx_request = make_shared(*req); + temp_transfer_req.m_tx_request = make_shared(*req); vector> transfers = get_transfers(temp_transfer_req); // collect unique txs from transfers while retaining order vector> txs = vector>(); unordered_set> txsSet; for (const shared_ptr& transfer : transfers) { - if (txsSet.find(transfer->tx) == txsSet.end()) { - txs.push_back(transfer->tx); - txsSet.insert(transfer->tx); + if (txsSet.find(transfer->m_tx) == txsSet.end()) { + txs.push_back(transfer->m_tx); + txsSet.insert(transfer->m_tx); } } @@ -1367,8 +1367,8 @@ namespace monero { // fetch and merge outputs if requested monero_output_request temp_output_req; - temp_output_req.tx_request = make_shared(*req); - if (req->include_outputs != boost::none && *req->include_outputs) { + temp_output_req.m_tx_request = make_shared(*req); + if (req->m_include_outputs != boost::none && *req->m_include_outputs) { // fetch outputs vector> outputs = get_outputs(temp_output_req); @@ -1376,7 +1376,7 @@ namespace monero { // merge output txs one time while retaining order unordered_set> outputTxs; for (const shared_ptr& output : outputs) { - shared_ptr tx = static_pointer_cast(output->tx); + shared_ptr tx = static_pointer_cast(output->m_tx); if (outputTxs.find(tx) == outputTxs.end()) { merge_tx(tx, tx_map, block_map, true); outputTxs.insert(tx); @@ -1385,7 +1385,7 @@ namespace monero { } // filter txs that don't meet transfer req // TODO: port this updated version to js - req->transfer_request = transfer_req; + req->m_transfer_request = transfer_req; vector> txs_requested; vector>::iterator tx_iter = txs.begin(); while (tx_iter != txs.end()) { @@ -1395,17 +1395,17 @@ namespace monero { tx_iter++; } else { tx_iter = txs.erase(tx_iter); - if (tx->block != boost::none) tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use tx_iter? + if (tx->m_block != boost::none) tx->m_block.get()->m_txs.erase(std::remove(tx->m_block.get()->m_txs.begin(), tx->m_block.get()->m_txs.end(), tx), tx->m_block.get()->m_txs.end()); // TODO, no way to use tx_iter? } } txs = txs_requested; // verify all specified tx ids found - if (!req->tx_ids.empty()) { - for (const string& tx_id : req->tx_ids) { + if (!req->m_tx_ids.empty()) { + for (const string& tx_id : req->m_tx_ids) { bool found = false; for (const shared_ptr& tx : txs) { - if (tx_id == *tx->id) { + if (tx_id == *tx->m_id) { found = true; break; } @@ -1417,13 +1417,13 @@ namespace monero { // special case: re-fetch txs if inconsistency caused by needing to make multiple wallet calls // TODO monero core: offer wallet.get_txs(...) for (const shared_ptr& tx : txs) { - if (*tx->is_confirmed && tx->block == boost::none) return get_txs(*req); + if (*tx->m_is_confirmed && tx->m_block == boost::none) return get_txs(*req); } // otherwise order txs if tx ids given then return - if (!req->tx_ids.empty()) { + if (!req->m_tx_ids.empty()) { vector> ordered_txs; - for (const string& tx_id : req->tx_ids) { + for (const string& tx_id : req->m_tx_ids) { map>::const_iterator tx_iter = tx_map.find(tx_id); ordered_txs.push_back(tx_iter->second); } @@ -1436,50 +1436,50 @@ namespace monero { MTRACE("monero_wallet::get_transfers(request)"); // LOG request - if (request.tx_request != boost::none) { - if ((*request.tx_request)->block == boost::none) MTRACE("Transfer request's tx request rooted at [tx]:" << (*request.tx_request)->serialize()); - else MTRACE("Transfer request's tx request rooted at [block]: " << (*(*request.tx_request)->block)->serialize()); + if (request.m_tx_request != boost::none) { + if ((*request.m_tx_request)->m_block == boost::none) MTRACE("Transfer request's tx request rooted at [tx]:" << (*request.m_tx_request)->serialize()); + else MTRACE("Transfer request's tx request rooted at [block]: " << (*(*request.m_tx_request)->m_block)->serialize()); } // copy and normalize request shared_ptr req; - if (request.tx_request == boost::none) req = request.copy(make_shared(request), make_shared()); + if (request.m_tx_request == boost::none) req = request.copy(make_shared(request), make_shared()); else { - shared_ptr tx_req = request.tx_request.get()->copy(request.tx_request.get(), make_shared()); - if (request.tx_request.get()->transfer_request != boost::none && request.tx_request.get()->transfer_request.get().get() == &request) { - req = tx_req->transfer_request.get(); + shared_ptr tx_req = request.m_tx_request.get()->copy(request.m_tx_request.get(), make_shared()); + if (request.m_tx_request.get()->m_transfer_request != boost::none && request.m_tx_request.get()->m_transfer_request.get().get() == &request) { + req = tx_req->m_transfer_request.get(); } else { - if (request.tx_request.get()->transfer_request != boost::none) throw new runtime_error("Transfer request's tx request must be a circular reference or null"); + if (request.m_tx_request.get()->m_transfer_request != boost::none) throw new runtime_error("Transfer request's tx request must be a circular reference or null"); shared_ptr requestSp = make_shared(request); // convert request to shared pointer for copy req = requestSp->copy(requestSp, make_shared()); - req->tx_request = tx_req; + req->m_tx_request = tx_req; } } - if (req->tx_request == boost::none) req->tx_request = make_shared(); - shared_ptr tx_req = req->tx_request.get(); - tx_req->transfer_request = boost::none; // break circular link for meets_criteria() + if (req->m_tx_request == boost::none) req->m_tx_request = make_shared(); + shared_ptr tx_req = req->m_tx_request.get(); + tx_req->m_transfer_request = boost::none; // break circular link for meets_criteria() // build parameters for w2->get_payments() - uint64_t min_height = tx_req->min_height == boost::none ? 0 : *tx_req->min_height; - uint64_t max_height = tx_req->max_height == boost::none ? CRYPTONOTE_MAX_BLOCK_NUMBER : min((uint64_t) CRYPTONOTE_MAX_BLOCK_NUMBER, *tx_req->max_height); - if (min_height > 0) min_height--; // TODO monero core: wallet2::get_payments() min_height is exclusive, so manually offset to match intended range (issues 5751, #5598) + uint64_t min_height = tx_req->m_min_height == boost::none ? 0 : *tx_req->m_min_height; + uint64_t max_height = tx_req->m_max_height == boost::none ? CRYPTONOTE_MAX_BLOCK_NUMBER : min((uint64_t) CRYPTONOTE_MAX_BLOCK_NUMBER, *tx_req->m_max_height); + if (min_height > 0) min_height--; // TODO monero core: wallet2::get_payments() m_min_height is exclusive, so manually offset to match intended range (issues 5751, #5598) boost::optional account_index = boost::none; - if (req->account_index != boost::none) account_index = *req->account_index; + if (req->m_account_index != boost::none) account_index = *req->m_account_index; std::set subaddress_indices; - for (int i = 0; i < req->subaddress_indices.size(); i++) { - subaddress_indices.insert(req->subaddress_indices[i]); + for (int i = 0; i < req->m_subaddress_indices.size(); i++) { + subaddress_indices.insert(req->m_subaddress_indices[i]); } // translate from monero_tx_request to in, out, pending, pool, failed terminology used by monero-wallet-rpc - bool can_be_confirmed = !bool_equals(false, tx_req->is_confirmed) && !bool_equals(true, tx_req->in_tx_pool) && !bool_equals(true, tx_req->is_failed) && !bool_equals(false, tx_req->is_relayed); - bool can_be_in_tx_pool = !bool_equals(true, tx_req->is_confirmed) && !bool_equals(false, tx_req->in_tx_pool) && !bool_equals(true, tx_req->is_failed) && !bool_equals(false, tx_req->is_relayed) && tx_req->get_height() == boost::none && tx_req->min_height == boost::none; - bool can_be_incoming = !bool_equals(false, req->is_incoming) && !bool_equals(true, req->getIsOutgoing()) && !bool_equals(true, req->has_destinations); - bool can_be_outgoing = !bool_equals(false, req->getIsOutgoing()) && !bool_equals(true, req->is_incoming); + bool can_be_confirmed = !bool_equals(false, tx_req->m_is_confirmed) && !bool_equals(true, tx_req->m_in_tx_pool) && !bool_equals(true, tx_req->m_is_failed) && !bool_equals(false, tx_req->m_is_relayed); + bool can_be_in_tx_pool = !bool_equals(true, tx_req->m_is_confirmed) && !bool_equals(false, tx_req->m_in_tx_pool) && !bool_equals(true, tx_req->m_is_failed) && !bool_equals(false, tx_req->m_is_relayed) && tx_req->get_height() == boost::none && tx_req->m_min_height == boost::none; + bool can_be_incoming = !bool_equals(false, req->m_is_incoming) && !bool_equals(true, req->getIsOutgoing()) && !bool_equals(true, req->m_has_destinations); + bool can_be_outgoing = !bool_equals(false, req->getIsOutgoing()) && !bool_equals(true, req->m_is_incoming); bool is_in = can_be_incoming && can_be_confirmed; bool is_out = can_be_outgoing && can_be_confirmed; bool is_pending = can_be_outgoing && can_be_in_tx_pool; bool is_pool = can_be_incoming && can_be_in_tx_pool; - bool is_failed = !bool_equals(false, tx_req->is_failed) && !bool_equals(true, tx_req->is_confirmed) && !bool_equals(true, tx_req->in_tx_pool); + bool is_failed = !bool_equals(false, tx_req->m_is_failed) && !bool_equals(true, tx_req->m_is_confirmed) && !bool_equals(true, tx_req->m_in_tx_pool); // cache unique txs and blocks uint64_t height = get_height(); @@ -1512,7 +1512,7 @@ namespace monero { w2->get_unconfirmed_payments_out(upayments, account_index, subaddress_indices); for (std::list>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) { shared_ptr tx = build_tx_with_outgoing_transfer_unconfirmed(*w2, i->first, i->second); - if (tx_req->is_failed != boost::none && tx_req->is_failed.get() != tx->is_failed.get()) continue; // skip merging if tx unrequested + if (tx_req->m_is_failed != boost::none && tx_req->m_is_failed.get() != tx->m_is_failed.get()) continue; // skip merging if tx unrequested merge_tx(tx, tx_map, block_map, false); } } @@ -1540,26 +1540,26 @@ namespace monero { for (const shared_ptr& tx : txs) { // sort transfers - sort(tx->incoming_transfers.begin(), tx->incoming_transfers.end(), incoming_transfer_before); + sort(tx->m_incoming_transfers.begin(), tx->m_incoming_transfers.end(), incoming_transfer_before); // collect outgoing transfer, erase if filtered TODO: js does not erase unrequested data, port to js - if (tx->outgoing_transfer != boost::none && req->meets_criteria(tx->outgoing_transfer.get().get())) transfers.push_back(tx->outgoing_transfer.get()); - else tx->outgoing_transfer = boost::none; + if (tx->m_outgoing_transfer != boost::none && req->meets_criteria(tx->m_outgoing_transfer.get().get())) transfers.push_back(tx->m_outgoing_transfer.get()); + else tx->m_outgoing_transfer = boost::none; // collect incoming transfers, erase if unrequested - vector>::iterator iter = tx->incoming_transfers.begin(); - while (iter != tx->incoming_transfers.end()) { + vector>::iterator iter = tx->m_incoming_transfers.begin(); + while (iter != tx->m_incoming_transfers.end()) { if (req->meets_criteria((*iter).get())) { transfers.push_back(*iter); iter++; } else { - iter = tx->incoming_transfers.erase(iter); + iter = tx->m_incoming_transfers.erase(iter); } } // remove unrequested txs from block - if (tx->block != boost::none && tx->outgoing_transfer == boost::none && tx->incoming_transfers.empty()) { - tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator? + if (tx->m_block != boost::none && tx->m_outgoing_transfer == boost::none && tx->m_incoming_transfers.empty()) { + tx->m_block.get()->m_txs.erase(std::remove(tx->m_block.get()->m_txs.begin(), tx->m_block.get()->m_txs.end(), tx), tx->m_block.get()->m_txs.end()); // TODO, no way to use const_iterator? } } MTRACE("monero_wallet.cpp get_transfers() returning " << transfers.size() << " transfers"); @@ -1572,28 +1572,28 @@ namespace monero { // print request MTRACE("Output request: " << request.serialize()); - if (request.tx_request != boost::none) { - if ((*request.tx_request)->block == boost::none) MTRACE("Output request's tx request rooted at [tx]:" << (*request.tx_request)->serialize()); - else MTRACE("Output request's tx request rooted at [block]: " << (*(*request.tx_request)->block)->serialize()); + if (request.m_tx_request != boost::none) { + if ((*request.m_tx_request)->m_block == boost::none) MTRACE("Output request's tx request rooted at [tx]:" << (*request.m_tx_request)->serialize()); + else MTRACE("Output request's tx request rooted at [block]: " << (*(*request.m_tx_request)->m_block)->serialize()); } // copy and normalize request shared_ptr req; - if (request.tx_request == boost::none) req = request.copy(make_shared(request), make_shared()); + if (request.m_tx_request == boost::none) req = request.copy(make_shared(request), make_shared()); else { - shared_ptr tx_req = request.tx_request.get()->copy(request.tx_request.get(), make_shared()); - if (request.tx_request.get()->output_request != boost::none && request.tx_request.get()->output_request.get().get() == &request) { - req = tx_req->output_request.get(); + shared_ptr tx_req = request.m_tx_request.get()->copy(request.m_tx_request.get(), make_shared()); + if (request.m_tx_request.get()->m_output_request != boost::none && request.m_tx_request.get()->m_output_request.get().get() == &request) { + req = tx_req->m_output_request.get(); } else { - if (request.tx_request.get()->output_request != boost::none) throw new runtime_error("Output request's tx request must be a circular reference or null"); + if (request.m_tx_request.get()->m_output_request != boost::none) throw new runtime_error("Output request's tx request must be a circular reference or null"); shared_ptr requestSp = make_shared(request); // convert request to shared pointer for copy req = requestSp->copy(requestSp, make_shared()); - req->tx_request = tx_req; + req->m_tx_request = tx_req; } } - if (req->tx_request == boost::none) req->tx_request = make_shared(); - shared_ptr tx_req = req->tx_request.get(); - tx_req->output_request = boost::none; // break circular link for meets_criteria() + if (req->m_tx_request == boost::none) req->m_tx_request = make_shared(); + shared_ptr tx_req = req->m_tx_request.get(); + tx_req->m_output_request = boost::none; // break circular link for meets_criteria() // get output data from wallet2 tools::wallet2::transfer_container outputs_w2; @@ -1620,22 +1620,22 @@ namespace monero { for (const shared_ptr& tx : txs) { // sort outputs - sort(tx->vouts.begin(), tx->vouts.end(), vout_before); + sort(tx->m_vouts.begin(), tx->m_vouts.end(), vout_before); // collect requested outputs, remove unrequested outputs - vector>::iterator voutIter = tx->vouts.begin(); - while (voutIter != tx->vouts.end()) { + vector>::iterator voutIter = tx->m_vouts.begin(); + while (voutIter != tx->m_vouts.end()) { shared_ptr vout_wallet = static_pointer_cast(*voutIter); if (req->meets_criteria(vout_wallet.get())) { vouts.push_back(vout_wallet); voutIter++; } else { - voutIter = tx->vouts.erase(voutIter); // remove unrequested vouts + voutIter = tx->m_vouts.erase(voutIter); // remove unrequested vouts } } // remove txs without requested vout - if (tx->vouts.empty() && tx->block != boost::none) tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator? + if (tx->m_vouts.empty() && tx->m_block != boost::none) tx->m_block.get()->m_txs.erase(std::remove(tx->m_block.get()->m_txs.begin(), tx->m_block.get()->m_txs.end(), tx), tx->m_block.get()->m_txs.end()); // TODO, no way to use const_iterator? } return vouts; } @@ -1665,8 +1665,8 @@ namespace monero { for (size_t n = 0; n < ski.second.size(); ++n) { shared_ptr key_image = make_shared(); key_images.push_back(key_image); - key_image->hex = epee::string_tools::pod_to_hex(ski.second[n].first); - key_image->signature = epee::string_tools::pod_to_hex(ski.second[n].second); + key_image->m_hex = epee::string_tools::pod_to_hex(ski.second[n].first); + key_image->m_signature = epee::string_tools::pod_to_hex(ski.second[n].second); } return key_images; } @@ -1678,10 +1678,10 @@ namespace monero { std::vector> ski; ski.resize(key_images.size()); for (size_t n = 0; n < ski.size(); ++n) { - if (!epee::string_tools::hex_to_pod(key_images[n]->hex.get(), ski[n].first)) { + if (!epee::string_tools::hex_to_pod(key_images[n]->m_hex.get(), ski[n].first)) { throw runtime_error("failed to parse key image"); } - if (!epee::string_tools::hex_to_pod(key_images[n]->signature.get(), ski[n].second)) { + if (!epee::string_tools::hex_to_pod(key_images[n]->m_signature.get(), ski[n].second)) { throw runtime_error("failed to parse signature"); } } @@ -1692,9 +1692,9 @@ namespace monero { // translate results shared_ptr result = make_shared(); - result->height = height; - result->spent_amount = spent; - result->unspent_amount = unspent; + result->m_height = height; + result->m_spent_amount = spent; + result->m_unspent_amount = unspent; return result; } @@ -1707,12 +1707,12 @@ namespace monero { epee::json_rpc::error err; // prepare parameters for wallet rpc's validate_transfer() - string payment_id = request.payment_id == boost::none ? string("") : request.payment_id.get(); + string payment_id = request.m_payment_id == boost::none ? string("") : request.m_payment_id.get(); list tr_destinations; - for (const shared_ptr& destination : request.destinations) { + for (const shared_ptr& destination : request.m_destinations) { tools::wallet_rpc::transfer_destination tr_destination; - tr_destination.amount = destination->amount.get(); - tr_destination.address = destination->address.get(); + tr_destination.amount = destination->m_amount.get(); + tr_destination.address = destination->m_address.get(); tr_destinations.push_back(tr_destination); } @@ -1724,20 +1724,20 @@ namespace monero { } // prepare parameters for wallet2's create_transactions_2() - uint64_t mixin = w2->adjust_mixin(request.ring_size == boost::none ? 0 : request.ring_size.get() - 1); - uint32_t priority = w2->adjust_priority(request.priority == boost::none ? 0 : request.priority.get()); - uint64_t unlock_time = request.unlock_time == boost::none ? 0 : request.unlock_time.get(); - if (request.account_index == boost::none) throw runtime_error("Must specify the account index to send from"); - uint32_t account_index = request.account_index.get(); - std::set subaddress_indices; - for (const uint32_t& subaddress_idx : request.subaddress_indices) subaddress_indices.insert(subaddress_idx); + uint64_t m_mixin = w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1); + uint32_t priority = w2->adjust_priority(request.m_priority == boost::none ? 0 : request.m_priority.get()); + uint64_t m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); + if (request.m_account_index == boost::none) throw runtime_error("Must specify the account index to send from"); + uint32_t m_account_index = request.m_account_index.get(); + std::set m_subaddress_indices; + for (const uint32_t& subaddress_idx : request.m_subaddress_indices) m_subaddress_indices.insert(subaddress_idx); // prepare transactions - vector ptx_vector = w2->create_transactions_2(dsts, mixin, unlock_time, priority, extra, account_index, subaddress_indices); + vector ptx_vector = w2->create_transactions_2(dsts, m_mixin, m_unlock_time, priority, extra, m_account_index, m_subaddress_indices); if (ptx_vector.empty()) throw runtime_error("No transaction created"); // check if request cannot be fulfilled due to splitting - if (request.can_split != boost::none && request.can_split.get() == false && ptx_vector.size() != 1) { + if (request.m_can_split != boost::none && request.m_can_split.get() == false && ptx_vector.size() != 1) { throw runtime_error("Transaction would be too large. Try send_split()"); } @@ -1745,7 +1745,7 @@ namespace monero { bool get_tx_keys = true; bool get_tx_hex = true; bool get_tx_metadata = true; - bool do_not_relay = request.do_not_relay == boost::none ? false : request.do_not_relay.get(); + bool m_do_not_relay = request.m_do_not_relay == boost::none ? false : request.m_do_not_relay.get(); // commit txs (if relaying) and get response using wallet rpc's fill_response() list tx_keys; @@ -1753,51 +1753,51 @@ namespace monero { list tx_fees; string multisig_tx_set; string unsigned_tx_set; - list tx_ids; + list m_tx_ids; list tx_blobs; list tx_metadatas; - if (!fill_response(w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_set, unsigned_tx_set, do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) { + if (!fill_response(w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_set, unsigned_tx_set, m_do_not_relay, m_tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) { throw runtime_error("need to handle error filling response!"); // TODO } // build sent txs from results // TODO: break this into separate utility function vector> txs; - auto tx_ids_iter = tx_ids.begin(); + auto tx_ids_iter = m_tx_ids.begin(); auto tx_keys_iter = tx_keys.begin(); auto tx_amounts_iter = tx_amounts.begin(); auto tx_fees_iter = tx_fees.begin(); auto tx_blobs_iter = tx_blobs.begin(); auto tx_metadatas_iter = tx_metadatas.begin(); - while (tx_ids_iter != tx_ids.end()) { + while (tx_ids_iter != m_tx_ids.end()) { // init tx with outgoing transfer from filled values shared_ptr tx = make_shared(); txs.push_back(tx); - tx->id = *tx_ids_iter; - tx->key = *tx_keys_iter; - tx->fee = *tx_fees_iter; - tx->full_hex = *tx_blobs_iter; - tx->metadata = *tx_metadatas_iter; + tx->m_id = *tx_ids_iter; + tx->m_key = *tx_keys_iter; + tx->m_fee = *tx_fees_iter; + tx->m_full_hex = *tx_blobs_iter; + tx->m_metadata = *tx_metadatas_iter; shared_ptr out_transfer = make_shared(); - tx->outgoing_transfer = out_transfer; - out_transfer->amount = *tx_amounts_iter; + tx->m_outgoing_transfer = out_transfer; + out_transfer->m_amount = *tx_amounts_iter; // init other known fields - tx->payment_id = request.payment_id; - tx->is_confirmed = false; - tx->is_miner_tx = false; - tx->is_failed = false; // TODO: test and handle if true - tx->do_not_relay = request.do_not_relay != boost::none && request.do_not_relay.get() == true; - tx->is_relayed = tx->do_not_relay.get() != true; - tx->in_tx_pool = !tx->do_not_relay.get(); - if (!tx->is_failed.get() && tx->is_relayed.get()) tx->is_double_spend_seen = false; // TODO: test and handle if true - tx->num_confirmations = 0; - tx->mixin = request.mixin; - tx->unlock_time = request.unlock_time == boost::none ? 0 : request.unlock_time.get(); - if (tx->is_relayed.get()) tx->last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 - out_transfer->account_index = request.account_index; - if (request.subaddress_indices.size() == 1) out_transfer->subaddress_indices.push_back(request.subaddress_indices[0]); // subaddress index is known iff 1 requested // TODO: get all known subaddress indices here - out_transfer->destinations = request.destinations; + tx->m_payment_id = request.m_payment_id; + tx->m_is_confirmed = false; + tx->m_is_miner_tx = false; + tx->m_is_failed = false; // TODO: test and handle if true + tx->m_do_not_relay = request.m_do_not_relay != boost::none && request.m_do_not_relay.get() == true; + tx->m_is_relayed = tx->m_do_not_relay.get() != true; + tx->m_in_tx_pool = !tx->m_do_not_relay.get(); + if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true + tx->m_num_confirmations = 0; + tx->m_mixin = request.m_mixin; + tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); + if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 + out_transfer->m_account_index = request.m_account_index; + if (request.m_subaddress_indices.size() == 1) out_transfer->m_subaddress_indices.push_back(request.m_subaddress_indices[0]); // subaddress index is known iff 1 requested // TODO: get all known subaddress indices here + out_transfer->m_destinations = request.m_destinations; // iterate to next element tx_keys_iter++; @@ -1815,34 +1815,34 @@ namespace monero { MTRACE("monero_send_request: " << request.serialize()); // validate input request - if (request.key_image == boost::none || request.key_image.get().empty()) throw runtime_error("Must provide key image of output to sweep"); - if (request.destinations.size() != 1 || request.destinations[0]->address == boost::none || request.destinations[0]->address.get().empty()) throw runtime_error("Must provide exactly one destination to sweep output to"); + if (request.m_key_image == boost::none || request.m_key_image.get().empty()) throw runtime_error("Must provide key image of output to sweep"); + if (request.m_destinations.size() != 1 || request.m_destinations[0]->m_address == boost::none || request.m_destinations[0]->m_address.get().empty()) throw runtime_error("Must provide exactly one destination to sweep output to"); // validate the transfer requested and populate dsts & extra - string payment_id = request.payment_id == boost::none ? string("") : request.payment_id.get(); + string m_payment_id = request.m_payment_id == boost::none ? string("") : request.m_payment_id.get(); std::vector dsts; std::vector extra; std::list destination; destination.push_back(wallet_rpc::transfer_destination()); destination.back().amount = 0; - destination.back().address = request.destinations[0]->address.get(); + destination.back().address = request.m_destinations[0]->m_address.get(); epee::json_rpc::error er; - if (!validate_transfer(w2.get(), destination, payment_id, dsts, extra, true, er)) { + if (!validate_transfer(w2.get(), destination, m_payment_id, dsts, extra, true, er)) { //throw runtime_error(er); // TODO throw runtime_error("Handle validate_transfer error!"); } // validate key image crypto::key_image ki; - if (!epee::string_tools::hex_to_pod(request.key_image.get(), ki)) { + if (!epee::string_tools::hex_to_pod(request.m_key_image.get(), ki)) { throw runtime_error("failed to parse key image"); } // create transaction - uint64_t mixin = w2->adjust_mixin(request.ring_size == boost::none ? 0 : request.ring_size.get() - 1); - uint32_t priority = w2->adjust_priority(request.priority == boost::none ? 0 : request.priority.get()); - uint64_t unlock_time = request.unlock_time == boost::none ? 0 : request.unlock_time.get(); - std::vector ptx_vector = w2->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, 1, mixin, unlock_time, priority, extra); + uint64_t m_mixin = w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1); + uint32_t priority = w2->adjust_priority(request.m_priority == boost::none ? 0 : request.m_priority.get()); + uint64_t m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); + std::vector ptx_vector = w2->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, 1, m_mixin, m_unlock_time, priority, extra); // validate created transaction if (ptx_vector.empty()) throw runtime_error("No outputs found"); @@ -1854,7 +1854,7 @@ namespace monero { bool get_tx_keys = true; bool get_tx_hex = true; bool get_tx_metadata = true; - bool do_not_relay = request.do_not_relay == boost::none ? false : request.do_not_relay.get(); + bool m_do_not_relay = request.m_do_not_relay == boost::none ? false : request.m_do_not_relay.get(); // commit txs (if relaying) and get response using wallet rpc's fill_response() list tx_keys; @@ -1862,52 +1862,52 @@ namespace monero { list tx_fees; string multisig_tx_set; string unsigned_tx_set; - list tx_ids; + list m_tx_ids; list tx_blobs; list tx_metadatas; - if (!fill_response(w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_set, unsigned_tx_set, do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) { + if (!fill_response(w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_set, unsigned_tx_set, m_do_not_relay, m_tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) { throw runtime_error("need to handle error filling response!"); // TODO: return err message } // build sent txs from results // TODO: use common utility with send_split() to avoid code duplication vector> txs; - auto tx_ids_iter = tx_ids.begin(); + auto tx_ids_iter = m_tx_ids.begin(); auto tx_keys_iter = tx_keys.begin(); auto tx_amounts_iter = tx_amounts.begin(); auto tx_fees_iter = tx_fees.begin(); auto tx_blobs_iter = tx_blobs.begin(); auto tx_metadatas_iter = tx_metadatas.begin(); - while (tx_ids_iter != tx_ids.end()) { + while (tx_ids_iter != m_tx_ids.end()) { // init tx with outgoing transfer from filled values shared_ptr tx = make_shared(); txs.push_back(tx); - tx->id = *tx_ids_iter; - tx->key = *tx_keys_iter; - tx->fee = *tx_fees_iter; - tx->full_hex = *tx_blobs_iter; - tx->metadata = *tx_metadatas_iter; + tx->m_id = *tx_ids_iter; + tx->m_key = *tx_keys_iter; + tx->m_fee = *tx_fees_iter; + tx->m_full_hex = *tx_blobs_iter; + tx->m_metadata = *tx_metadatas_iter; shared_ptr out_transfer = make_shared(); - tx->outgoing_transfer = out_transfer; - out_transfer->amount = *tx_amounts_iter; + tx->m_outgoing_transfer = out_transfer; + out_transfer->m_amount = *tx_amounts_iter; // init other known fields - tx->payment_id = request.payment_id; - tx->is_confirmed = false; - tx->is_miner_tx = false; - tx->is_failed = false; // TODO: test and handle if true - tx->do_not_relay = request.do_not_relay != boost::none && request.do_not_relay.get() == true; - tx->is_relayed = tx->do_not_relay.get() != true; - tx->in_tx_pool = !tx->do_not_relay.get(); - if (!tx->is_failed.get() && tx->is_relayed.get()) tx->is_double_spend_seen = false; // TODO: test and handle if true - tx->num_confirmations = 0; - tx->mixin = request.mixin; - tx->unlock_time = request.unlock_time == boost::none ? 0 : request.unlock_time.get(); - if (tx->is_relayed.get()) tx->last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 - out_transfer->account_index = request.account_index; - if (request.subaddress_indices.size() == 1) out_transfer->subaddress_indices.push_back(request.subaddress_indices[0]); // subaddress index is known iff 1 requested // TODO: get all known subaddress indices here - out_transfer->destinations = request.destinations; - out_transfer->destinations[0]->amount = *tx_amounts_iter; + tx->m_payment_id = request.m_payment_id; + tx->m_is_confirmed = false; + tx->m_is_miner_tx = false; + tx->m_is_failed = false; // TODO: test and handle if true + tx->m_do_not_relay = request.m_do_not_relay != boost::none && request.m_do_not_relay.get() == true; + tx->m_is_relayed = tx->m_do_not_relay.get() != true; + tx->m_in_tx_pool = !tx->m_do_not_relay.get(); + if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true + tx->m_num_confirmations = 0; + tx->m_mixin = request.m_mixin; + tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); + if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 + out_transfer->m_account_index = request.m_account_index; + if (request.m_subaddress_indices.size() == 1) out_transfer->m_subaddress_indices.push_back(request.m_subaddress_indices[0]); // subaddress index is known iff 1 requested // TODO: get all known subaddress indices here + out_transfer->m_destinations = request.m_destinations; + out_transfer->m_destinations[0]->m_amount = *tx_amounts_iter; // iterate to next element tx_keys_iter++; @@ -1923,7 +1923,7 @@ namespace monero { return txs[0]; } - vector> monero_wallet::sweep_dust(bool do_not_relay) { + vector> monero_wallet::sweep_dust(bool m_do_not_relay) { MTRACE("monero_wallet::sweep_dust()"); // create transaction to fill @@ -1940,49 +1940,49 @@ namespace monero { list tx_fees; string multisig_tx_set; string unsigned_tx_set; - list tx_ids; + list m_tx_ids; list tx_blobs; list tx_metadatas; epee::json_rpc::error er; - if (!fill_response(w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_set, unsigned_tx_set, do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) { + if (!fill_response(w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_set, unsigned_tx_set, m_do_not_relay, m_tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) { throw runtime_error("need to handle error filling response!"); // TODO: return err message } // build sent txs from results // TODO: use common utility with send_split() to avoid code duplication vector> txs; - auto tx_ids_iter = tx_ids.begin(); + auto tx_ids_iter = m_tx_ids.begin(); auto tx_keys_iter = tx_keys.begin(); auto tx_amounts_iter = tx_amounts.begin(); auto tx_fees_iter = tx_fees.begin(); auto tx_blobs_iter = tx_blobs.begin(); auto tx_metadatas_iter = tx_metadatas.begin(); - while (tx_ids_iter != tx_ids.end()) { + while (tx_ids_iter != m_tx_ids.end()) { // init tx with outgoing transfer from filled values shared_ptr tx = make_shared(); txs.push_back(tx); - tx->id = *tx_ids_iter; - tx->key = *tx_keys_iter; - tx->fee = *tx_fees_iter; - tx->full_hex = *tx_blobs_iter; - tx->metadata = *tx_metadatas_iter; + tx->m_id = *tx_ids_iter; + tx->m_key = *tx_keys_iter; + tx->m_fee = *tx_fees_iter; + tx->m_full_hex = *tx_blobs_iter; + tx->m_metadata = *tx_metadatas_iter; shared_ptr out_transfer = make_shared(); - tx->outgoing_transfer = out_transfer; - out_transfer->amount = *tx_amounts_iter; + tx->m_outgoing_transfer = out_transfer; + out_transfer->m_amount = *tx_amounts_iter; // init other known fields - tx->is_confirmed = false; - tx->is_miner_tx = false; - tx->is_failed = false; // TODO: test and handle if true - tx->do_not_relay = do_not_relay; - tx->is_relayed = tx->do_not_relay.get() != true; - tx->in_tx_pool = !tx->do_not_relay.get(); - if (!tx->is_failed.get() && tx->is_relayed.get()) tx->is_double_spend_seen = false; // TODO: test and handle if true - tx->num_confirmations = 0; - //tx->mixin = request.mixin; // TODO: how to get? - tx->unlock_time = 0; - if (tx->is_relayed.get()) tx->last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 - out_transfer->destinations[0]->amount = *tx_amounts_iter; + tx->m_is_confirmed = false; + tx->m_is_miner_tx = false; + tx->m_is_failed = false; // TODO: test and handle if true + tx->m_do_not_relay = m_do_not_relay; + tx->m_is_relayed = tx->m_do_not_relay.get() != true; + tx->m_in_tx_pool = !tx->m_do_not_relay.get(); + if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true + tx->m_num_confirmations = 0; + //tx->m_mixin = request.m_mixin; // TODO: how to get? + tx->m_unlock_time = 0; + if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 + out_transfer->m_destinations[0]->m_amount = *tx_amounts_iter; // iterate to next element tx_keys_iter++; @@ -2000,7 +2000,7 @@ namespace monero { MTRACE("relay_txs()"); // relay each metadata as a tx - vector tx_ids; + vector m_tx_ids; for (const auto& txMetadata : tx_metadatas) { // parse tx metadata hex @@ -2027,11 +2027,11 @@ namespace monero { } // collect resulting id - tx_ids.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx))); + m_tx_ids.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx))); } // return relayed tx ids - return tx_ids; + return m_tx_ids; } string monero_wallet::get_tx_note(const string& tx_id) const { @@ -2044,10 +2044,10 @@ namespace monero { return w2->get_tx_note(tx_hash); } - vector monero_wallet::get_tx_notes(const vector& tx_ids) const { + vector monero_wallet::get_tx_notes(const vector& m_tx_ids) const { MTRACE("monero_wallet::get_tx_notes()"); vector notes; - for (const auto& tx_id : tx_ids) notes.push_back(get_tx_note(tx_id)); + for (const auto& tx_id : m_tx_ids) notes.push_back(get_tx_note(tx_id)); return notes; } @@ -2061,11 +2061,11 @@ namespace monero { w2->set_tx_note(tx_hash, note); } - void monero_wallet::set_tx_notes(const vector& tx_ids, const vector& notes) { + void monero_wallet::set_tx_notes(const vector& m_tx_ids, const vector& notes) { MTRACE("monero_wallet::set_tx_notes()"); - if (tx_ids.size() != notes.size()) throw runtime_error("Different amount of txids and notes"); - for (int i = 0; i < tx_ids.size(); i++) { - set_tx_note(tx_ids[i], notes[i]); + if (m_tx_ids.size() != notes.size()) throw runtime_error("Different amount of txids and notes"); + for (int i = 0; i < m_tx_ids.size(); i++) { + set_tx_note(m_tx_ids[i], notes[i]); } } @@ -2166,10 +2166,10 @@ namespace monero { uint64_t num_confirmations; w2->check_tx_key(tx_hash, tx_key, additional_tx_keys, info.address, received_amount, in_tx_pool, num_confirmations); shared_ptr checkTx = make_shared(); - checkTx->is_good = true; // check is good if we get this far - checkTx->received_amount = received_amount; - checkTx->in_tx_pool = in_tx_pool; - checkTx->num_confirmations = num_confirmations; + checkTx->m_is_good = true; // check is good if we get this far + checkTx->m_received_amount = received_amount; + checkTx->m_in_tx_pool = in_tx_pool; + checkTx->m_num_confirmations = num_confirmations; return checkTx; } @@ -2211,11 +2211,11 @@ namespace monero { uint64_t received_amount; bool in_tx_pool; uint64_t num_confirmations; - checkTx->is_good = w2->check_tx_proof(tx_hash, info.address, info.is_subaddress, message, signature, received_amount, in_tx_pool, num_confirmations); - if (checkTx->is_good) { - checkTx->received_amount = received_amount; - checkTx->in_tx_pool = in_tx_pool; - checkTx->num_confirmations = num_confirmations; + checkTx->m_is_good = w2->check_tx_proof(tx_hash, info.address, info.is_subaddress, message, signature, received_amount, in_tx_pool, num_confirmations); + if (checkTx->m_is_good) { + checkTx->m_received_amount = received_amount; + checkTx->m_in_tx_pool = in_tx_pool; + checkTx->m_num_confirmations = num_confirmations; } return checkTx; } @@ -2272,10 +2272,10 @@ namespace monero { shared_ptr checkReserve = make_shared(); uint64_t total_amount; uint64_t unconfirmed_spent_amount; - checkReserve->is_good = w2->check_reserve_proof(info.address, message, signature, total_amount, unconfirmed_spent_amount); - if (checkReserve->is_good) { - checkReserve->total_amount = total_amount; - checkReserve->unconfirmed_spent_amount = unconfirmed_spent_amount; + checkReserve->m_is_good = w2->check_reserve_proof(info.address, message, signature, total_amount, unconfirmed_spent_amount); + if (checkReserve->m_is_good) { + checkReserve->m_total_amount = total_amount; + checkReserve->m_unconfirmed_spent_amount = unconfirmed_spent_amount; } return checkReserve; } @@ -2284,20 +2284,20 @@ namespace monero { MTRACE("create_payment_uri()"); // validate request - if (request.destinations.size() != 1) throw runtime_error("Cannot make URI from supplied parameters: must provide exactly one destination to send funds"); - if (request.destinations.at(0)->address == boost::none) throw runtime_error("Cannot make URI from supplied parameters: must provide destination address"); - if (request.destinations.at(0)->amount == boost::none) throw runtime_error("Cannot make URI from supplied parameters: must provide destination amount"); + if (request.m_destinations.size() != 1) throw runtime_error("Cannot make URI from supplied parameters: must provide exactly one destination to send funds"); + if (request.m_destinations.at(0)->m_address == boost::none) throw runtime_error("Cannot make URI from supplied parameters: must provide destination address"); + if (request.m_destinations.at(0)->m_amount == boost::none) throw runtime_error("Cannot make URI from supplied parameters: must provide destination amount"); // prepare wallet2 params - string address = request.destinations.at(0)->address.get(); - string payment_id = request.payment_id == boost::none ? "" : request.payment_id.get(); - uint64_t amount = request.destinations.at(0)->amount.get(); - string note = request.note == boost::none ? "" : request.note.get(); - string recipient_name = request.recipient_name == boost::none ? "" : request.recipient_name.get(); + string address = request.m_destinations.at(0)->m_address.get(); + string payment_id = request.m_payment_id == boost::none ? "" : request.m_payment_id.get(); + uint64_t amount = request.m_destinations.at(0)->m_amount.get(); + string note = request.m_note == boost::none ? "" : request.m_note.get(); + string m_recipient_name = request.m_recipient_name == boost::none ? "" : request.m_recipient_name.get(); // make uri using wallet2 std::string error; - string uri = w2->make_uri(address, payment_id, amount, note, recipient_name, error); + string uri = w2->make_uri(address, payment_id, amount, note, m_recipient_name, error); if (uri.empty()) throw runtime_error("Cannot make URI from supplied parameters: " + error); return uri; } @@ -2310,22 +2310,22 @@ namespace monero { string payment_id; uint64_t amount = 0; string note; - string recipient_name; + string m_recipient_name; vector unknown_parameters; string error; - if (!w2->parse_uri(uri, address, payment_id, amount, note, recipient_name, unknown_parameters, error)) { + if (!w2->parse_uri(uri, address, payment_id, amount, note, m_recipient_name, unknown_parameters, error)) { throw runtime_error("Error parsing URI: " + error); } // initialize send request shared_ptr send_request = make_shared(); shared_ptr destination = make_shared(); - send_request->destinations.push_back(destination); - if (!address.empty()) destination->address = address; - destination->amount = amount; - if (!payment_id.empty()) send_request->payment_id = payment_id; - if (!note.empty()) send_request->note = note; - if (!recipient_name.empty()) send_request->recipient_name = recipient_name; + send_request->m_destinations.push_back(destination); + if (!address.empty()) destination->m_address = address; + destination->m_amount = amount; + if (!payment_id.empty()) send_request->m_payment_id = payment_id; + if (!note.empty()) send_request->m_note = note; + if (!m_recipient_name.empty()) send_request->m_recipient_name = m_recipient_name; if (!unknown_parameters.empty()) MWARNING("WARNING in monero_wallet::parse_payment_uri: URI contains unknown parameters which are discarded"); // TODO: return unknown parameters? return send_request; } @@ -2437,8 +2437,8 @@ namespace monero { bool rescan = rescan_on_sync.exchange(false); boost::lock_guard guarg(sync_mutex); // synchronize sync() and syncAsync() monero_sync_result result; - result.num_blocks_fetched = 0; - result.received_money = false; + result.m_num_blocks_fetched = 0; + result.m_received_money = false; do { // skip if daemon is not connected or synced if (is_connected && get_is_daemon_synced()) { @@ -2466,14 +2466,14 @@ namespace monero { // sync wallet and return result w2_listener->on_sync_start(sync_start_height, listener); monero_sync_result result; - w2->refresh(w2->is_trusted_daemon(), sync_start_height, result.num_blocks_fetched, result.received_money, true); + w2->refresh(w2->is_trusted_daemon(), sync_start_height, result.m_num_blocks_fetched, result.m_received_money, true); if (!is_synced) is_synced = true; w2_listener->on_sync_end(); return result; } // private helper to initialize subaddresses using transfer details - vector monero_wallet::get_subaddresses_aux(const uint32_t account_idx, const vector& subaddress_indices, const vector& transfers) const { + vector monero_wallet::get_subaddresses_aux(const uint32_t account_idx, const vector& m_subaddress_indices, const vector& transfers) const { vector subaddresses; // get balances per subaddress as maps @@ -2482,30 +2482,30 @@ namespace monero { // get all indices if no indices given vector subaddress_indices_req; - if (subaddress_indices.empty()) { + if (m_subaddress_indices.empty()) { for (uint32_t subaddress_idx = 0; subaddress_idx < w2->get_num_subaddresses(account_idx); subaddress_idx++) { subaddress_indices_req.push_back(subaddress_idx); } } else { - subaddress_indices_req = subaddress_indices; + subaddress_indices_req = m_subaddress_indices; } // initialize subaddresses at indices for (uint32_t subaddressIndicesIdx = 0; subaddressIndicesIdx < subaddress_indices_req.size(); subaddressIndicesIdx++) { monero_subaddress subaddress; - subaddress.account_index = account_idx; + subaddress.m_account_index = account_idx; uint32_t subaddress_idx = subaddress_indices_req.at(subaddressIndicesIdx); - subaddress.index = subaddress_idx; - subaddress.address = get_address(account_idx, subaddress_idx); - subaddress.label = w2->get_subaddress_label({account_idx, subaddress_idx}); + subaddress.m_index = subaddress_idx; + subaddress.m_address = get_address(account_idx, subaddress_idx); + subaddress.m_label = w2->get_subaddress_label({account_idx, subaddress_idx}); auto iter1 = balancePerSubaddress.find(subaddress_idx); - subaddress.balance = iter1 == balancePerSubaddress.end() ? 0 : iter1->second; + subaddress.m_balance = iter1 == balancePerSubaddress.end() ? 0 : iter1->second; auto iter2 = unlockedBalancePerSubaddress.find(subaddress_idx); - subaddress.unlocked_balance = iter2 == unlockedBalancePerSubaddress.end() ? 0 : iter2->second.first; + subaddress.m_unlocked_balance = iter2 == unlockedBalancePerSubaddress.end() ? 0 : iter2->second.first; cryptonote::subaddress_index index = {account_idx, subaddress_idx}; - subaddress.num_unspent_outputs = count_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return !td.m_spent && td.m_subaddr_index == index; }); - subaddress.is_used = find_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return td.m_subaddr_index == index; }) != transfers.end(); - subaddress.num_blocks_to_unlock = iter1 == balancePerSubaddress.end() ? 0 : iter2->second.second; + subaddress.m_num_unspent_outputs = count_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return !td.m_spent && td.m_subaddr_index == index; }); + subaddress.m_is_used = find_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return td.m_subaddr_index == index; }) != transfers.end(); + subaddress.m_num_blocks_to_unlock = iter1 == balancePerSubaddress.end() ? 0 : iter2->second.second; subaddresses.push_back(subaddress); } diff --git a/src/wallet/monero_wallet_model.cpp b/src/wallet/monero_wallet_model.cpp index 758aadd..c2f832d 100644 --- a/src/wallet/monero_wallet_model.cpp +++ b/src/wallet/monero_wallet_model.cpp @@ -67,7 +67,7 @@ namespace monero { void merge_incoming_transfer(vector>& transfers, const shared_ptr& transfer) { for (const shared_ptr& 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(src), static_pointer_cast(tgt)); // copy wallet extensions - if (!src->incoming_transfers.empty()) { - tgt->incoming_transfers = vector>(); - for (const shared_ptr& transfer : src->incoming_transfers) { + if (!src->m_incoming_transfers.empty()) { + tgt->m_incoming_transfers = vector>(); + for (const shared_ptr& transfer : src->m_incoming_transfers) { shared_ptr transferCopy = transfer->copy(transfer, make_shared()); - 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 transferCopy = src->outgoing_transfer.get()->copy(src->outgoing_transfer.get(), make_shared()); - transferCopy->tx = tgt; - tgt->outgoing_transfer = transferCopy; + if (src->m_outgoing_transfer != boost::none) { + shared_ptr transferCopy = src->m_outgoing_transfer.get()->copy(src->m_outgoing_transfer.get(), make_shared()); + 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& self, const shared_ptr& 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& 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& 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(src), static_pointer_cast(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(src->tx_ids); - tgt-> has_payment_id = src->has_payment_id; - if (!src->payment_ids.empty()) tgt->payment_ids = vector(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()); - if (src->output_request != boost::none) tgt->output_request = src->output_request.get()->copy(src->output_request.get(), make_shared()); + 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(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(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()); + if (src->m_output_request != boost::none) tgt->m_output_request = src->m_output_request.get()->copy(src->m_output_request.get(), make_shared()); 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& 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& 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 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::copy(const shared_ptr& src, const shared_ptr& tgt) const { MTRACE("monero_destination::copy(const shared_ptr& src, const shared_ptr& tgt)"); if (this != src.get()) throw runtime_error("this != src"); - tgt->address = src->address; - tgt->amount = src->amount; + 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::copy(const shared_ptr& src, const shared_ptr& tgt) const { MTRACE("monero_transfer::copy(const shared_ptr& src, const shared_ptr& tgt)"); - tgt->tx = src->tx; // reference parent tx by default - tgt->amount = src->amount; - tgt->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& self, const shared_ptr& 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& self, const shared_ptr& 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(src), static_pointer_cast(tgt)); // copy extensions - tgt->is_incoming = src->is_incoming; - tgt->address = src->address; - if (!src->addresses.empty()) tgt->addresses = vector(src->addresses); - tgt->subaddress_index = src->subaddress_index; - if (!src->subaddress_indices.empty()) tgt->subaddress_indices = vector(src->subaddress_indices); - if (!src->destinations.empty()) { - for (const shared_ptr& destination : src->destinations) { - tgt->destinations.push_back(destination->copy(destination, make_shared())); + tgt->m_is_incoming = src->m_is_incoming; + tgt->m_address = src->m_address; + if (!src->m_addresses.empty()) tgt->m_addresses = vector(src->m_addresses); + tgt->m_subaddress_index = src->m_subaddress_index; + if (!src->m_subaddress_indices.empty()) tgt->m_subaddress_indices = vector(src->m_subaddress_indices); + if (!src->m_destinations.empty()) { + for (const shared_ptr& destination : src->m_destinations) { + tgt->m_destinations.push_back(destination->copy(destination, make_shared())); } } - 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 monero_transfer_request::getIsIncoming() const { return is_incoming; } + boost::optional 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(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(src), static_pointer_cast(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(src), static_pointer_cast(tgt)); // copy extensions - if (!src->subaddress_indices.empty()) tgt->subaddress_indices = vector(src->subaddress_indices); + if (!src->m_subaddress_indices.empty()) tgt->m_subaddress_indices = vector(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(output->tx).get())) return false; + if (m_tx_request != boost::none && !(*m_tx_request)->meets_criteria(static_pointer_cast(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; } } diff --git a/src/wallet/monero_wallet_model.h b/src/wallet/monero_wallet_model.h index 3eb0a5a..b97f693 100644 --- a/src/wallet/monero_wallet_model.h +++ b/src/wallet/monero_wallet_model.h @@ -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 account_index; - boost::optional index; - boost::optional address; - boost::optional label; - boost::optional balance; - boost::optional unlocked_balance; - boost::optional num_unspent_outputs; - boost::optional is_used; - boost::optional num_blocks_to_unlock; + boost::optional m_account_index; + boost::optional m_index; + boost::optional m_address; + boost::optional m_label; + boost::optional m_balance; + boost::optional m_unlocked_balance; + boost::optional m_num_unspent_outputs; + boost::optional m_is_used; + boost::optional 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 index; - boost::optional primary_address; - boost::optional balance; - boost::optional unlocked_balance; - boost::optional tag; - vector subaddresses; + boost::optional m_index; + boost::optional m_primary_address; + boost::optional m_balance; + boost::optional m_unlocked_balance; + boost::optional m_tag; + vector 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 address; - boost::optional amount; + boost::optional m_address; + boost::optional m_amount; shared_ptr copy(const shared_ptr& src, const shared_ptr& 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 tx; - boost::optional amount; - boost::optional account_index; - boost::optional num_suggested_confirmations; + shared_ptr m_tx; + boost::optional m_amount; + boost::optional m_account_index; + boost::optional m_num_suggested_confirmations; virtual boost::optional getIsIncoming() const = 0; // derived class must implement shared_ptr copy(const shared_ptr& src, const shared_ptr& 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 subaddress_index; - boost::optional address; + boost::optional m_subaddress_index; + boost::optional m_address; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; @@ -177,9 +177,9 @@ namespace monero { * Models an outgoing transfer of funds from the wallet. */ struct monero_outgoing_transfer : public monero_transfer { - vector subaddress_indices; - vector addresses; - vector> destinations; + vector m_subaddress_indices; + vector m_addresses; + vector> m_destinations; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; @@ -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 is_incoming; - boost::optional address; - vector addresses; - boost::optional subaddress_index; - vector subaddress_indices; - vector> destinations; - boost::optional has_destinations; - boost::optional> tx_request; + boost::optional m_is_incoming; + boost::optional m_address; + vector m_addresses; + boost::optional m_subaddress_index; + vector m_subaddress_indices; + vector> m_destinations; + boost::optional m_has_destinations; + boost::optional> m_tx_request; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; @@ -215,11 +215,11 @@ namespace monero { * Models a Monero output with wallet extensions. */ struct monero_output_wallet : public monero_output { - boost::optional account_index; - boost::optional subaddress_index; - boost::optional is_spent; - boost::optional is_unlocked; - boost::optional is_frozen; + boost::optional m_account_index; + boost::optional m_subaddress_index; + boost::optional m_is_spent; + boost::optional m_is_unlocked; + boost::optional m_is_frozen; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; shared_ptr copy(const shared_ptr& src, const shared_ptr& 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 subaddress_indices; - boost::optional> tx_request; + vector m_subaddress_indices; + boost::optional> m_tx_request; // TODO: necessary to override all super classes? shared_ptr copy(const shared_ptr& src, const shared_ptr& 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> incoming_transfers; - boost::optional> outgoing_transfer; - boost::optional note; + vector> m_incoming_transfers; + boost::optional> m_outgoing_transfer; + boost::optional m_note; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; @@ -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 is_outgoing; - boost::optional is_incoming; - vector tx_ids; - boost::optional has_payment_id; - vector payment_ids; - boost::optional height; - boost::optional min_height; - boost::optional max_height; - boost::optional include_outputs; - boost::optional> transfer_request; - boost::optional> output_request; + boost::optional m_is_outgoing; + boost::optional m_is_incoming; + vector m_tx_ids; + boost::optional m_has_payment_id; + vector m_payment_ids; + boost::optional m_height; + boost::optional m_min_height; + boost::optional m_max_height; + boost::optional m_include_outputs; + boost::optional> m_transfer_request; + boost::optional> m_output_request; // TODO: necessary to override all super classes? shared_ptr copy(const shared_ptr& src, const shared_ptr& 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> destinations; - boost::optional payment_id; - boost::optional priority; - boost::optional mixin; - boost::optional ring_size; - boost::optional fee; - boost::optional account_index; - vector subaddress_indices; - boost::optional unlock_time; - boost::optional can_split; - boost::optional do_not_relay; - boost::optional note; - boost::optional recipient_name; - boost::optional below_amount; - boost::optional sweep_each_subaddress; - boost::optional key_image; + vector> m_destinations; + boost::optional m_payment_id; + boost::optional m_priority; + boost::optional m_mixin; + boost::optional m_ring_size; + boost::optional m_fee; + boost::optional m_account_index; + vector m_subaddress_indices; + boost::optional m_unlock_time; + boost::optional m_can_split; + boost::optional m_do_not_relay; + boost::optional m_note; + boost::optional m_recipient_name; + boost::optional m_below_amount; + boost::optional m_sweep_each_subaddress; + boost::optional 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 height; - boost::optional spent_amount; - boost::optional unspent_amount; + boost::optional m_height; + boost::optional m_spent_amount; + boost::optional 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 in_tx_pool; - boost::optional num_confirmations; - boost::optional received_amount; + boost::optional m_in_tx_pool; + boost::optional m_num_confirmations; + boost::optional 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 total_amount; - boost::optional unconfirmed_spent_amount; + boost::optional m_total_amount; + boost::optional m_unconfirmed_spent_amount; boost::property_tree::ptree to_property_tree() const; };