mirror of
https://github.com/Xahau/xahaud.git
synced 2026-09-26 07:10:15 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0c2bf138f | ||
|
|
4e51d60024 | ||
|
|
12aed86eb7 | ||
|
|
0e46bdadfe |
@@ -38,7 +38,6 @@
|
||||
#define KEYLET_HOOK_DEFINITION 24
|
||||
#define KEYLET_HOOK_STATE_DIR 25
|
||||
#define KEYLET_CRON 26
|
||||
#define KEYLET_MANIFEST 37
|
||||
|
||||
#define COMPARE_EQUAL 1U
|
||||
#define COMPARE_LESS 2U
|
||||
|
||||
@@ -313,7 +313,6 @@ enum keylet_code : uint32_t {
|
||||
MPTOKEN = 34,
|
||||
CREDENTIAL = 35,
|
||||
PERMISSIONED_DOMAIN = 36,
|
||||
MANIFEST = 37,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -563,20 +563,6 @@ public:
|
||||
env(reward::claim(alice),
|
||||
reward::issuer(issuer),
|
||||
ter(tecNO_TARGET));
|
||||
env.close();
|
||||
}
|
||||
// Invalid HookName
|
||||
{
|
||||
auto hookObj = hso(jtx::genesis::AcceptHook, overrideFlag);
|
||||
hookObj[jss::HookOn] = to_string(~UINT256_BIT[ttCLAIM_REWARD]);
|
||||
hookObj[jss::HookName] = "4142434445";
|
||||
env(hook(issuer, {{hookObj}}, 0), fee(XRP(1)));
|
||||
env.close();
|
||||
|
||||
env(reward::claim(alice),
|
||||
reward::issuer(issuer),
|
||||
ter(tecNO_TARGET));
|
||||
env.close();
|
||||
}
|
||||
// Vaild HookOn
|
||||
{
|
||||
|
||||
@@ -82,10 +82,7 @@ namespace hook_api {
|
||||
namespace hook {
|
||||
|
||||
bool
|
||||
canHook(
|
||||
STTx const& tx,
|
||||
ripple::uint256 hookOn,
|
||||
std::optional<ripple::Slice> hookName);
|
||||
canHook(ripple::TxType txType, ripple::uint256 hookOn);
|
||||
|
||||
bool
|
||||
canEmit(ripple::TxType txType, ripple::uint256 hookCanEmit);
|
||||
|
||||
@@ -785,7 +785,7 @@ hook::removeHookNamespaceEntry(ripple::SLE& sleAccount, ripple::uint256 ns)
|
||||
// transactions. If you wish to set a hook that has control over ttHOOK_SET then
|
||||
// set bit 1U<<22.
|
||||
bool
|
||||
canHookTT(ripple::TxType txType, ripple::uint256 hookOn)
|
||||
hook::canHook(ripple::TxType txType, ripple::uint256 hookOn)
|
||||
{
|
||||
// invert ttHOOK_SET bit
|
||||
hookOn ^= UINT256_BIT[ttHOOK_SET];
|
||||
@@ -799,28 +799,7 @@ canHookTT(ripple::TxType txType, ripple::uint256 hookOn)
|
||||
bool
|
||||
hook::canEmit(ripple::TxType txType, ripple::uint256 hookCanEmit)
|
||||
{
|
||||
return canHookTT(txType, hookCanEmit);
|
||||
}
|
||||
|
||||
bool
|
||||
hook::canHook(
|
||||
STTx const& tx,
|
||||
ripple::uint256 hookOn,
|
||||
std::optional<ripple::Slice> hookName)
|
||||
{
|
||||
if (!canHookTT(tx.getTxnType(), hookOn))
|
||||
return false;
|
||||
|
||||
if (!hookName || hookName->empty())
|
||||
// no hook name specified to hook, so we can always hook
|
||||
return true;
|
||||
|
||||
if (!tx.isFieldPresent(sfHookName))
|
||||
// hook name specified hook, but no hook name specified in the
|
||||
// transaction, so we can't hook without the hook name
|
||||
return false;
|
||||
|
||||
return tx[sfHookName] == *hookName;
|
||||
return hook::canHook(txType, hookCanEmit);
|
||||
}
|
||||
|
||||
ripple::uint256
|
||||
@@ -2212,35 +2191,6 @@ DEFINE_HOOK_FUNCTION(
|
||||
return serialize_keylet(kl, memory, write_ptr, write_len);
|
||||
}
|
||||
|
||||
// keylets that take a validator public key
|
||||
case keylet_code::MANIFEST: {
|
||||
if (!applyCtx.view().rules().enabled(featureOnChainManifests))
|
||||
return INVALID_ARGUMENT;
|
||||
|
||||
if (a == 0 || b == 0)
|
||||
return INVALID_ARGUMENT;
|
||||
|
||||
if (c != 0 || d != 0 || e != 0 || f != 0)
|
||||
return INVALID_ARGUMENT;
|
||||
|
||||
uint32_t read_ptr = a, read_len = b;
|
||||
|
||||
if (NOT_IN_BOUNDS(read_ptr, read_len, memory_length))
|
||||
return OUT_OF_BOUNDS;
|
||||
|
||||
ripple::Slice const pkSlice{memory + read_ptr, read_len};
|
||||
|
||||
// Reject anything that is not a well-formed public key before
|
||||
// constructing one: the PublicKey ctor throws on bad input.
|
||||
if (!publicKeyType(pkSlice))
|
||||
return INVALID_ARGUMENT;
|
||||
|
||||
ripple::Keylet kl =
|
||||
ripple::keylet::manifest(ripple::PublicKey(pkSlice));
|
||||
|
||||
return serialize_keylet(kl, memory, write_ptr, write_len);
|
||||
}
|
||||
|
||||
// keylets that take 20 byte account id, and (4 byte uint for 32
|
||||
// byte hash)
|
||||
case keylet_code::ORACLE: {
|
||||
|
||||
@@ -158,11 +158,7 @@ ClaimReward::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
auto const& hookOn =
|
||||
hook::getHookOn(hook, sleDef, sfHookOnIncoming);
|
||||
auto const hookName =
|
||||
ctx.view.rules().enabled(fixHookNameValidation)
|
||||
? hook[~sfHookName]
|
||||
: std::nullopt;
|
||||
if (hook::canHook(ctx.tx, hookOn, hookName))
|
||||
if (hook::canHook(ttCLAIM_REWARD, hookOn))
|
||||
{
|
||||
hasClaimRewardHook = true;
|
||||
break;
|
||||
|
||||
@@ -287,7 +287,19 @@ Transactor::calculateHookChainFee(
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
auto const hookName = hookObj[~sfHookName];
|
||||
std::optional<Blob> requiredHookName;
|
||||
if (hookObj.isFieldPresent(sfHookName) &&
|
||||
hookObj.getFieldVL(sfHookName).size() > 0)
|
||||
requiredHookName = hookObj.getFieldVL(sfHookName);
|
||||
|
||||
if (requiredHookName)
|
||||
{
|
||||
// need to specify same hook name in the transaction
|
||||
if (!tx.isFieldPresent(sfHookName))
|
||||
continue;
|
||||
if (*requiredHookName != tx.getFieldVL(sfHookName))
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
if (hookObj.isFieldPresent(sfFlags))
|
||||
@@ -299,7 +311,7 @@ Transactor::calculateHookChainFee(
|
||||
uint256 hookOn = hook::getHookOn(
|
||||
hookObj, hookDef, isOutgoing ? sfHookOnOutgoing : sfHookOnIncoming);
|
||||
|
||||
if (hook::canHook(tx, hookOn, hookName) &&
|
||||
if (hook::canHook(tx.getTxnType(), hookOn) &&
|
||||
(!collectCallsOnly || (flags & hook::hsfCOLLECT)))
|
||||
{
|
||||
XRPAmount const toAdd{hookDef->getFieldAmount(sfFee).xrp().drops()};
|
||||
@@ -1369,13 +1381,25 @@ Transactor::executeHookChain(
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
auto const hookName = hookObj[~sfHookName];
|
||||
std::optional<Blob> requiredHookName;
|
||||
if (hookObj.isFieldPresent(sfHookName) &&
|
||||
hookObj.getFieldVL(sfHookName).size() > 0)
|
||||
requiredHookName = hookObj.getFieldVL(sfHookName);
|
||||
|
||||
if (requiredHookName)
|
||||
{
|
||||
// need to specify same hook name in the transaction
|
||||
if (!ctx_.tx.isFieldPresent(sfHookName))
|
||||
continue;
|
||||
if (*requiredHookName != ctx_.tx.getFieldVL(sfHookName))
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if the hook can fire
|
||||
uint256 hookOn = hook::getHookOn(
|
||||
hookObj, hookDef, isOutgoing ? sfHookOnOutgoing : sfHookOnIncoming);
|
||||
|
||||
if (!hook::canHook(ctx_.tx, hookOn, hookName))
|
||||
if (!hook::canHook(ctx_.tx.getTxnType(), hookOn))
|
||||
continue; // skip if it can't
|
||||
|
||||
uint256 hookCanEmit = hook::getHookCanEmit(hookObj, hookDef);
|
||||
|
||||
Reference in New Issue
Block a user