From dab90215bfe6fafd78fa2a2cfdbe570649723d6c Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 29 Nov 2019 09:42:13 -0500 Subject: [PATCH] refactor tx and output is_unlocked -> is_locked --- src/utils/monero_utils.cpp | 4 ++-- src/wallet/monero_wallet.cpp | 18 +++++++++--------- src/wallet/monero_wallet_model.cpp | 14 +++++++------- src/wallet/monero_wallet_model.h | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/utils/monero_utils.cpp b/src/utils/monero_utils.cpp index 198cbd2..f33087b 100644 --- a/src/utils/monero_utils.cpp +++ b/src/utils/monero_utils.cpp @@ -127,7 +127,7 @@ void node_to_output_wallet(const boost::property_tree::ptree& node, shared_ptrm_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("isLocked")) output_wallet->m_is_locked = it->second.get_value(); else if (key == string("isFrozen")) output_wallet->m_is_frozen = it->second.get_value(); } } @@ -198,7 +198,7 @@ void node_to_tx_wallet(const boost::property_tree::ptree& node, shared_ptrfirst; //if (key == string("id")) tx->m_id = it->second.data(); - if (key == string("isUnlocked")) tx_wallet->m_is_unlocked = it->second.get_value(); + if (key == string("isLocked")) tx_wallet->m_is_locked = it->second.get_value(); // TODO: deserialize other fields } } diff --git a/src/wallet/monero_wallet.cpp b/src/wallet/monero_wallet.cpp index f198965..b2549f8 100644 --- a/src/wallet/monero_wallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -103,7 +103,7 @@ namespace monero { 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_is_unlocked = m_w2.is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height); + tx->m_is_locked = !m_w2.is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height); tx->m_fee = pd.m_fee; tx->m_note = m_w2.get_tx_note(pd.m_tx_hash); if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note @@ -156,7 +156,7 @@ namespace monero { 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_is_unlocked = m_w2.is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height); + tx->m_is_locked = !m_w2.is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height); tx->m_fee = pd.m_amount_in - pd.m_amount_out; tx->m_note = m_w2.get_tx_note(txid); if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note @@ -224,7 +224,7 @@ namespace monero { 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_is_unlocked = false; + tx->m_is_locked = true; tx->m_fee = pd.m_fee; tx->m_note = m_w2.get_tx_note(pd.m_tx_hash); if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note @@ -266,7 +266,7 @@ namespace monero { 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_is_unlocked = false; + tx->m_is_locked = true; tx->m_fee = pd.m_amount_in - pd.m_amount_out; tx->m_note = m_w2.get_tx_note(txid); if (tx->m_note->empty()) tx->m_note = boost::none; // clear empty note @@ -335,7 +335,7 @@ namespace monero { tx->m_in_tx_pool = false; tx->m_do_not_relay = false; tx->m_is_double_spend_seen = false; - tx->m_is_unlocked = m_w2.is_transfer_unlocked(td); + tx->m_is_locked = !m_w2.is_transfer_unlocked(td); // construct vout shared_ptr vout = make_shared(); @@ -346,7 +346,7 @@ namespace monero { 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 = m_w2.is_transfer_unlocked(td); // TODO: this is redundant with tx + vout->m_is_locked = !m_w2.is_transfer_unlocked(td); // TODO: this is redundant with tx vout->m_is_frozen = td.m_frozen; if (td.m_key_image_known) { vout->m_key_image = make_shared(); @@ -1982,7 +1982,7 @@ namespace monero { 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(); - tx->m_is_unlocked = false; + tx->m_is_locked = true; 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 @@ -2137,7 +2137,7 @@ namespace monero { shared_ptr tx = make_shared(); txs.push_back(tx); tx->m_id = *tx_ids_iter; - tx->m_is_unlocked = false; + tx->m_is_locked = true; tx->m_is_outgoing = true; tx->m_key = *tx_keys_iter; tx->m_fee = *tx_fees_iter; @@ -2276,7 +2276,7 @@ namespace monero { 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(); - tx->m_is_unlocked = false; + tx->m_is_locked = true; 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 diff --git a/src/wallet/monero_wallet_model.cpp b/src/wallet/monero_wallet_model.cpp index e61c636..e9e284e 100644 --- a/src/wallet/monero_wallet_model.cpp +++ b/src/wallet/monero_wallet_model.cpp @@ -136,7 +136,7 @@ namespace monero { tgt->m_outgoing_transfer = transferCopy; } tgt->m_note = src->m_note; - tgt->m_is_unlocked = src->m_is_unlocked; + tgt->m_is_locked = src->m_is_locked; tgt->m_input_sum = src->m_input_sum; tgt->m_output_sum = src->m_output_sum; tgt->m_change_address = src->m_change_address; @@ -154,7 +154,7 @@ namespace monero { 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); - if (m_is_unlocked != boost::none) node.put("isUnlocked", *m_is_unlocked); + if (m_is_locked != boost::none) node.put("isLocked", *m_is_locked); if (m_input_sum != boost::none) node.put("inputSum", *m_input_sum); if (m_output_sum != boost::none) node.put("outputSum", *m_output_sum); if (m_change_address != boost::none) node.put("changeAddress", *m_change_address); @@ -194,7 +194,7 @@ namespace monero { m_is_incoming = gen_utils::reconcile(m_is_incoming, other->m_is_incoming); m_is_outgoing = gen_utils::reconcile(m_is_outgoing, other->m_is_outgoing); m_note = gen_utils::reconcile(m_note, other->m_note); - m_is_unlocked = gen_utils::reconcile(m_is_unlocked, other->m_is_unlocked); + m_is_locked = gen_utils::reconcile(m_is_locked, other->m_is_locked); m_input_sum = gen_utils::reconcile(m_input_sum, other->m_input_sum); m_output_sum = gen_utils::reconcile(m_output_sum, other->m_output_sum); m_change_address = gen_utils::reconcile(m_change_address, other->m_change_address); @@ -261,7 +261,7 @@ namespace monero { 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; - if (m_is_unlocked != boost::none && m_is_unlocked != tx->m_is_unlocked) return false; + if (m_is_locked != boost::none && m_is_locked != tx->m_is_locked) return false; // at least one transfer must meet transfer query if defined if (m_transfer_query != boost::none) { @@ -582,7 +582,7 @@ namespace monero { 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_locked = src->m_is_locked; tgt->m_is_frozen = src->m_is_frozen; return tgt; }; @@ -592,7 +592,7 @@ namespace monero { 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_locked != boost::none) node.put("isUnlocked", *m_is_locked); if (m_is_frozen != boost::none) node.put("isFrozen", *m_is_frozen); return node; } @@ -656,7 +656,7 @@ namespace monero { if (m_subaddress_index != boost::none && (output->m_subaddress_index == boost::none || *m_subaddress_index != *output->m_subaddress_index)) return false; if (m_amount != boost::none && (output->m_amount == boost::none || *m_amount != *output->m_amount)) return false; if (m_is_spent != boost::none && (output->m_is_spent == boost::none || *m_is_spent != *output->m_is_spent)) return false; - if (m_is_unlocked != boost::none && (output->m_is_unlocked == boost::none || *m_is_unlocked != *output->m_is_unlocked)) return false; + if (m_is_locked != boost::none && (output->m_is_locked == boost::none || *m_is_locked != *output->m_is_locked)) return false; // filter on output key image if (m_key_image != boost::none) { diff --git a/src/wallet/monero_wallet_model.h b/src/wallet/monero_wallet_model.h index c388c23..6626820 100644 --- a/src/wallet/monero_wallet_model.h +++ b/src/wallet/monero_wallet_model.h @@ -221,7 +221,7 @@ namespace monero { boost::optional m_account_index; boost::optional m_subaddress_index; boost::optional m_is_spent; - boost::optional m_is_unlocked; + boost::optional m_is_locked; boost::optional m_is_frozen; shared_ptr copy(const shared_ptr& src, const shared_ptr& tgt) const; @@ -263,7 +263,7 @@ namespace monero { vector> m_incoming_transfers; boost::optional> m_outgoing_transfer; boost::optional m_note; - boost::optional m_is_unlocked; + boost::optional m_is_locked; boost::optional m_input_sum; boost::optional m_output_sum; boost::optional m_change_address;