mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-09 11:46:37 +00:00
import_vl_keys logic fix (flap fix) (#588)
This commit is contained in:
@@ -94,21 +94,6 @@ Change::preflight(PreflightContext const& ctx)
|
||||
"of sfImportVLKey, sfActiveValidator";
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
// if we do specify import_vl_keys in config then we won't approve keys
|
||||
// that aren't on our list
|
||||
if (ctx.tx.isFieldPresent(sfImportVLKey) &&
|
||||
!ctx.app.config().IMPORT_VL_KEYS.empty())
|
||||
{
|
||||
auto const& inner = const_cast<ripple::STTx&>(ctx.tx)
|
||||
.getField(sfImportVLKey)
|
||||
.downcast<STObject>();
|
||||
auto const pk = inner.getFieldVL(sfPublicKey);
|
||||
std::string const strPk = strHex(makeSlice(pk));
|
||||
if (ctx.app.config().IMPORT_VL_KEYS.find(strPk) ==
|
||||
ctx.app.config().IMPORT_VL_KEYS.end())
|
||||
return telIMPORT_VL_KEY_NOT_RECOGNISED;
|
||||
}
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -168,9 +153,42 @@ Change::preclaim(PreclaimContext const& ctx)
|
||||
return tesSUCCESS;
|
||||
case ttAMENDMENT:
|
||||
case ttUNL_MODIFY:
|
||||
case ttUNL_REPORT:
|
||||
case ttEMIT_FAILURE:
|
||||
return tesSUCCESS;
|
||||
case ttUNL_REPORT: {
|
||||
if (!ctx.tx.isFieldPresent(sfImportVLKey) ||
|
||||
ctx.app.config().IMPORT_VL_KEYS.empty())
|
||||
return tesSUCCESS;
|
||||
|
||||
// if we do specify import_vl_keys in config then we won't approve
|
||||
// keys that aren't on our list and/or aren't in the ledger object
|
||||
auto const& inner = const_cast<ripple::STTx&>(ctx.tx)
|
||||
.getField(sfImportVLKey)
|
||||
.downcast<STObject>();
|
||||
auto const pkBlob = inner.getFieldVL(sfPublicKey);
|
||||
std::string const strPk = strHex(makeSlice(pkBlob));
|
||||
if (ctx.app.config().IMPORT_VL_KEYS.find(strPk) !=
|
||||
ctx.app.config().IMPORT_VL_KEYS.end())
|
||||
return tesSUCCESS;
|
||||
|
||||
auto const pkType = publicKeyType(makeSlice(pkBlob));
|
||||
if (!pkType)
|
||||
return tefINTERNAL;
|
||||
|
||||
PublicKey const pk(makeSlice(pkBlob));
|
||||
|
||||
// check on ledger
|
||||
if (auto const unlRep = ctx.view.read(keylet::UNLReport());
|
||||
unlRep && unlRep->isFieldPresent(sfImportVLKeys))
|
||||
{
|
||||
auto const& vlKeys = unlRep->getFieldArray(sfImportVLKeys);
|
||||
for (auto const& k : vlKeys)
|
||||
if (PublicKey(k[sfPublicKey]) == pk)
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
return telIMPORT_VL_KEY_NOT_RECOGNISED;
|
||||
}
|
||||
default:
|
||||
return temUNKNOWN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user