mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 01:09:24 -05:00
Merge pull request #2624
2677ade5
simplewallet: forbid 0 ring size (moneromooo-monero)da8b60cb
simplewallet: reject attempts to use too low mixin early (moneromooo-monero)
This commit is contained in:
commit
25b97ee937
@ -2585,12 +2585,23 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
|||||||
if (fake_outs_count == 0)
|
if (fake_outs_count == 0)
|
||||||
fake_outs_count = DEFAULT_MIX;
|
fake_outs_count = DEFAULT_MIX;
|
||||||
}
|
}
|
||||||
|
else if (ring_size == 0)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("Ring size must not be 0");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fake_outs_count = ring_size - 1;
|
fake_outs_count = ring_size - 1;
|
||||||
local_args.erase(local_args.begin());
|
local_args.erase(local_args.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
|
||||||
|
if (adjusted_fake_outs_count > fake_outs_count)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const size_t min_args = (transfer_type == TransferLocked) ? 3 : 2;
|
const size_t min_args = (transfer_type == TransferLocked) ? 3 : 2;
|
||||||
if(local_args.size() < min_args)
|
if(local_args.size() < min_args)
|
||||||
@ -3190,12 +3201,23 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
|
|||||||
if (fake_outs_count == 0)
|
if (fake_outs_count == 0)
|
||||||
fake_outs_count = DEFAULT_MIX;
|
fake_outs_count = DEFAULT_MIX;
|
||||||
}
|
}
|
||||||
|
else if (ring_size == 0)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("Ring size must not be 0");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fake_outs_count = ring_size - 1;
|
fake_outs_count = ring_size - 1;
|
||||||
local_args.erase(local_args.begin());
|
local_args.erase(local_args.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
|
||||||
|
if (adjusted_fake_outs_count > fake_outs_count)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> extra;
|
std::vector<uint8_t> extra;
|
||||||
bool payment_id_seen = false;
|
bool payment_id_seen = false;
|
||||||
|
@ -3981,6 +3981,19 @@ int wallet2::get_fee_algorithm()
|
|||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint64_t wallet2::adjust_mixin(uint64_t mixin)
|
||||||
|
{
|
||||||
|
if (mixin < 4 && use_fork_rules(6, 10)) {
|
||||||
|
MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 6, using 5");
|
||||||
|
mixin = 4;
|
||||||
|
}
|
||||||
|
else if (mixin < 2 && use_fork_rules(2, 10)) {
|
||||||
|
MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 2, using 3");
|
||||||
|
mixin = 2;
|
||||||
|
}
|
||||||
|
return mixin;
|
||||||
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// separated the call(s) to wallet2::transfer into their own function
|
// separated the call(s) to wallet2::transfer into their own function
|
||||||
//
|
//
|
||||||
|
@ -761,6 +761,7 @@ namespace tools
|
|||||||
|
|
||||||
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1);
|
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1);
|
||||||
uint64_t get_per_kb_fee();
|
uint64_t get_per_kb_fee();
|
||||||
|
uint64_t adjust_mixin(uint64_t mixin);
|
||||||
|
|
||||||
// Light wallet specific functions
|
// Light wallet specific functions
|
||||||
// fetch unspent outs from lw node and store in m_transfers
|
// fetch unspent outs from lw node and store in m_transfers
|
||||||
|
@ -227,19 +227,6 @@ namespace tools
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
uint64_t wallet_rpc_server::adjust_mixin(uint64_t mixin)
|
|
||||||
{
|
|
||||||
if (mixin < 4 && m_wallet->use_fork_rules(6, 10)) {
|
|
||||||
MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 6, using 5");
|
|
||||||
mixin = 4;
|
|
||||||
}
|
|
||||||
else if (mixin < 2 && m_wallet->use_fork_rules(2, 10)) {
|
|
||||||
MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 2, using 3");
|
|
||||||
mixin = 2;
|
|
||||||
}
|
|
||||||
return mixin;
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd)
|
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd)
|
||||||
{
|
{
|
||||||
entry.txid = string_tools::pod_to_hex(pd.m_tx_hash);
|
entry.txid = string_tools::pod_to_hex(pd.m_tx_hash);
|
||||||
@ -607,7 +594,7 @@ namespace tools
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint64_t mixin = adjust_mixin(req.mixin);
|
uint64_t mixin = m_wallet->adjust_mixin(req.mixin);
|
||||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon);
|
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon);
|
||||||
|
|
||||||
// reject proposed transactions if there are more than one. see on_transfer_split below.
|
// reject proposed transactions if there are more than one. see on_transfer_split below.
|
||||||
@ -667,7 +654,7 @@ namespace tools
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint64_t mixin = adjust_mixin(req.mixin);
|
uint64_t mixin = m_wallet->adjust_mixin(req.mixin);
|
||||||
uint64_t ptx_amount;
|
uint64_t ptx_amount;
|
||||||
std::vector<wallet2::pending_tx> ptx_vector;
|
std::vector<wallet2::pending_tx> ptx_vector;
|
||||||
LOG_PRINT_L2("on_transfer_split calling create_transactions_2");
|
LOG_PRINT_L2("on_transfer_split calling create_transactions_2");
|
||||||
@ -784,7 +771,7 @@ namespace tools
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint64_t mixin = adjust_mixin(req.mixin);
|
uint64_t mixin = m_wallet->adjust_mixin(req.mixin);
|
||||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, dsts[0].is_subaddress, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon);
|
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, dsts[0].is_subaddress, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon);
|
||||||
|
|
||||||
if (!req.do_not_relay)
|
if (!req.do_not_relay)
|
||||||
|
Loading…
Reference in New Issue
Block a user