mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 23:58:59 +02:00
rename tx and block "id" to "hash"
This commit is contained in:
@@ -66,7 +66,7 @@ namespace monero {
|
||||
|
||||
void merge_tx(vector<shared_ptr<monero_tx>>& txs, const shared_ptr<monero_tx>& tx) {
|
||||
for (const shared_ptr<monero_tx>& aTx : txs) {
|
||||
if (aTx->m_id.get() == tx->m_id.get()) {
|
||||
if (aTx->m_hash.get() == tx->m_hash.get()) {
|
||||
aTx->merge(aTx, tx);
|
||||
return;
|
||||
}
|
||||
@@ -126,14 +126,14 @@ namespace monero {
|
||||
if (m_major_version != boost::none) monero_utils::addJsonMember("majorVersion", m_major_version.get(), allocator, root, value_num);
|
||||
if (m_minor_version != boost::none) monero_utils::addJsonMember("minorVersion", m_minor_version.get(), allocator, root, value_num);
|
||||
if (m_nonce != boost::none) monero_utils::addJsonMember("nonce", m_nonce.get(), allocator, root, value_num);
|
||||
if (m_miner_tx_id != boost::none) monero_utils::addJsonMember("minerTxId", m_miner_tx_id.get(), allocator, root, value_num);
|
||||
if (m_miner_tx_hash != boost::none) monero_utils::addJsonMember("minerTxHash", m_miner_tx_hash.get(), allocator, root, value_num);
|
||||
if (m_num_txs != boost::none) monero_utils::addJsonMember("numTxs", m_num_txs.get(), allocator, root, value_num);
|
||||
if (m_reward != boost::none) monero_utils::addJsonMember("reward", m_reward.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_id != boost::none) monero_utils::addJsonMember("id", m_id.get(), allocator, root, value_str);
|
||||
if (m_prev_id != boost::none) monero_utils::addJsonMember("prevId", m_prev_id.get(), allocator, root, value_str);
|
||||
if (m_hash != boost::none) monero_utils::addJsonMember("hash", m_hash.get(), allocator, root, value_str);
|
||||
if (m_prev_hash != boost::none) monero_utils::addJsonMember("prevHash", m_prev_hash.get(), allocator, root, value_str);
|
||||
if (m_pow_hash != boost::none) monero_utils::addJsonMember("powHash", m_pow_hash.get(), allocator, root, value_str);
|
||||
|
||||
// set bool values
|
||||
@@ -146,7 +146,7 @@ namespace monero {
|
||||
void monero_block_header::merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other) {
|
||||
if (this != self.get()) throw runtime_error("this != self");
|
||||
if (self == other) return;
|
||||
m_id = gen_utils::reconcile(m_id, other->m_id);
|
||||
m_hash = gen_utils::reconcile(m_hash, other->m_hash);
|
||||
m_height = gen_utils::reconcile(m_height, other->m_height, boost::none, boost::none, true, "block height"); // height can increase
|
||||
m_timestamp = gen_utils::reconcile(m_timestamp, other->m_timestamp, boost::none, boost::none, true, "block header timestamp"); // timestamp can increase
|
||||
m_size = gen_utils::reconcile(m_size, other->m_size, "block header size");
|
||||
@@ -158,10 +158,10 @@ namespace monero {
|
||||
m_major_version = gen_utils::reconcile(m_major_version, other->m_major_version, "m_major_version");
|
||||
m_minor_version = gen_utils::reconcile(m_minor_version, other->m_minor_version, "m_minor_version");
|
||||
m_nonce = gen_utils::reconcile(m_nonce, other->m_nonce, "m_nonce");
|
||||
m_miner_tx_id = gen_utils::reconcile(m_miner_tx_id, other->m_miner_tx_id);
|
||||
m_miner_tx_hash = gen_utils::reconcile(m_miner_tx_hash, other->m_miner_tx_hash);
|
||||
m_num_txs = gen_utils::reconcile(m_num_txs, other->m_num_txs, "block header m_num_txs");
|
||||
m_orphan_status = gen_utils::reconcile(m_orphan_status, other->m_orphan_status);
|
||||
m_prev_id = gen_utils::reconcile(m_prev_id, other->m_prev_id);
|
||||
m_prev_hash = gen_utils::reconcile(m_prev_hash, other->m_prev_hash);
|
||||
m_reward = gen_utils::reconcile(m_reward, other->m_reward, "block header m_reward");
|
||||
m_pow_hash = gen_utils::reconcile(m_pow_hash, other->m_pow_hash);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace monero {
|
||||
|
||||
// set sub-arrays
|
||||
if (!m_txs.empty()) root.AddMember("txs", monero_utils::to_rapidjson_val(allocator, m_txs), allocator);
|
||||
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_ids), allocator);
|
||||
if (!m_tx_hashes.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_hashes), allocator);
|
||||
|
||||
// set sub-objects
|
||||
if (m_miner_tx != boost::none) root.AddMember("minerTx", m_miner_tx.get()->to_rapidjson_val(allocator), allocator);
|
||||
@@ -201,7 +201,7 @@ namespace monero {
|
||||
|
||||
// merge reconcilable block extensions
|
||||
m_hex = gen_utils::reconcile(m_hex, other->m_hex);
|
||||
m_tx_ids = gen_utils::reconcile(m_tx_ids, other->m_tx_ids);
|
||||
m_tx_hashes = gen_utils::reconcile(m_tx_hashes, other->m_tx_hashes);
|
||||
|
||||
// merge miner tx
|
||||
if (m_miner_tx == boost::none) m_miner_tx = other->m_miner_tx;
|
||||
@@ -242,7 +242,7 @@ namespace monero {
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_id != boost::none) monero_utils::addJsonMember("id", m_id.get(), allocator, root, value_str);
|
||||
if (m_hash != boost::none) monero_utils::addJsonMember("hash", m_hash.get(), allocator, root, value_str);
|
||||
if (m_payment_id != boost::none) monero_utils::addJsonMember("paymentId", m_payment_id.get(), allocator, root, value_str);
|
||||
if (m_key != boost::none) monero_utils::addJsonMember("key", m_key.get(), allocator, root, value_str);
|
||||
if (m_full_hex != boost::none) monero_utils::addJsonMember("fullHex", m_full_hex.get(), allocator, root, value_str);
|
||||
@@ -253,8 +253,8 @@ namespace monero {
|
||||
if (m_common_tx_sets != boost::none) monero_utils::addJsonMember("commonTxSets", m_common_tx_sets.get(), allocator, root, value_str);
|
||||
if (m_rct_signatures != boost::none) monero_utils::addJsonMember("rctSignatures", m_rct_signatures.get(), allocator, root, value_str);
|
||||
if (m_rct_sig_prunable != boost::none) monero_utils::addJsonMember("rctSigPrunable", m_rct_sig_prunable.get(), allocator, root, value_str);
|
||||
if (m_last_failed_id != boost::none) monero_utils::addJsonMember("lastFailedId", m_last_failed_id.get(), allocator, root, value_str);
|
||||
if (m_max_used_block_id != boost::none) monero_utils::addJsonMember("maxUsedBlockId", m_max_used_block_id.get(), allocator, root, value_str);
|
||||
if (m_last_failed_hash != boost::none) monero_utils::addJsonMember("lastFailedHash", m_last_failed_hash.get(), allocator, root, value_str);
|
||||
if (m_max_used_block_hash != boost::none) monero_utils::addJsonMember("maxUsedBlockHash", m_max_used_block_hash.get(), allocator, root, value_str);
|
||||
|
||||
// set bool values
|
||||
if (m_is_miner_tx != boost::none) monero_utils::addJsonMember("isMinerTx", m_is_miner_tx.get(), allocator, root);
|
||||
@@ -282,7 +282,7 @@ namespace monero {
|
||||
// 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->m_id = it->second.data();
|
||||
if (key == string("hash")) tx->m_hash = it->second.data();
|
||||
else if (key == string("version")) throw runtime_error("version deserializationn not implemented");
|
||||
else if (key == string("isMinerTx")) tx->m_is_miner_tx = it->second.get_value<bool>();
|
||||
else if (key == string("paymentId")) tx->m_payment_id = it->second.data(); // TODO: this threw runtime_error, how is "Can get transactions by payment ids" test passing in Java?
|
||||
@@ -315,16 +315,16 @@ namespace monero {
|
||||
else if (key == string("isKeptByBlock")) tx->m_is_kept_by_block = it->second.get_value<bool>();
|
||||
else if (key == string("isFailed")) tx->m_is_failed = it->second.get_value<bool>();
|
||||
else if (key == string("lastFailedHeight")) throw runtime_error("lastFailedHeight deserialization not implemented");
|
||||
else if (key == string("lastFailedId")) tx->m_last_failed_id = it->second.data();
|
||||
else if (key == string("lastFailedHash")) tx->m_last_failed_hash = it->second.data();
|
||||
else if (key == string("maxUsedBlockHeight")) throw runtime_error("maxUsedBlockHeight deserialization not implemented");
|
||||
else if (key == string("maxUsedBlockId")) tx->m_max_used_block_id = it->second.data();
|
||||
else if (key == string("maxUsedBlockHash")) tx->m_max_used_block_hash = it->second.data();
|
||||
else if (key == string("signatures")) throw runtime_error("signatures deserialization not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<monero_tx> monero_tx::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const {
|
||||
MTRACE("monero_tx::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt)");
|
||||
tgt->m_id = src->m_id;
|
||||
tgt->m_hash = src->m_hash;
|
||||
tgt->m_version = src->m_version;
|
||||
tgt->m_is_miner_tx = src->m_is_miner_tx;
|
||||
tgt->m_payment_id = src->m_payment_id;
|
||||
@@ -371,9 +371,9 @@ namespace monero {
|
||||
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_last_failed_hash = src->m_last_failed_hash;
|
||||
tgt->m_max_used_block_height = src->m_max_used_block_height;
|
||||
tgt->m_max_used_block_id = src->m_max_used_block_id;
|
||||
tgt->m_max_used_block_hash = src->m_max_used_block_hash;
|
||||
if (!src->m_signatures.empty()) tgt->m_signatures = vector<string>(src->m_signatures);
|
||||
return tgt;
|
||||
}
|
||||
@@ -404,7 +404,7 @@ namespace monero {
|
||||
}
|
||||
|
||||
// otherwise merge tx fields
|
||||
m_id = gen_utils::reconcile(m_id, other->m_id);
|
||||
m_hash = gen_utils::reconcile(m_hash, other->m_hash);
|
||||
m_version = gen_utils::reconcile(m_version, other->m_version);
|
||||
m_payment_id = gen_utils::reconcile(m_payment_id, other->m_payment_id);
|
||||
m_fee = gen_utils::reconcile(m_fee, other->m_fee, "tx fee");
|
||||
@@ -429,9 +429,9 @@ namespace monero {
|
||||
m_is_kept_by_block = gen_utils::reconcile(m_is_kept_by_block, other->m_is_kept_by_block);
|
||||
m_is_failed = gen_utils::reconcile(m_is_failed, other->m_is_failed);
|
||||
m_last_failed_height = gen_utils::reconcile(m_last_failed_height, other->m_last_failed_height, "m_last_failed_height");
|
||||
m_last_failed_id = gen_utils::reconcile(m_last_failed_id, other->m_last_failed_id);
|
||||
m_last_failed_hash = gen_utils::reconcile(m_last_failed_hash, other->m_last_failed_hash);
|
||||
m_max_used_block_height = gen_utils::reconcile(m_max_used_block_height, other->m_max_used_block_height, "max_used_block_height");
|
||||
m_max_used_block_id = gen_utils::reconcile(m_max_used_block_id, other->m_max_used_block_id);
|
||||
m_max_used_block_hash = gen_utils::reconcile(m_max_used_block_hash, other->m_max_used_block_hash);
|
||||
//m_signatures = gen_utils::reconcile(m_signatures, other->m_signatures); // TODO
|
||||
m_unlock_time = gen_utils::reconcile(m_unlock_time, other->m_unlock_time, "m_unlock_time");
|
||||
m_num_confirmations = gen_utils::reconcile(m_num_confirmations, other->m_num_confirmations, "m_num_confirmations");
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace monero {
|
||||
* TODO: a header that is transmitted may have fewer fields like cryptonote::block_header; separate?
|
||||
*/
|
||||
struct monero_block_header : public serializable_struct {
|
||||
boost::optional<string> m_id;
|
||||
boost::optional<string> m_hash;
|
||||
boost::optional<uint64_t> m_height;
|
||||
boost::optional<uint64_t> m_timestamp;
|
||||
boost::optional<uint64_t> m_size;
|
||||
@@ -139,10 +139,10 @@ namespace monero {
|
||||
boost::optional<uint32_t> m_major_version;
|
||||
boost::optional<uint32_t> m_minor_version;
|
||||
boost::optional<uint32_t> m_nonce;
|
||||
boost::optional<string> m_miner_tx_id;
|
||||
boost::optional<string> m_miner_tx_hash;
|
||||
boost::optional<uint32_t> m_num_txs;
|
||||
boost::optional<bool> m_orphan_status;
|
||||
boost::optional<string> m_prev_id;
|
||||
boost::optional<string> m_prev_hash;
|
||||
boost::optional<uint64_t> m_reward;
|
||||
boost::optional<string> m_pow_hash;
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace monero {
|
||||
boost::optional<string> m_hex;
|
||||
boost::optional<shared_ptr<monero_tx>> m_miner_tx;
|
||||
vector<shared_ptr<monero_tx>> m_txs;
|
||||
vector<string> m_tx_ids;
|
||||
vector<string> m_tx_hashes;
|
||||
|
||||
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
|
||||
@@ -170,7 +170,7 @@ namespace monero {
|
||||
struct monero_tx : public serializable_struct {
|
||||
static const string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
|
||||
boost::optional<shared_ptr<monero_block>> m_block;
|
||||
boost::optional<string> m_id;
|
||||
boost::optional<string> m_hash;
|
||||
boost::optional<uint32_t> m_version;
|
||||
boost::optional<bool> m_is_miner_tx;
|
||||
boost::optional<string> m_payment_id;
|
||||
@@ -203,9 +203,9 @@ namespace monero {
|
||||
boost::optional<bool> m_is_kept_by_block;
|
||||
boost::optional<bool> m_is_failed;
|
||||
boost::optional<uint64_t> m_last_failed_height;
|
||||
boost::optional<string> m_last_failed_id;
|
||||
boost::optional<string> m_last_failed_hash;
|
||||
boost::optional<uint64_t> m_max_used_block_height;
|
||||
boost::optional<string> m_max_used_block_id;
|
||||
boost::optional<string> m_max_used_block_hash;
|
||||
vector<string> m_signatures;
|
||||
|
||||
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
|
||||
@@ -240,11 +240,11 @@ shared_ptr<monero_block> monero_utils::cn_block_to_block(const cryptonote::block
|
||||
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_prev_hash = 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->m_tx_ids.push_back(epee::string_tools::pod_to_hex(tx_hash));
|
||||
block->m_tx_hashes.push_back(epee::string_tools::pod_to_hex(tx_hash));
|
||||
}
|
||||
return block;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ shared_ptr<monero_tx> monero_utils::cn_tx_to_tx(const cryptonote::transaction& c
|
||||
shared_ptr<monero_tx> tx = init_as_tx_wallet ? make_shared<monero_tx_wallet>() : make_shared<monero_tx>();
|
||||
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_hash = epee::string_tools::pod_to_hex(cn_tx.hash);
|
||||
tx->m_extra = cn_tx.extra;
|
||||
|
||||
// init vins
|
||||
|
||||
@@ -66,6 +66,10 @@ namespace monero_utils
|
||||
using namespace std;
|
||||
using namespace cryptonote;
|
||||
|
||||
// ------------------------ CONSTANTS ---------------------------
|
||||
|
||||
static const int RING_SIZE = 12; // network-enforced ring size
|
||||
|
||||
// ------------------------ BINARY SERIALIZATION ----------------------------
|
||||
|
||||
void json_to_binary(const std::string &json, std::string &bin);
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace monero {
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
tx->m_block = block;
|
||||
block->m_txs.push_back(tx);
|
||||
tx->m_id = string_tools::pod_to_hex(pd.m_tx_hash);
|
||||
tx->m_hash = string_tools::pod_to_hex(pd.m_tx_hash);
|
||||
tx->m_is_incoming = true;
|
||||
tx->m_payment_id = string_tools::pod_to_hex(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
|
||||
@@ -149,7 +149,7 @@ namespace monero {
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
tx->m_block = block;
|
||||
block->m_txs.push_back(tx);
|
||||
tx->m_id = string_tools::pod_to_hex(txid);
|
||||
tx->m_hash = string_tools::pod_to_hex(txid);
|
||||
tx->m_is_outgoing = true;
|
||||
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
|
||||
@@ -217,7 +217,7 @@ namespace monero {
|
||||
// construct tx
|
||||
const tools::wallet2::payment_details &pd = ppd.m_pd;
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
tx->m_id = string_tools::pod_to_hex(pd.m_tx_hash);
|
||||
tx->m_hash = string_tools::pod_to_hex(pd.m_tx_hash);
|
||||
tx->m_is_incoming = true;
|
||||
tx->m_payment_id = string_tools::pod_to_hex(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
|
||||
@@ -259,7 +259,7 @@ namespace monero {
|
||||
// construct tx
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
tx->m_is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed;
|
||||
tx->m_id = string_tools::pod_to_hex(txid);
|
||||
tx->m_hash = string_tools::pod_to_hex(txid);
|
||||
tx->m_is_outgoing = true;
|
||||
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
|
||||
@@ -327,7 +327,7 @@ namespace monero {
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
tx->m_block = block;
|
||||
block->m_txs.push_back(tx);
|
||||
tx->m_id = epee::string_tools::pod_to_hex(td.m_txid);
|
||||
tx->m_hash = epee::string_tools::pod_to_hex(td.m_txid);
|
||||
tx->m_is_confirmed = true;
|
||||
tx->m_is_failed = false;
|
||||
tx->m_is_relayed = true;
|
||||
@@ -367,13 +367,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<monero_tx_wallet>& tx, map<string, shared_ptr<monero_tx_wallet>>& tx_map, map<uint64_t, shared_ptr<monero_block>>& block_map, bool skip_if_absent) {
|
||||
if (tx->m_id == boost::none) throw runtime_error("Tx id is not initialized");
|
||||
if (tx->m_hash == boost::none) throw runtime_error("Tx id is not initialized");
|
||||
|
||||
// if tx doesn't exist, add it (unless skipped)
|
||||
map<string, shared_ptr<monero_tx_wallet>>::const_iterator tx_iter = tx_map.find(*tx->m_id);
|
||||
map<string, shared_ptr<monero_tx_wallet>>::const_iterator tx_iter = tx_map.find(*tx->m_hash);
|
||||
if (tx_iter == tx_map.end()) {
|
||||
if (!skip_if_absent) {
|
||||
tx_map[*tx->m_id] = tx;
|
||||
tx_map[*tx->m_hash] = tx;
|
||||
} else {
|
||||
MWARNING("WARNING: tx does not already exist");
|
||||
}
|
||||
@@ -381,7 +381,7 @@ namespace monero {
|
||||
|
||||
// otherwise merge with existing tx
|
||||
else {
|
||||
shared_ptr<monero_tx_wallet>& a_tx = tx_map[*tx->m_id];
|
||||
shared_ptr<monero_tx_wallet>& a_tx = tx_map[*tx->m_hash];
|
||||
a_tx->merge(a_tx, tx);
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ namespace monero {
|
||||
shared_ptr<monero_tx_wallet> tx = static_pointer_cast<monero_tx_wallet>(monero_utils::cn_tx_to_tx(cn_tx, true));
|
||||
block->m_txs.push_back(tx);
|
||||
tx->m_block = block;
|
||||
tx->m_id = epee::string_tools::pod_to_hex(txid);
|
||||
tx->m_hash = epee::string_tools::pod_to_hex(txid);
|
||||
tx->m_unlock_time = unlock_time;
|
||||
shared_ptr<monero_output_wallet> output = make_shared<monero_output_wallet>();
|
||||
tx->m_vouts.push_back(output);
|
||||
@@ -741,7 +741,7 @@ namespace monero {
|
||||
shared_ptr<monero_tx_wallet> tx = static_pointer_cast<monero_tx_wallet>(monero_utils::cn_tx_to_tx(cn_tx_in, true));
|
||||
block->m_txs.push_back(tx);
|
||||
tx->m_block = block;
|
||||
tx->m_id = epee::string_tools::pod_to_hex(txid);
|
||||
tx->m_hash = epee::string_tools::pod_to_hex(txid);
|
||||
shared_ptr<monero_output_wallet> output = make_shared<monero_output_wallet>();
|
||||
tx->m_vins.push_back(output);
|
||||
output->m_tx = tx;
|
||||
@@ -1431,11 +1431,11 @@ namespace monero {
|
||||
txs = queried_txs;
|
||||
|
||||
// verify all specified tx ids found
|
||||
if (!_query->m_tx_ids.empty()) {
|
||||
for (const string& tx_id : _query->m_tx_ids) {
|
||||
if (!_query->m_tx_hashes.empty()) {
|
||||
for (const string& tx_id : _query->m_tx_hashes) {
|
||||
bool found = false;
|
||||
for (const shared_ptr<monero_tx_wallet>& tx : txs) {
|
||||
if (tx_id == *tx->m_id) {
|
||||
if (tx_id == *tx->m_hash) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -1451,9 +1451,9 @@ namespace monero {
|
||||
}
|
||||
|
||||
// otherwise order txs if tx ids given then return
|
||||
if (!_query->m_tx_ids.empty()) {
|
||||
if (!_query->m_tx_hashes.empty()) {
|
||||
vector<shared_ptr<monero_tx_wallet>> ordered_txs;
|
||||
for (const string& tx_id : _query->m_tx_ids) {
|
||||
for (const string& tx_id : _query->m_tx_hashes) {
|
||||
map<string, shared_ptr<monero_tx_wallet>>::const_iterator tx_iter = tx_map.find(tx_id);
|
||||
ordered_txs.push_back(tx_iter->second);
|
||||
}
|
||||
@@ -1875,7 +1875,7 @@ namespace monero {
|
||||
}
|
||||
|
||||
// prepare parameters for wallet2's create_transactions_2()
|
||||
uint64_t mixin = m_w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1);
|
||||
uint64_t mixin = m_w2->adjust_mixin(0); // get mixin for call to 'create_transactions_2'
|
||||
uint32_t priority = m_w2->adjust_priority(request.m_priority == boost::none ? 0 : request.m_priority.get());
|
||||
uint64_t unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get();
|
||||
uint32_t account_index = request.m_account_index.get();
|
||||
@@ -1923,7 +1923,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_id = *tx_ids_iter;
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
tx->m_fee = *tx_fees_iter;
|
||||
tx->m_full_hex = *tx_blobs_iter;
|
||||
@@ -1943,7 +1943,7 @@ namespace monero {
|
||||
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_ring_size = request.m_ring_size;
|
||||
tx->m_ring_size = monero_utils::RING_SIZE;
|
||||
tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get();
|
||||
tx->m_is_locked = true;
|
||||
if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast<uint64_t>(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2
|
||||
@@ -2057,7 +2057,7 @@ namespace monero {
|
||||
|
||||
// prepare parameters for wallet2's create_transactions_all()
|
||||
uint64_t below_amount = request.m_below_amount == boost::none ? 0 : request.m_below_amount.get();
|
||||
uint64_t mixin = m_w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1);
|
||||
uint64_t mixin = m_w2->adjust_mixin(0);
|
||||
uint32_t priority = m_w2->adjust_priority(request.m_priority == boost::none ? 0 : request.m_priority.get());
|
||||
uint64_t unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get();
|
||||
uint32_t account_index = request.m_account_index.get();
|
||||
@@ -2099,7 +2099,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_id = *tx_ids_iter;
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_is_locked = true;
|
||||
tx->m_is_outgoing = true;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
@@ -2122,7 +2122,7 @@ namespace monero {
|
||||
tx->m_in_tx_pool = !do_not_relay;
|
||||
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_ring_size = request.m_ring_size;
|
||||
tx->m_ring_size = monero_utils::RING_SIZE;
|
||||
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<uint64_t>(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;
|
||||
@@ -2174,7 +2174,7 @@ namespace monero {
|
||||
}
|
||||
|
||||
// create transaction
|
||||
uint64_t mixin = m_w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1);
|
||||
uint64_t mixin = m_w2->adjust_mixin(0);
|
||||
uint32_t priority = m_w2->adjust_priority(request.m_priority == boost::none ? 0 : request.m_priority.get());
|
||||
uint64_t unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get();
|
||||
std::vector<wallet2::pending_tx> ptx_vector = m_w2->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, 1, mixin, unlock_time, priority, extra);
|
||||
@@ -2217,7 +2217,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_id = *tx_ids_iter;
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_is_outgoing = true;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
tx->m_fee = *tx_fees_iter;
|
||||
@@ -2237,7 +2237,7 @@ namespace monero {
|
||||
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_ring_size = request.m_ring_size;
|
||||
tx->m_ring_size = monero_utils::RING_SIZE;
|
||||
tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get();
|
||||
tx->m_is_locked = true;
|
||||
if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast<uint64_t>(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2
|
||||
@@ -2304,7 +2304,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_id = *tx_ids_iter;
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_is_outgoing = true;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
tx->m_fee = *tx_fees_iter;
|
||||
@@ -2323,7 +2323,7 @@ namespace monero {
|
||||
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_ring_size = request.m_ring_size; // TODO: how to get?
|
||||
tx->m_ring_size = monero_utils::RING_SIZE;
|
||||
tx->m_unlock_time = 0;
|
||||
if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast<uint64_t>(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;
|
||||
@@ -3117,7 +3117,7 @@ namespace monero {
|
||||
monero_multisig_sign_result result;
|
||||
result.m_signed_multisig_tx_hex = signed_multisig_tx_hex;
|
||||
for (const crypto::hash& tx_hash : tx_hashes) {
|
||||
result.m_tx_ids.push_back(epee::string_tools::pod_to_hex(tx_hash));
|
||||
result.m_tx_hashes.push_back(epee::string_tools::pod_to_hex(tx_hash));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace monero {
|
||||
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
//if (key == string("id")) tx->m_id = it->second.data();
|
||||
//if (key == string("id")) tx->m_hash = it->second.data();
|
||||
if (key == string("isLocked")) tx_wallet->m_is_locked = it->second.get_value<bool>();
|
||||
// TODO: deserialize other fields
|
||||
}
|
||||
@@ -308,7 +308,7 @@ namespace monero {
|
||||
if (m_include_outputs != boost::none) monero_utils::addJsonMember("includeOutputs", m_include_outputs.get(), allocator, root);
|
||||
|
||||
// set sub-arrays
|
||||
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_ids), allocator);
|
||||
if (!m_tx_hashes.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_hashes), allocator);
|
||||
if (!m_payment_ids.empty()) root.AddMember("paymentIds", monero_utils::to_rapidjson_val(allocator, m_payment_ids), allocator);
|
||||
|
||||
// set sub-objects
|
||||
@@ -326,7 +326,7 @@ namespace monero {
|
||||
string key = it->first;
|
||||
if (key == string("isOutgoing")) tx_query->m_is_outgoing = it->second.get_value<bool>();
|
||||
else if (key == string("isIncoming")) tx_query->m_is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_query->m_tx_ids.push_back(it2->second.data());
|
||||
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_query->m_tx_hashes.push_back(it2->second.data());
|
||||
else if (key == string("hasPaymentId")) tx_query->m_has_payment_id = it->second.get_value<bool>();
|
||||
else if (key == string("paymentIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_query->m_payment_ids.push_back(it2->second.data());
|
||||
else if (key == string("height")) tx_query->m_height = it->second.get_value<uint64_t>();
|
||||
@@ -379,7 +379,7 @@ namespace monero {
|
||||
// copy query extensions
|
||||
tgt->m_is_outgoing = src->m_is_outgoing;
|
||||
tgt->m_is_incoming = src->m_is_incoming;
|
||||
if (!src->m_tx_ids.empty()) tgt->m_tx_ids = vector<string>(src->m_tx_ids);
|
||||
if (!src->m_tx_hashes.empty()) tgt->m_tx_hashes = vector<string>(src->m_tx_hashes);
|
||||
tgt-> m_has_payment_id = src->m_has_payment_id;
|
||||
if (!src->m_payment_ids.empty()) tgt->m_payment_ids = vector<string>(src->m_payment_ids);
|
||||
tgt->m_height = src->m_height;
|
||||
@@ -395,7 +395,7 @@ namespace monero {
|
||||
if (tx == nullptr) return false;
|
||||
|
||||
// filter on tx
|
||||
if (m_id != boost::none && m_id != tx->m_id) return false;
|
||||
if (m_hash != boost::none && m_hash != tx->m_hash) 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;
|
||||
@@ -447,7 +447,7 @@ namespace monero {
|
||||
|
||||
// filter on remaining fields
|
||||
boost::optional<uint64_t> txHeight = tx->get_height();
|
||||
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_tx_hashes.empty() && find(m_tx_hashes.begin(), m_tx_hashes.end(), *tx->m_hash) == m_tx_hashes.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;
|
||||
@@ -1253,7 +1253,7 @@ namespace monero {
|
||||
if (m_signed_multisig_tx_hex != boost::none) monero_utils::addJsonMember("signedMultisigTxHex", m_signed_multisig_tx_hex.get(), allocator, root, value_str);
|
||||
|
||||
// set sub-arrays
|
||||
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_ids), allocator);
|
||||
if (!m_tx_hashes.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_hashes), allocator);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace monero {
|
||||
struct monero_tx_query : public monero_tx_wallet {
|
||||
boost::optional<bool> m_is_outgoing;
|
||||
boost::optional<bool> m_is_incoming;
|
||||
vector<string> m_tx_ids;
|
||||
vector<string> m_tx_hashes;
|
||||
boost::optional<bool> m_has_payment_id;
|
||||
vector<string> m_payment_ids;
|
||||
boost::optional<uint64_t> m_height;
|
||||
@@ -430,7 +430,7 @@ namespace monero {
|
||||
*/
|
||||
struct monero_multisig_sign_result : serializable_struct {
|
||||
boost::optional<string> m_signed_multisig_tx_hex;
|
||||
vector<string> m_tx_ids;
|
||||
vector<string> m_tx_hashes;
|
||||
|
||||
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user