mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Defer checking whether master key was used for signing
This commit is contained in:
@@ -176,6 +176,21 @@ SetAccount::doApply ()
|
||||
bool bSetDisallowXRP = (uTxFlags & tfDisallowXRP) || (uSetFlag == asfDisallowXRP);
|
||||
bool bClearDisallowXRP = (uTxFlags & tfAllowXRP) || (uClearFlag == asfDisallowXRP);
|
||||
|
||||
bool sigWithMaster = false;
|
||||
|
||||
{
|
||||
auto const blob = ctx_.tx.getSigningPubKey();
|
||||
|
||||
if (!blob.empty ())
|
||||
{
|
||||
auto const signingPubKey =
|
||||
RippleAddress::createAccountPublic(blob);
|
||||
|
||||
if (calcAccountID(signingPubKey) == account_)
|
||||
sigWithMaster = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// RequireAuth
|
||||
//
|
||||
@@ -226,7 +241,7 @@ SetAccount::doApply ()
|
||||
//
|
||||
if ((uSetFlag == asfDisableMaster) && !(uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
if (!mSigMaster)
|
||||
if (!sigWithMaster)
|
||||
{
|
||||
j_.trace << "Must use master key to disable master key.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
@@ -273,7 +288,7 @@ SetAccount::doApply ()
|
||||
//
|
||||
if (uSetFlag == asfNoFreeze)
|
||||
{
|
||||
if (!mSigMaster && !(uFlagsIn & lsfDisableMaster))
|
||||
if (!sigWithMaster && !(uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
j_.trace << "Can't use regular key to set NoFreeze.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
|
||||
@@ -79,15 +79,6 @@ preflight1 (PreflightContext const& ctx)
|
||||
TER
|
||||
preflight2 (PreflightContext const& ctx)
|
||||
{
|
||||
// Extract signing key
|
||||
// Transactions contain a signing key. This allows us to trivially verify a
|
||||
// transaction has at least been properly signed without going to disk.
|
||||
// Each transaction also notes a source account id. This is used to verify
|
||||
// that the signing key is associated with the account.
|
||||
// XXX This could be a lot cleaner to prevent unnecessary copying.
|
||||
auto const pk = RippleAddress::createAccountPublic(
|
||||
ctx.tx.getSigningPubKey());
|
||||
|
||||
if(!( ctx.flags & tapNO_CHECK_SIGN) &&
|
||||
checkValidity(ctx.app.getHashRouter(),
|
||||
ctx.tx, ctx.rules, ctx.app.config(),
|
||||
@@ -128,7 +119,6 @@ Transactor::Transactor(
|
||||
ApplyContext& ctx)
|
||||
: ctx_ (ctx)
|
||||
, j_ (ctx.journal)
|
||||
, mSigMaster (false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -285,9 +275,6 @@ void Transactor::preCompute ()
|
||||
{
|
||||
account_ = ctx_.tx.getAccountID(sfAccount);
|
||||
assert(account_ != zero);
|
||||
mSigningPubKey =
|
||||
RippleAddress::createAccountPublic(
|
||||
ctx_.tx.getSigningPubKey());
|
||||
}
|
||||
|
||||
TER Transactor::apply ()
|
||||
@@ -316,8 +303,6 @@ TER Transactor::apply ()
|
||||
|
||||
if (terResult != tesSUCCESS) return terResult;
|
||||
|
||||
checkMasterSign ();
|
||||
|
||||
view().update (sle);
|
||||
}
|
||||
|
||||
@@ -344,21 +329,6 @@ Transactor::checkSign (PreclaimContext const& ctx)
|
||||
return checkSingleSign (ctx);
|
||||
}
|
||||
|
||||
void
|
||||
Transactor::checkMasterSign ()
|
||||
{
|
||||
if ((view().flags() & tapENABLE_TESTING) ||
|
||||
(view().rules().enabled(featureMultiSign,
|
||||
ctx_.app.config().features)))
|
||||
{
|
||||
if (mSigningPubKey.getAccountPublic().empty())
|
||||
// Multisign obviously doesn't use the master key
|
||||
return;
|
||||
}
|
||||
|
||||
mSigMaster = calcAccountID(mSigningPubKey) == account_;
|
||||
}
|
||||
|
||||
TER
|
||||
Transactor::checkSingleSign (PreclaimContext const& ctx)
|
||||
{
|
||||
|
||||
@@ -79,8 +79,6 @@ protected:
|
||||
XRPAmount mFeeDue;
|
||||
XRPAmount mPriorBalance; // Balance before fees.
|
||||
XRPAmount mSourceBalance; // Balance after fees.
|
||||
bool mSigMaster;
|
||||
RippleAddress mSigningPubKey;
|
||||
|
||||
public:
|
||||
/** Process the transaction. */
|
||||
@@ -151,7 +149,6 @@ protected:
|
||||
private:
|
||||
void setSeq ();
|
||||
TER payFee ();
|
||||
void checkMasterSign ();
|
||||
static TER checkSingleSign (PreclaimContext const& ctx);
|
||||
static TER checkMultiSign (PreclaimContext const& ctx);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user