Skip to content

Commit 894adf0

Browse files
committed
wallet: remove ring size plumbing
1 parent a1dc85c commit 894adf0

File tree

6 files changed

+36
-155
lines changed

6 files changed

+36
-155
lines changed

src/simplewallet/simplewallet.cpp

Lines changed: 11 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ namespace
194194
const char* USAGE_INCOMING_TRANSFERS("incoming_transfers [available|unavailable] [verbose] [uses] [index=<N1>[,<N2>[,...]]]");
195195
const char* USAGE_PAYMENTS("payments <PID_1> [<PID_2> ... <PID_N>]");
196196
const char* USAGE_PAYMENT_ID("payment_id");
197-
const char* USAGE_TRANSFER("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <address> <amount>) [subtractfeefrom=<D0>[,<D1>,all,...]] [<payment_id>]");
198-
const char* USAGE_SWEEP_ALL("sweep_all [index=<N1>[,<N2>,...] | index=all] [<priority>] [<ring_size>] [outputs=<N>] <address> [<payment_id (obsolete)>]");
199-
const char* USAGE_SWEEP_ACCOUNT("sweep_account <account> [index=<N1>[,<N2>,...] | index=all] [<priority>] [<ring_size>] [outputs=<N>] <address> [<payment_id (obsolete)>]");
200-
const char* USAGE_SWEEP_BELOW("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id (obsolete)>]");
201-
const char* USAGE_SWEEP_SINGLE("sweep_single [<priority>] [<ring_size>] [outputs=<N>] <key_image> <address> [<payment_id (obsolete)>]");
202-
const char* USAGE_DONATE("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id (obsolete)>]");
197+
const char* USAGE_TRANSFER("transfer [index=<N1>[,<N2>,...]] [<priority>] (<URI> | <address> <amount>) [subtractfeefrom=<D0>[,<D1>,all,...]] [<payment_id>]");
198+
const char* USAGE_SWEEP_ALL("sweep_all [index=<N1>[,<N2>,...] | index=all] [<priority>] [outputs=<N>] <address> [<payment_id (obsolete)>]");
199+
const char* USAGE_SWEEP_ACCOUNT("sweep_account <account> [index=<N1>[,<N2>,...] | index=all] [<priority>] [outputs=<N>] <address> [<payment_id (obsolete)>]");
200+
const char* USAGE_SWEEP_BELOW("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] <address> [<payment_id (obsolete)>]");
201+
const char* USAGE_SWEEP_SINGLE("sweep_single [<priority>] [outputs=<N>] <key_image> <address> [<payment_id (obsolete)>]");
202+
const char* USAGE_DONATE("donate [index=<N1>[,<N2>,...]] [<priority>] <amount> [<payment_id (obsolete)>]");
203203
const char* USAGE_SIGN_TRANSFER("sign_transfer [export_raw] [<filename>]");
204204
const char* USAGE_SET_LOG("set_log <level>|{+,-,}<categories>");
205205
const char* USAGE_ACCOUNT("account\n"
@@ -3220,7 +3220,7 @@ simple_wallet::simple_wallet()
32203220
tr("Show the blockchain height."));
32213221
m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::on_command, this, &simple_wallet::transfer, _1),
32223222
tr(USAGE_TRANSFER),
3223-
tr("Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding URI_2 or <address_2> <amount_2> etcetera (before the payment ID, if it's included). The \"subtractfeefrom=\" list allows you to choose which destinations to fund the tx fee from instead of the change output. The fee will be split across the chosen destinations proportionally equally. For example, to make 3 transfers where the fee is taken from the first and third destinations, one could do: \"transfer <addr1> 3 <addr2> 0.5 <addr3> 1 subtractfeefrom=0,2\". Let's say the tx fee is 0.1. The balance would drop by exactly 4.5 XMR including fees, and addr1 & addr3 would receive 2.925 & 0.975 XMR, respectively. Use \"subtractfeefrom=all\" to spread the fee across all destinations."));
3223+
tr("Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. Multiple payments can be made at once by adding URI_2 or <address_2> <amount_2> etcetera (before the payment ID, if it's included). The \"subtractfeefrom=\" list allows you to choose which destinations to fund the tx fee from instead of the change output. The fee will be split across the chosen destinations proportionally equally. For example, to make 3 transfers where the fee is taken from the first and third destinations, one could do: \"transfer <addr1> 3 <addr2> 0.5 <addr3> 1 subtractfeefrom=0,2\". Let's say the tx fee is 0.1. The balance would drop by exactly 4.5 XMR including fees, and addr1 & addr3 would receive 2.925 & 0.975 XMR, respectively. Use \"subtractfeefrom=all\" to spread the fee across all destinations."));
32243224
m_cmd_binder.set_handler("sweep_unmixable",
32253225
boost::bind(&simple_wallet::on_command, this, &simple_wallet::sweep_unmixable, _1),
32263226
tr("Send all unmixable outputs to yourself with ring_size 1"));
@@ -6425,7 +6425,7 @@ bool simple_wallet::on_command(bool (simple_wallet::*cmd)(const std::vector<std:
64256425
//----------------------------------------------------------------------------------------------------
64266426
bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool called_by_mms)
64276427
{
6428-
// "transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"
6428+
// "transfer [index=<N1>[,<N2>,...]] [<priority>] <address> <amount> [<payment_id>]"
64296429
CHECK_IF_BACKGROUND_SYNCING("cannot transfer");
64306430
if (!try_connect_to_daemon())
64316431
return false;
@@ -6446,36 +6446,6 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
64466446

64476447
priority = m_wallet->adjust_priority(priority);
64486448

6449-
const size_t min_ring_size = m_wallet->get_min_ring_size();
6450-
size_t fake_outs_count = min_ring_size - 1;
6451-
if(local_args.size() > 0) {
6452-
size_t ring_size;
6453-
if(!epee::string_tools::get_xtype_from_string(ring_size, local_args[0]))
6454-
{
6455-
}
6456-
else if (ring_size == 0)
6457-
{
6458-
fail_msg_writer() << tr("Ring size must not be 0");
6459-
return false;
6460-
}
6461-
else
6462-
{
6463-
fake_outs_count = ring_size - 1;
6464-
local_args.erase(local_args.begin());
6465-
}
6466-
}
6467-
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
6468-
if (adjusted_fake_outs_count > fake_outs_count)
6469-
{
6470-
fail_msg_writer() << (boost::format(tr("ring size %u is too small, minimum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
6471-
return false;
6472-
}
6473-
if (adjusted_fake_outs_count < fake_outs_count)
6474-
{
6475-
fail_msg_writer() << (boost::format(tr("ring size %u is too large, maximum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
6476-
return false;
6477-
}
6478-
64796449
const size_t min_args = 1;
64806450
if(local_args.size() < min_args)
64816451
{
@@ -6630,7 +6600,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
66306600
try
66316601
{
66326602
// figure out what tx will be necessary
6633-
auto ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, priority, extra,
6603+
auto ptx_vector = m_wallet->create_transactions_2(dsts, priority, extra,
66346604
m_current_subaddress_account, subaddr_indices, subtract_fee_from_outputs);
66356605

66366606
if (ptx_vector.empty())
@@ -7011,35 +6981,6 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
70116981

70126982
priority = m_wallet->adjust_priority(priority);
70136983

7014-
size_t fake_outs_count = m_wallet->get_min_ring_size() - 1;
7015-
if(local_args.size() > 0) {
7016-
size_t ring_size;
7017-
if(!epee::string_tools::get_xtype_from_string(ring_size, local_args[0]))
7018-
{
7019-
}
7020-
else if (ring_size == 0)
7021-
{
7022-
fail_msg_writer() << tr("Ring size must not be 0");
7023-
return true;
7024-
}
7025-
else
7026-
{
7027-
fake_outs_count = ring_size - 1;
7028-
local_args.erase(local_args.begin());
7029-
}
7030-
}
7031-
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
7032-
if (adjusted_fake_outs_count > fake_outs_count)
7033-
{
7034-
fail_msg_writer() << (boost::format(tr("ring size %u is too small, minimum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
7035-
return true;
7036-
}
7037-
if (adjusted_fake_outs_count < fake_outs_count)
7038-
{
7039-
fail_msg_writer() << (boost::format(tr("ring size %u is too large, maximum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
7040-
return true;
7041-
}
7042-
70436984
size_t outputs = 1;
70446985
if (local_args.size() > 0 && local_args[0].substr(0, 8) == "outputs=")
70456986
{
@@ -7114,7 +7055,7 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
71147055
try
71157056
{
71167057
// figure out what tx will be necessary
7117-
auto ptx_vector = m_wallet->create_transactions_all(below, info.address, info.is_subaddress, outputs, fake_outs_count, priority, extra, account, subaddr_indices);
7058+
auto ptx_vector = m_wallet->create_transactions_all(below, info.address, info.is_subaddress, outputs, priority, extra, account, subaddr_indices);
71187059

71197060
if (ptx_vector.empty())
71207061
{
@@ -7255,35 +7196,6 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
72557196

72567197
priority = m_wallet->adjust_priority(priority);
72577198

7258-
size_t fake_outs_count = m_wallet->get_min_ring_size() - 1;
7259-
if(local_args.size() > 0) {
7260-
size_t ring_size;
7261-
if(!epee::string_tools::get_xtype_from_string(ring_size, local_args[0]))
7262-
{
7263-
}
7264-
else if (ring_size == 0)
7265-
{
7266-
fail_msg_writer() << tr("Ring size must not be 0");
7267-
return true;
7268-
}
7269-
else
7270-
{
7271-
fake_outs_count = ring_size - 1;
7272-
local_args.erase(local_args.begin());
7273-
}
7274-
}
7275-
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
7276-
if (adjusted_fake_outs_count > fake_outs_count)
7277-
{
7278-
fail_msg_writer() << (boost::format(tr("ring size %u is too small, minimum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
7279-
return true;
7280-
}
7281-
if (adjusted_fake_outs_count < fake_outs_count)
7282-
{
7283-
fail_msg_writer() << (boost::format(tr("ring size %u is too large, maximum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
7284-
return true;
7285-
}
7286-
72877199
size_t outputs = 1;
72887200
if (local_args.size() > 0 && local_args[0].substr(0, 8) == "outputs=")
72897201
{
@@ -7372,7 +7284,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
73727284
try
73737285
{
73747286
// figure out what tx will be necessary
7375-
auto ptx_vector = m_wallet->create_transactions_single(ki, info.address, info.is_subaddress, outputs, fake_outs_count, priority, extra);
7287+
auto ptx_vector = m_wallet->create_transactions_single(ki, info.address, info.is_subaddress, outputs, priority, extra);
73767288

73777289
if (ptx_vector.empty())
73787290
{

src/wallet/api/wallet.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,15 +1691,11 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
16911691
break;
16921692
}
16931693
try {
1694-
size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin();
1695-
fake_outs_count = m_wallet->adjust_mixin(mixin_count);
1696-
16971694
if (amount) {
1698-
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count,
1699-
adjusted_priority,
1695+
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, adjusted_priority,
17001696
extra, subaddr_account, subaddr_indices);
17011697
} else {
1702-
transaction->m_pending_tx = m_wallet->create_transactions_all(0, info.address, info.is_subaddress, 1, fake_outs_count,
1698+
transaction->m_pending_tx = m_wallet->create_transactions_all(0, info.address, info.is_subaddress, 1,
17031699
adjusted_priority,
17041700
extra, subaddr_account, subaddr_indices);
17051701
}
@@ -1889,7 +1885,7 @@ uint64_t WalletImpl::estimateTransactionFee(const std::vector<std::pair<std::str
18891885
m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE, 0),
18901886
m_wallet->use_fork_rules(4, 0),
18911887
1,
1892-
m_wallet->get_min_ring_size() - 1,
1888+
m_wallet->get_ring_size() - 1,
18931889
destinations.size() + 1,
18941890
extra_size,
18951891
m_wallet->use_fork_rules(8, 0),

src/wallet/api/wallet.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ class WalletImpl : public Wallet
155155
PendingTransaction* restoreMultisigTransaction(const std::string& signData) override;
156156

157157
PendingTransaction * createTransactionMultDest(const std::vector<std::string> &dst_addr, const std::string &payment_id,
158-
optional<std::vector<uint64_t>> amount, uint32_t mixin_count,
158+
optional<std::vector<uint64_t>> amount,
159+
uint32_t mixin_count, // deprecated
159160
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
160161
uint32_t subaddr_account = 0,
161162
std::set<uint32_t> subaddr_indices = {}) override;
162163
PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
163-
optional<uint64_t> amount, uint32_t mixin_count,
164+
optional<uint64_t> amount,
165+
uint32_t mixin_count, // deprecated
164166
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
165167
uint32_t subaddr_account = 0,
166168
std::set<uint32_t> subaddr_indices = {}) override;

0 commit comments

Comments
 (0)