mirror of
https://github.com/monero-project/monero.git
synced 2024-12-26 01:29:25 -05:00
Merge pull request #5182
b674728d
Better error when sending a tx with a too large extra field (moneromooo-monero)
This commit is contained in:
commit
e1be617ea2
@ -9148,6 +9148,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|||||||
{
|
{
|
||||||
const size_t estimated_rct_tx_weight = estimate_tx_weight(use_rct, tx.selected_transfers.size(), fake_outs_count, tx.dsts.size()+1, extra.size(), bulletproof);
|
const size_t estimated_rct_tx_weight = estimate_tx_weight(use_rct, tx.selected_transfers.size(), fake_outs_count, tx.dsts.size()+1, extra.size(), bulletproof);
|
||||||
try_tx = dsts.empty() || (estimated_rct_tx_weight >= TX_WEIGHT_TARGET(upper_transaction_weight_limit));
|
try_tx = dsts.empty() || (estimated_rct_tx_weight >= TX_WEIGHT_TARGET(upper_transaction_weight_limit));
|
||||||
|
THROW_WALLET_EXCEPTION_IF(try_tx && tx.dsts.empty(), error::tx_too_big, estimated_rct_tx_weight, upper_transaction_weight_limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,26 +699,43 @@ namespace tools
|
|||||||
explicit tx_too_big(std::string&& loc, const cryptonote::transaction& tx, uint64_t tx_weight_limit)
|
explicit tx_too_big(std::string&& loc, const cryptonote::transaction& tx, uint64_t tx_weight_limit)
|
||||||
: transfer_error(std::move(loc), "transaction is too big")
|
: transfer_error(std::move(loc), "transaction is too big")
|
||||||
, m_tx(tx)
|
, m_tx(tx)
|
||||||
|
, m_tx_valid(true)
|
||||||
|
, m_tx_weight(cryptonote::get_transaction_weight(tx))
|
||||||
, m_tx_weight_limit(tx_weight_limit)
|
, m_tx_weight_limit(tx_weight_limit)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit tx_too_big(std::string&& loc, uint64_t tx_weight, uint64_t tx_weight_limit)
|
||||||
|
: transfer_error(std::move(loc), "transaction would be too big")
|
||||||
|
, m_tx_valid(false)
|
||||||
|
, m_tx_weight(tx_weight)
|
||||||
|
, m_tx_weight_limit(tx_weight_limit)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tx_valid() const { return m_tx_valid; }
|
||||||
const cryptonote::transaction& tx() const { return m_tx; }
|
const cryptonote::transaction& tx() const { return m_tx; }
|
||||||
|
uint64_t tx_weight() const { return m_tx_weight; }
|
||||||
uint64_t tx_weight_limit() const { return m_tx_weight_limit; }
|
uint64_t tx_weight_limit() const { return m_tx_weight_limit; }
|
||||||
|
|
||||||
std::string to_string() const
|
std::string to_string() const
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
cryptonote::transaction tx = m_tx;
|
|
||||||
ss << transfer_error::to_string() <<
|
ss << transfer_error::to_string() <<
|
||||||
", tx_weight_limit = " << m_tx_weight_limit <<
|
", tx_weight_limit = " << m_tx_weight_limit <<
|
||||||
", tx weight = " << get_transaction_weight(m_tx) <<
|
", tx weight = " << m_tx_weight;
|
||||||
", tx:\n" << cryptonote::obj_to_json_str(tx);
|
if (m_tx_valid)
|
||||||
|
{
|
||||||
|
cryptonote::transaction tx = m_tx;
|
||||||
|
ss << ", tx:\n" << cryptonote::obj_to_json_str(tx);
|
||||||
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cryptonote::transaction m_tx;
|
cryptonote::transaction m_tx;
|
||||||
|
bool m_tx_valid;
|
||||||
|
uint64_t m_tx_weight;
|
||||||
uint64_t m_tx_weight_limit;
|
uint64_t m_tx_weight_limit;
|
||||||
};
|
};
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user