MWEB: IsStandard policies
This commit is contained in:
parent
22dae0e31a
commit
fb672d32fe
@ -204,6 +204,7 @@ BITCOIN_CORE_H = \
|
||||
miner.h \
|
||||
mweb/mweb_db.h \
|
||||
mweb/mweb_models.h \
|
||||
mweb/mweb_policy.h \
|
||||
net.h \
|
||||
net_permissions.h \
|
||||
net_processing.h \
|
||||
@ -547,6 +548,7 @@ libbitcoin_common_a_SOURCES = \
|
||||
key.cpp \
|
||||
key_io.cpp \
|
||||
merkleblock.cpp \
|
||||
mweb/mweb_policy.cpp \
|
||||
netaddress.cpp \
|
||||
netbase.cpp \
|
||||
net_permissions.cpp \
|
||||
|
||||
33
src/mweb/mweb_policy.cpp
Normal file
33
src/mweb/mweb_policy.cpp
Normal file
@ -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;
|
||||
}
|
||||
22
src/mweb/mweb_policy.h
Normal file
22
src/mweb/mweb_policy.h
Normal file
@ -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);
|
||||
};
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@
|
||||
#include <policy/policy.h>
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <mweb/mweb_policy.h>
|
||||
#include <coins.h>
|
||||
#include <span.h>
|
||||
|
||||
@ -109,6 +110,12 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
|
||||
}
|
||||
}
|
||||
|
||||
// MWEB: Also check pegout scripts
|
||||
std::vector<CTxOut> txouts = tx.vout;
|
||||
for (const PegOutCoin& pegout : tx.mweb_tx.GetPegOuts()) {
|
||||
txouts.push_back(CTxOut(pegout.GetAmount(), pegout.GetScriptPubKey()));
|
||||
}
|
||||
|
||||
unsigned int nDataOut = 0;
|
||||
TxoutType whichType;
|
||||
for (const CTxOut& txout : tx.vout) {
|
||||
@ -134,6 +141,11 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
|
||||
return false;
|
||||
}
|
||||
|
||||
// MWEB: Check MWEB standard transaction policies
|
||||
if (!MWEB::Policy::IsStandardTx(tx, reason)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user