refactor tx and output is_unlocked -> is_locked

This commit is contained in:
woodser
2019-11-29 09:42:13 -05:00
parent 96301d1f9e
commit dab90215bf
4 changed files with 20 additions and 20 deletions
+2 -2
View File
@@ -127,7 +127,7 @@ void node_to_output_wallet(const boost::property_tree::ptree& node, shared_ptr<m
if (key == string("accountIndex")) output_wallet->m_account_index = it->second.get_value<uint32_t>();
else if (key == string("subaddressIndex")) output_wallet->m_subaddress_index = it->second.get_value<uint32_t>();
else if (key == string("isSpent")) output_wallet->m_is_spent = it->second.get_value<bool>();
else if (key == string("isUnlocked")) output_wallet->m_is_unlocked = it->second.get_value<bool>();
else if (key == string("isLocked")) output_wallet->m_is_locked = it->second.get_value<bool>();
else if (key == string("isFrozen")) output_wallet->m_is_frozen = it->second.get_value<bool>();
}
}
@@ -198,7 +198,7 @@ void node_to_tx_wallet(const boost::property_tree::ptree& node, shared_ptr<moner
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
//if (key == string("id")) tx->m_id = it->second.data();
if (key == string("isUnlocked")) tx_wallet->m_is_unlocked = it->second.get_value<bool>();
if (key == string("isLocked")) tx_wallet->m_is_locked = it->second.get_value<bool>();
// TODO: deserialize other fields
}
}
+9 -9
View File
@@ -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<monero_output_wallet> vout = make_shared<monero_output_wallet>();
@@ -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<monero_key_image>();
@@ -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<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;
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<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
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<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;
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
+7 -7
View File
@@ -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) {
+2 -2
View File
@@ -221,7 +221,7 @@ namespace monero {
boost::optional<uint32_t> m_account_index;
boost::optional<uint32_t> m_subaddress_index;
boost::optional<bool> m_is_spent;
boost::optional<bool> m_is_unlocked;
boost::optional<bool> m_is_locked;
boost::optional<bool> m_is_frozen;
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
@@ -263,7 +263,7 @@ namespace monero {
vector<shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
boost::optional<shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
boost::optional<string> m_note;
boost::optional<bool> m_is_unlocked;
boost::optional<bool> m_is_locked;
boost::optional<uint64_t> m_input_sum;
boost::optional<uint64_t> m_output_sum;
boost::optional<string> m_change_address;