parent
22dae0e31a
commit
fb672d32fe
@ -0,0 +1,33 @@
|
||||
#include <mweb/mweb_policy.h>
|
||||
|
||||
#include <primitives/transaction.h>
|
||||
|
||||
using namespace MWEB;
|
||||
|
||||
bool Policy::IsStandardTx(const CTransaction& tx, std::string& reason)
|
||||
{
|
||||
// MWEB: To help avoid mempool bugs, we don't yet allow transaction aggregation
|
||||
// for transactions with canonical LTC data.
|
||||
if (!tx.IsMWEBOnly()) {
|
||||
std::set<mw::Hash> pegin_kernels;
|
||||
for (const CTxOut& txout : tx.vout) {
|
||||
mw::Hash kernel_id;
|
||||
if (txout.scriptPubKey.IsMWEBPegin(&kernel_id)) {
|
||||
pegin_kernels.insert(std::move(kernel_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (pegin_kernels != tx.mweb_tx.GetKernelIDs()) {
|
||||
reason = "kernel-mismatch";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// MWEB: Check MWEB transaction for non-standard kernel features
|
||||
if (tx.HasMWEBTx() && !tx.mweb_tx.m_transaction->IsStandard()) {
|
||||
reason = "non-standard-mweb-tx";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
// Forward Declarations
|
||||
class CTransaction;
|
||||
|
||||
namespace MWEB {
|
||||
|
||||
class Policy
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Checks the transaction for violation of any MWEB-specific standard tx policies.
|
||||
/// </summary>
|
||||
/// <param name="tx">The transaction to check.</param>
|
||||
/// <param name="reason">The reason it's non-standard, if any.</param>
|
||||
/// <returns>True if the transaction is standard.</returns>
|
||||
static bool IsStandardTx(const CTransaction& tx, std::string& reason);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in new issue