mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
Merge pull request #5487
df83ed7
consensus: from v12, enforce >= 2 outputs (moneromooo-monero)
This commit is contained in:
commit
2258551ef9
8 changed files with 27 additions and 0 deletions
|
@ -48,6 +48,7 @@ namespace cryptonote
|
||||||
bool m_overspend;
|
bool m_overspend;
|
||||||
bool m_fee_too_low;
|
bool m_fee_too_low;
|
||||||
bool m_not_rct;
|
bool m_not_rct;
|
||||||
|
bool m_too_few_outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct block_verification_context
|
struct block_verification_context
|
||||||
|
|
|
@ -147,6 +147,7 @@
|
||||||
#define HF_VERSION_PER_BYTE_FEE 8
|
#define HF_VERSION_PER_BYTE_FEE 8
|
||||||
#define HF_VERSION_SMALLER_BP 10
|
#define HF_VERSION_SMALLER_BP 10
|
||||||
#define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 10
|
#define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 10
|
||||||
|
#define HF_VERSION_MIN_2_OUTPUTS 12
|
||||||
|
|
||||||
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
||||||
|
|
||||||
|
|
|
@ -2840,6 +2840,19 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
|
||||||
|
|
||||||
const uint8_t hf_version = m_hardfork->get_current_version();
|
const uint8_t hf_version = m_hardfork->get_current_version();
|
||||||
|
|
||||||
|
if (hf_version >= HF_VERSION_MIN_2_OUTPUTS)
|
||||||
|
{
|
||||||
|
if (tx.version >= 2)
|
||||||
|
{
|
||||||
|
if (tx.vout.size() < 2)
|
||||||
|
{
|
||||||
|
MERROR_VER("Tx " << get_transaction_hash(tx) << " has fewer than two outputs");
|
||||||
|
tvc.m_too_few_outputs = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// from hard fork 2, we require mixin at least 2 unless one output cannot mix with 2 others
|
// from hard fork 2, we require mixin at least 2 unless one output cannot mix with 2 others
|
||||||
// if one output cannot mix with 2 others, we accept at most 1 output that can mix
|
// if one output cannot mix with 2 others, we accept at most 1 output that can mix
|
||||||
if (hf_version >= 2)
|
if (hf_version >= 2)
|
||||||
|
|
|
@ -864,6 +864,8 @@ namespace cryptonote
|
||||||
add_reason(reason, "fee too low");
|
add_reason(reason, "fee too low");
|
||||||
if ((res.not_rct = tvc.m_not_rct))
|
if ((res.not_rct = tvc.m_not_rct))
|
||||||
add_reason(reason, "tx is not ringct");
|
add_reason(reason, "tx is not ringct");
|
||||||
|
if ((res.too_few_outputs = tvc.m_too_few_outputs))
|
||||||
|
add_reason(reason, "too few outputs");
|
||||||
const std::string punctuation = reason.empty() ? "" : ": ";
|
const std::string punctuation = reason.empty() ? "" : ": ";
|
||||||
if (tvc.m_verifivation_failed)
|
if (tvc.m_verifivation_failed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -612,6 +612,7 @@ namespace cryptonote
|
||||||
bool overspend;
|
bool overspend;
|
||||||
bool fee_too_low;
|
bool fee_too_low;
|
||||||
bool not_rct;
|
bool not_rct;
|
||||||
|
bool too_few_outputs;
|
||||||
bool sanity_check_failed;
|
bool sanity_check_failed;
|
||||||
bool untrusted;
|
bool untrusted;
|
||||||
|
|
||||||
|
@ -627,6 +628,7 @@ namespace cryptonote
|
||||||
KV_SERIALIZE(overspend)
|
KV_SERIALIZE(overspend)
|
||||||
KV_SERIALIZE(fee_too_low)
|
KV_SERIALIZE(fee_too_low)
|
||||||
KV_SERIALIZE(not_rct)
|
KV_SERIALIZE(not_rct)
|
||||||
|
KV_SERIALIZE(too_few_outputs)
|
||||||
KV_SERIALIZE(sanity_check_failed)
|
KV_SERIALIZE(sanity_check_failed)
|
||||||
KV_SERIALIZE(untrusted)
|
KV_SERIALIZE(untrusted)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
|
|
|
@ -343,6 +343,11 @@ namespace rpc
|
||||||
if (!res.error_details.empty()) res.error_details += " and ";
|
if (!res.error_details.empty()) res.error_details += " and ";
|
||||||
res.error_details = "tx is not ringct";
|
res.error_details = "tx is not ringct";
|
||||||
}
|
}
|
||||||
|
if (tvc.m_too_few_outputs)
|
||||||
|
{
|
||||||
|
if (!res.error_details.empty()) res.error_details += " and ";
|
||||||
|
res.error_details = "too few outputs";
|
||||||
|
}
|
||||||
if (res.error_details.empty())
|
if (res.error_details.empty())
|
||||||
{
|
{
|
||||||
res.error_details = "an unknown issue was found with the transaction";
|
res.error_details = "an unknown issue was found with the transaction";
|
||||||
|
|
|
@ -217,6 +217,8 @@ namespace
|
||||||
add_reason(reason, "invalid input");
|
add_reason(reason, "invalid input");
|
||||||
if (res.invalid_output)
|
if (res.invalid_output)
|
||||||
add_reason(reason, "invalid output");
|
add_reason(reason, "invalid output");
|
||||||
|
if (res.too_few_outputs)
|
||||||
|
add_reason(reason, "too few outputs");
|
||||||
if (res.too_big)
|
if (res.too_big)
|
||||||
add_reason(reason, "too big");
|
add_reason(reason, "too big");
|
||||||
if (res.overspend)
|
if (res.overspend)
|
||||||
|
|
|
@ -574,6 +574,7 @@ class TransferTest():
|
||||||
assert res.overspend == False
|
assert res.overspend == False
|
||||||
assert res.fee_too_low == False
|
assert res.fee_too_low == False
|
||||||
assert res.not_rct == False
|
assert res.not_rct == False
|
||||||
|
assert res.too_few_outputs == False
|
||||||
|
|
||||||
res = daemon.get_transactions([txes[0][0]])
|
res = daemon.get_transactions([txes[0][0]])
|
||||||
assert len(res.txs) >= 1
|
assert len(res.txs) >= 1
|
||||||
|
|
Loading…
Reference in a new issue