summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/wownero/0004-coin-control.patch233
1 files changed, 175 insertions, 58 deletions
diff --git a/patches/wownero/0004-coin-control.patch b/patches/wownero/0004-coin-control.patch
index b47c075..1a7d08c 100644
--- a/patches/wownero/0004-coin-control.patch
+++ b/patches/wownero/0004-coin-control.patch
@@ -1,36 +1,16 @@
From bb9282a07934c0d4c389e6e10971f5e6f9f563b7 Mon Sep 17 00:00:00 2001
From: Czarek Nakamoto <cyjan@mrcyjanek.net>
-Date: Tue, 26 Mar 2024 09:41:28 +0100
+Date: Wed, 27 Mar 2024 14:33:07 +0100
Subject: [PATCH] coin control
---
- src/simplewallet/simplewallet.cpp | 4 ++--
- src/wallet/api/wallet.cpp | 5 +++--
- src/wallet/wallet2.cpp | 2 +-
- src/wallet/wallet2.h | 3 ++-
- src/wallet/wallet_rpc_server.cpp | 2 +-
- 5 files changed, 9 insertions(+), 7 deletions(-)
+ src/wallet/api/wallet.cpp | 5 +++--
+ src/wallet/api/wallet2_api.h | 3 +++
+ src/wallet/wallet2.cpp | 21 +++++++++++++++++++++
+ src/wallet/wallet2.h | 3 +++
+ src/wallet/api/coins.cpp |
+ 4 files changed, 29 insertions(+), 2 deletions(-)
-diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
-index 754f088d6..c2e470a9b 100644
---- a/src/simplewallet/simplewallet.cpp
-+++ b/src/simplewallet/simplewallet.cpp
-@@ -7043,13 +7043,13 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
- return false;
- }
- unlock_block = bc_height + locked_blocks;
-- ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, unlock_block /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, subtract_fee_from_outputs);
-+ ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, unlock_block /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, {}, subtract_fee_from_outputs);
- break;
- default:
- LOG_ERROR("Unknown transfer method, using default");
- /* FALLTHRU */
- case Transfer:
-- ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, subtract_fee_from_outputs);
-+ ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, {}, subtract_fee_from_outputs);
- break;
- }
-
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 63ed26a11..ca83812f3 100644
--- a/src/wallet/api/wallet.cpp
@@ -43,7 +23,7 @@ index 63ed26a11..ca83812f3 100644
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
adjusted_priority,
- extra, subaddr_account, subaddr_indices);
-+ extra, subaddr_account, subaddr_indices, preferred_input_list);
++ extra, subaddr_account, subaddr_indices, {}, preferred_input_list);
} else {
transaction->m_pending_tx = m_wallet->create_transactions_all(0, info.address, info.is_subaddress, 1, fake_outs_count, 0 /* unlock_time */,
adjusted_priority,
@@ -52,32 +32,72 @@ index 63ed26a11..ca83812f3 100644
}
pendingTxPostProcess(transaction);
+diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
+index c2fa3d95b..ece303c37 100644
+--- a/src/wallet/api/wallet2_api.h
++++ b/src/wallet/api/wallet2_api.h
+@@ -352,7 +352,9 @@ struct Coins
+ virtual CoinsInfo * coin(int index) const = 0;
+ virtual std::vector<CoinsInfo*> getAll() const = 0;
+ virtual void refresh() = 0;
++ virtual void setFrozen(std::string public_key) = 0;
+ virtual void setFrozen(int index) = 0;
++ virtual void thaw(std::string public_key) = 0;
+ virtual void thaw(int index) = 0;
+ virtual bool isTransferUnlocked(uint64_t unlockTime, uint64_t blockHeight) = 0;
++ virtual void setDescription(const std::string &public_key, const std::string &description) = 0;
+ };
+
+ struct SubaddressRow {
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
-index 00d9c133e..55a5030c3 100644
+index 00d9c133e..674126b87 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
-@@ -11500,7 +11500,7 @@ bool wallet2::light_wallet_key_image_is_ours(const crypto::key_image& key_image,
- // This system allows for sending (almost) the entire balance, since it does
- // not generate spurious change in all txes, thus decreasing the instantaneous
- // usable balance.
--std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const unique_index_container& subtract_fee_from_outputs, const std::vector<crypto::key_image>& preferred_input_list)
-+std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const std::vector<crypto::key_image>& preferred_input_list, const unique_index_container& subtract_fee_from_outputs)
+@@ -2091,12 +2091,21 @@ bool wallet2::frozen(const multisig_tx_set& txs) const
+
+ return false;
+ }
++void wallet2::freeze(const crypto::public_key &pk)
++{
++ freeze(get_transfer_details(pk));
++}
+ //----------------------------------------------------------------------------------------------------
+ void wallet2::freeze(const crypto::key_image &ki)
+ {
+ freeze(get_transfer_details(ki));
+ }
+ //----------------------------------------------------------------------------------------------------
++void wallet2::thaw(const crypto::public_key &pk)
++{
++ thaw(get_transfer_details(pk));
++}
++//----------------------------------------------------------------------------------------------------
+ void wallet2::thaw(const crypto::key_image &ki)
{
- //ensure device is let in NONE mode in any case
- hw::device &hwdev = m_account.get_device();
+ thaw(get_transfer_details(ki));
+@@ -2107,6 +2116,18 @@ bool wallet2::frozen(const crypto::key_image &ki) const
+ return frozen(get_transfer_details(ki));
+ }
+ //----------------------------------------------------------------------------------------------------
++size_t wallet2::get_transfer_details(const crypto::public_key &pk) const
++{
++ for (size_t idx = 0; idx < m_transfers.size(); ++idx)
++ {
++ const transfer_details &td = m_transfers[idx];
++ if (td.get_public_key() == pk) {
++ return idx;
++ }
++ }
++ CHECK_AND_ASSERT_THROW_MES(false, "Public key not found");
++}
++//----------------------------------------------------------------------------------------------------
+ size_t wallet2::get_transfer_details(const crypto::key_image &ki) const
+ {
+ for (size_t idx = 0; idx < m_transfers.size(); ++idx)
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
-index 40997cdbb..f0e03a799 100644
+index 40997cdbb..fd6dd09e3 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
-@@ -1208,7 +1208,7 @@ private:
- bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const;
- bool load_tx(const std::string &signed_filename, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set&)> accept_func = NULL);
- bool parse_tx_from_str(const std::string &signed_tx_st, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set &)> accept_func);
-- std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const unique_index_container& subtract_fee_from_outputs = {}, const std::vector<crypto::key_image>& preferred_input_list = {}); // pass subaddr_indices by value on purpose
-+ std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const std::vector<crypto::key_image>& preferred_input_list = {}, const unique_index_container& subtract_fee_from_outputs = {}); // pass subaddr_indices by value on purpose
- std::vector<wallet2::pending_tx> create_transactions_all(uint64_t below, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const std::vector<crypto::key_image>& preferred_input_list = {});
- std::vector<wallet2::pending_tx> create_transactions_single(const crypto::key_image &ki, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra);
- std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra);
@@ -1562,6 +1562,7 @@ private:
uint64_t get_num_rct_outputs();
size_t get_num_transfer_details() const { return m_transfers.size(); }
@@ -86,16 +106,113 @@ index 40997cdbb..f0e03a799 100644
uint8_t get_current_hard_fork();
void get_hard_fork_info(uint8_t version, uint64_t &earliest_height);
-diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
-index 8d2c68ac4..290af3831 100644
---- a/src/wallet/wallet_rpc_server.cpp
-+++ b/src/wallet/wallet_rpc_server.cpp
-@@ -1156,7 +1156,7 @@ namespace tools
+@@ -1792,7 +1793,9 @@ private:
+ void freeze(size_t idx);
+ void thaw(size_t idx);
+ bool frozen(size_t idx) const;
++ void freeze(const crypto::public_key &pk);
+ void freeze(const crypto::key_image &ki);
++ void thaw(const crypto::public_key &pk);
+ void thaw(const crypto::key_image &ki);
+ bool frozen(const crypto::key_image &ki) const;
+ bool frozen(const transfer_details &td) const;
+diff --git a/src/wallet/api/coins.cpp b/src/wallet/api/coins.cpp
+index fe54b82cf..fdd1c3c7a 100644
+--- a/src/wallet/api/coins.cpp
++++ b/src/wallet/api/coins.cpp
+@@ -90,6 +90,26 @@ namespace Monero {
+ }
+ }
+
++ void CoinsImpl::setFrozen(std::string public_key)
++ {
++ crypto::public_key pk;
++ if (!epee::string_tools::hex_to_pod(public_key, pk))
++ {
++ LOG_ERROR("Invalid public key: " << public_key);
++ return;
++ }
++
++ try
++ {
++ m_wallet->m_wallet->freeze(pk);
++ refresh();
++ }
++ catch (const std::exception& e)
++ {
++ LOG_ERROR("setFrozen: " << e.what());
++ }
++ }
++
+ void CoinsImpl::setFrozen(int index)
+ {
+ try
+@@ -103,6 +123,27 @@ namespace Monero {
+ }
+ }
+
++ void CoinsImpl::thaw(std::string public_key)
++ {
++ crypto::public_key pk;
++ if (!epee::string_tools::hex_to_pod(public_key, pk))
++ {
++ LOG_ERROR("Invalid public key: " << public_key);
++ return;
++ }
++
++ try
++ {
++ m_wallet->m_wallet->thaw(pk);
++ refresh();
++ }
++ catch (const std::exception& e)
++ {
++ LOG_ERROR("thaw: " << e.what());
++ }
++ }
++
++
++void CoinsImpl::setDescription(const std::string &public_key, const std::string &description)
++{
++ crypto::public_key pk;
++ if (!epee::string_tools::hex_to_pod(public_key, pk))
++ {
++ LOG_ERROR("Invalid public key: " << public_key);
++ return;
++ }
++
++ try
++ {
++ const size_t index = m_wallet->m_wallet->get_transfer_details(pk);
++ const tools::wallet2::transfer_details &td = m_wallet->m_wallet->get_transfer_details(index);
++ m_wallet->m_wallet->set_tx_note(td.m_txid, description);
++ refresh();
++ }
++ catch (const std::exception& e)
++ {
++ LOG_ERROR("setDescription: " << e.what());
++ }
++}
++
+ void CoinsImpl::thaw(int index)
{
- uint64_t mixin = m_wallet->adjust_mixin(req.ring_size ? req.ring_size - 1 : 0);
- uint32_t priority = m_wallet->adjust_priority(req.priority);
-- std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, req.subtract_fee_from_outputs);
-+ std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, {}, req.subtract_fee_from_outputs);
+ try
+diff --git a/src/wallet/api/coins.h b/src/wallet/api/coins.h
+index 3293d8ae9..eb8d54fa6 100644
+--- a/src/wallet/api/coins.h
++++ b/src/wallet/api/coins.h
+@@ -19,10 +19,14 @@ namespace Monero {
+ void refresh() override;
+
+ void setFrozen(int index) override;
++ void setFrozen(std::string public_key) override;
+ void thaw(int index) override;
++ void thaw(std::string public_key) override;
+
+ bool isTransferUnlocked(uint64_t unlockTime, uint64_t blockHeight) override;
- if (ptx_vector.empty())
- {
++ void setDescription(const std::string &public_key, const std::string &description) override;
++
+ private:
+ WalletImpl *m_wallet;
+ std::vector<CoinsInfo*> m_rows;