aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp51
-rw-r--r--src/wallet/wallet2.h3
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h216
3 files changed, 104 insertions, 166 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 51ee9cdca..78c0f6328 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -1169,7 +1169,6 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std
m_refresh_from_block_height(0),
m_explicit_refresh_from_block_height(true),
m_skip_to_height(0),
- m_confirm_non_default_ring_size(true),
m_ask_password(AskPasswordToDecrypt),
m_max_reorg_depth(ORPHANED_BLOCKS_MAX_COUNT),
m_min_output_count(0),
@@ -1972,6 +1971,36 @@ bool wallet2::frozen(size_t idx) const
return td.m_frozen;
}
//----------------------------------------------------------------------------------------------------
+bool wallet2::frozen(const multisig_tx_set& txs) const
+{
+ // Each call to frozen(const key_image&) is O(N), so if we didn't use batching like we did here,
+ // this op would be O(M * N) instead of O(M + N). N = # wallet transfers, M = # key images in set.
+ // Step 1. Collect all key images from all pending txs into set
+ std::unordered_set<crypto::key_image> kis_to_sign;
+ for (const auto& ptx : txs.m_ptx)
+ {
+ const tools::wallet2::tx_construction_data& cd = ptx.construction_data;
+ CHECK_AND_ASSERT_THROW_MES(cd.sources.size() == ptx.tx.vin.size(), "mismatched multisg tx set source sizes");
+ for (size_t src_idx = 0; src_idx < cd.sources.size(); ++src_idx)
+ {
+ // Check that the key images are consistent between tx vin and construction data
+ const crypto::key_image multisig_ki = rct::rct2ki(cd.sources[src_idx].multisig_kLRki.ki);
+ CHECK_AND_ASSERT_THROW_MES(ptx.tx.vin[src_idx].type() == typeid(cryptonote::txin_to_key), "multisig tx cannot be miner");
+ const crypto::key_image vin_ki = boost::get<cryptonote::txin_to_key>(ptx.tx.vin[src_idx]).k_image;
+ CHECK_AND_ASSERT_THROW_MES(multisig_ki == vin_ki, "Mismatched key image b/t vin and construction data");
+
+ // Add key image to set
+ kis_to_sign.insert(multisig_ki);
+ }
+ }
+ // Step 2. Scan all transfers for frozen key images
+ for (const auto& td : m_transfers)
+ if (td.m_frozen && kis_to_sign.count(td.m_key_image))
+ return true;
+
+ return false;
+}
+//----------------------------------------------------------------------------------------------------
void wallet2::freeze(const crypto::key_image &ki)
{
freeze(get_transfer_details(ki));
@@ -1992,8 +2021,13 @@ size_t wallet2::get_transfer_details(const crypto::key_image &ki) const
for (size_t idx = 0; idx < m_transfers.size(); ++idx)
{
const transfer_details &td = m_transfers[idx];
- if (td.m_key_image_known && td.m_key_image == ki)
- return idx;
+ if (td.m_key_image == ki)
+ {
+ if (td.m_key_image_known)
+ return idx;
+ else if (td.m_key_image_partial)
+ CHECK_AND_ASSERT_THROW_MES(false, "Transfer detail lookups are not allowed for multisig partial key images");
+ }
}
CHECK_AND_ASSERT_THROW_MES(false, "Key image not found");
}
@@ -4390,7 +4424,7 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
value2.SetUint64(m_skip_to_height);
json.AddMember("skip_to_height", value2, json.GetAllocator());
- value2.SetInt(m_confirm_non_default_ring_size ? 1 :0);
+ value2.SetInt(1); // exists for deserialization backwards compatibility
json.AddMember("confirm_non_default_ring_size", value2, json.GetAllocator());
value2.SetInt(m_ask_password);
@@ -4623,7 +4657,6 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st
m_refresh_type = RefreshType::RefreshDefault;
m_refresh_from_block_height = 0;
m_skip_to_height = 0;
- m_confirm_non_default_ring_size = true;
m_ask_password = AskPasswordToDecrypt;
cryptonote::set_default_decimal_point(CRYPTONOTE_DISPLAY_DECIMAL_POINT);
m_max_reorg_depth = ORPHANED_BLOCKS_MAX_COUNT;
@@ -4775,8 +4808,6 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st
m_refresh_from_block_height = field_refresh_height;
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, skip_to_height, uint64_t, Uint64, false, 0);
m_skip_to_height = field_skip_to_height;
- GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, confirm_non_default_ring_size, int, Int, false, true);
- m_confirm_non_default_ring_size = field_confirm_non_default_ring_size;
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, ask_password, AskPasswordType, Int, false, AskPasswordToDecrypt);
m_ask_password = field_ask_password;
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_decimal_point, int, Int, false, CRYPTONOTE_DISPLAY_DECIMAL_POINT);
@@ -6360,6 +6391,8 @@ std::map<uint32_t, uint64_t> wallet2::balance_per_subaddress(uint32_t index_majo
std::map<uint32_t, uint64_t> amount_per_subaddr;
for (const auto& td: m_transfers)
{
+ if (td.amount() > m_ignore_outputs_above || td.amount() < m_ignore_outputs_below)
+ continue;
if (td.m_subaddr_index.major == index_major && !is_spent(td, strict) && !td.m_frozen)
{
auto found = amount_per_subaddr.find(td.m_subaddr_index.minor);
@@ -6415,6 +6448,8 @@ std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> wallet2::
const uint64_t now = time(NULL);
for(const transfer_details& td: m_transfers)
{
+ if (td.amount() > m_ignore_outputs_above || td.amount() < m_ignore_outputs_below)
+ continue;
if(td.m_subaddr_index.major == index_major && !is_spent(td, strict) && !td.m_frozen)
{
uint64_t amount = 0, blocks_to_unlock = 0, time_to_unlock = 0;
@@ -7646,6 +7681,8 @@ bool wallet2::sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto
error::wallet_internal_error, "Transaction was signed by too many signers");
THROW_WALLET_EXCEPTION_IF(exported_txs.m_signers.size() == m_multisig_threshold,
error::wallet_internal_error, "Transaction is already fully signed");
+ THROW_WALLET_EXCEPTION_IF(frozen(exported_txs),
+ error::wallet_internal_error, "Will not sign multisig tx containing frozen outputs")
txids.clear();
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 554a766bf..9c310f692 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -1342,8 +1342,6 @@ private:
void segregation_height(uint64_t height) { m_segregation_height = height; }
bool ignore_fractional_outputs() const { return m_ignore_fractional_outputs; }
void ignore_fractional_outputs(bool value) { m_ignore_fractional_outputs = value; }
- bool confirm_non_default_ring_size() const { return m_confirm_non_default_ring_size; }
- void confirm_non_default_ring_size(bool always) { m_confirm_non_default_ring_size = always; }
uint64_t ignore_outputs_above() const { return m_ignore_outputs_above; }
void ignore_outputs_above(uint64_t value) { m_ignore_outputs_above = value; }
uint64_t ignore_outputs_below() const { return m_ignore_outputs_below; }
@@ -1616,6 +1614,7 @@ private:
void thaw(const crypto::key_image &ki);
bool frozen(const crypto::key_image &ki) const;
bool frozen(const transfer_details &td) const;
+ bool frozen(const multisig_tx_set& txs) const; // does partially signed txset contain frozen enotes?
bool save_to_file(const std::string& path_to_file, const std::string& binary, bool is_printable = false) const;
static bool load_from_file(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000);
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 72719e982..002db4289 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -530,6 +530,33 @@ namespace wallet_rpc
END_KV_SERIALIZE_MAP()
};
+ struct single_transfer_response
+ {
+ std::string tx_hash;
+ std::string tx_key;
+ uint64_t amount;
+ uint64_t fee;
+ uint64_t weight;
+ std::string tx_blob;
+ std::string tx_metadata;
+ std::string multisig_txset;
+ std::string unsigned_txset;
+ key_image_list spent_key_images;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(tx_hash)
+ KV_SERIALIZE(tx_key)
+ KV_SERIALIZE(amount)
+ KV_SERIALIZE(fee)
+ KV_SERIALIZE(weight)
+ KV_SERIALIZE(tx_blob)
+ KV_SERIALIZE(tx_metadata)
+ KV_SERIALIZE(multisig_txset)
+ KV_SERIALIZE(unsigned_txset)
+ KV_SERIALIZE(spent_key_images)
+ END_KV_SERIALIZE_MAP()
+ };
+
struct COMMAND_RPC_TRANSFER
{
struct request_t
@@ -562,35 +589,37 @@ namespace wallet_rpc
};
typedef epee::misc_utils::struct_init<request_t> request;
- struct response_t
- {
- std::string tx_hash;
- std::string tx_key;
- uint64_t amount;
- uint64_t fee;
- uint64_t weight;
- std::string tx_blob;
- std::string tx_metadata;
- std::string multisig_txset;
- std::string unsigned_txset;
- key_image_list spent_key_images;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tx_hash)
- KV_SERIALIZE(tx_key)
- KV_SERIALIZE(amount)
- KV_SERIALIZE(fee)
- KV_SERIALIZE(weight)
- KV_SERIALIZE(tx_blob)
- KV_SERIALIZE(tx_metadata)
- KV_SERIALIZE(multisig_txset)
- KV_SERIALIZE(unsigned_txset)
- KV_SERIALIZE(spent_key_images)
- END_KV_SERIALIZE_MAP()
- };
+ typedef single_transfer_response response_t;
typedef epee::misc_utils::struct_init<response_t> response;
};
+ struct split_transfer_response
+ {
+ std::list<std::string> tx_hash_list;
+ std::list<std::string> tx_key_list;
+ std::list<uint64_t> amount_list;
+ std::list<uint64_t> fee_list;
+ std::list<uint64_t> weight_list;
+ std::list<std::string> tx_blob_list;
+ std::list<std::string> tx_metadata_list;
+ std::string multisig_txset;
+ std::string unsigned_txset;
+ std::list<key_image_list> spent_key_images_list;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(tx_hash_list)
+ KV_SERIALIZE(tx_key_list)
+ KV_SERIALIZE(amount_list)
+ KV_SERIALIZE(fee_list)
+ KV_SERIALIZE(weight_list)
+ KV_SERIALIZE(tx_blob_list)
+ KV_SERIALIZE(tx_metadata_list)
+ KV_SERIALIZE(multisig_txset)
+ KV_SERIALIZE(unsigned_txset)
+ KV_SERIALIZE(spent_key_images_list)
+ END_KV_SERIALIZE_MAP()
+ };
+
struct COMMAND_RPC_TRANSFER_SPLIT
{
struct request_t
@@ -623,41 +652,7 @@ namespace wallet_rpc
};
typedef epee::misc_utils::struct_init<request_t> request;
- struct key_list
- {
- std::list<std::string> keys;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(keys)
- END_KV_SERIALIZE_MAP()
- };
-
- struct response_t
- {
- std::list<std::string> tx_hash_list;
- std::list<std::string> tx_key_list;
- std::list<uint64_t> amount_list;
- std::list<uint64_t> fee_list;
- std::list<uint64_t> weight_list;
- std::list<std::string> tx_blob_list;
- std::list<std::string> tx_metadata_list;
- std::string multisig_txset;
- std::string unsigned_txset;
- std::list<key_image_list> spent_key_images_list;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tx_hash_list)
- KV_SERIALIZE(tx_key_list)
- KV_SERIALIZE(amount_list)
- KV_SERIALIZE(fee_list)
- KV_SERIALIZE(weight_list)
- KV_SERIALIZE(tx_blob_list)
- KV_SERIALIZE(tx_metadata_list)
- KV_SERIALIZE(multisig_txset)
- KV_SERIALIZE(unsigned_txset)
- KV_SERIALIZE(spent_key_images_list)
- END_KV_SERIALIZE_MAP()
- };
+ typedef split_transfer_response response_t;
typedef epee::misc_utils::struct_init<response_t> response;
};
@@ -821,41 +816,7 @@ namespace wallet_rpc
};
typedef epee::misc_utils::struct_init<request_t> request;
- struct key_list
- {
- std::list<std::string> keys;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(keys)
- END_KV_SERIALIZE_MAP()
- };
-
- struct response_t
- {
- std::list<std::string> tx_hash_list;
- std::list<std::string> tx_key_list;
- std::list<uint64_t> amount_list;
- std::list<uint64_t> fee_list;
- std::list<uint64_t> weight_list;
- std::list<std::string> tx_blob_list;
- std::list<std::string> tx_metadata_list;
- std::string multisig_txset;
- std::string unsigned_txset;
- std::list<key_image_list> spent_key_images_list;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tx_hash_list)
- KV_SERIALIZE(tx_key_list)
- KV_SERIALIZE(amount_list)
- KV_SERIALIZE(fee_list)
- KV_SERIALIZE(weight_list)
- KV_SERIALIZE(tx_blob_list)
- KV_SERIALIZE(tx_metadata_list)
- KV_SERIALIZE(multisig_txset)
- KV_SERIALIZE(unsigned_txset)
- KV_SERIALIZE(spent_key_images_list)
- END_KV_SERIALIZE_MAP()
- };
+ typedef split_transfer_response response_t;
typedef epee::misc_utils::struct_init<response_t> response;
};
@@ -897,41 +858,7 @@ namespace wallet_rpc
};
typedef epee::misc_utils::struct_init<request_t> request;
- struct key_list
- {
- std::list<std::string> keys;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(keys)
- END_KV_SERIALIZE_MAP()
- };
-
- struct response_t
- {
- std::list<std::string> tx_hash_list;
- std::list<std::string> tx_key_list;
- std::list<uint64_t> amount_list;
- std::list<uint64_t> fee_list;
- std::list<uint64_t> weight_list;
- std::list<std::string> tx_blob_list;
- std::list<std::string> tx_metadata_list;
- std::string multisig_txset;
- std::string unsigned_txset;
- std::list<key_image_list> spent_key_images_list;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tx_hash_list)
- KV_SERIALIZE(tx_key_list)
- KV_SERIALIZE(amount_list)
- KV_SERIALIZE(fee_list)
- KV_SERIALIZE(weight_list)
- KV_SERIALIZE(tx_blob_list)
- KV_SERIALIZE(tx_metadata_list)
- KV_SERIALIZE(multisig_txset)
- KV_SERIALIZE(unsigned_txset)
- KV_SERIALIZE(spent_key_images_list)
- END_KV_SERIALIZE_MAP()
- };
+ typedef split_transfer_response response_t;
typedef epee::misc_utils::struct_init<response_t> response;
};
@@ -967,32 +894,7 @@ namespace wallet_rpc
};
typedef epee::misc_utils::struct_init<request_t> request;
- struct response_t
- {
- std::string tx_hash;
- std::string tx_key;
- uint64_t amount;
- uint64_t fee;
- uint64_t weight;
- std::string tx_blob;
- std::string tx_metadata;
- std::string multisig_txset;
- std::string unsigned_txset;
- key_image_list spent_key_images;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tx_hash)
- KV_SERIALIZE(tx_key)
- KV_SERIALIZE(amount)
- KV_SERIALIZE(fee)
- KV_SERIALIZE(weight)
- KV_SERIALIZE(tx_blob)
- KV_SERIALIZE(tx_metadata)
- KV_SERIALIZE(multisig_txset)
- KV_SERIALIZE(unsigned_txset)
- KV_SERIALIZE(spent_key_images)
- END_KV_SERIALIZE_MAP()
- };
+ typedef single_transfer_response response_t;
typedef epee::misc_utils::struct_init<response_t> response;
};