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 bSetDisallowXRP = (uTxFlags & tfDisallowXRP) || (uSetFlag == asfDisallowXRP);
|
||||||
bool bClearDisallowXRP = (uTxFlags & tfAllowXRP) || (uClearFlag == 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
|
// RequireAuth
|
||||||
//
|
//
|
||||||
@@ -226,7 +241,7 @@ SetAccount::doApply ()
|
|||||||
//
|
//
|
||||||
if ((uSetFlag == asfDisableMaster) && !(uFlagsIn & lsfDisableMaster))
|
if ((uSetFlag == asfDisableMaster) && !(uFlagsIn & lsfDisableMaster))
|
||||||
{
|
{
|
||||||
if (!mSigMaster)
|
if (!sigWithMaster)
|
||||||
{
|
{
|
||||||
j_.trace << "Must use master key to disable master key.";
|
j_.trace << "Must use master key to disable master key.";
|
||||||
return tecNEED_MASTER_KEY;
|
return tecNEED_MASTER_KEY;
|
||||||
@@ -273,7 +288,7 @@ SetAccount::doApply ()
|
|||||||
//
|
//
|
||||||
if (uSetFlag == asfNoFreeze)
|
if (uSetFlag == asfNoFreeze)
|
||||||
{
|
{
|
||||||
if (!mSigMaster && !(uFlagsIn & lsfDisableMaster))
|
if (!sigWithMaster && !(uFlagsIn & lsfDisableMaster))
|
||||||
{
|
{
|
||||||
j_.trace << "Can't use regular key to set NoFreeze.";
|
j_.trace << "Can't use regular key to set NoFreeze.";
|
||||||
return tecNEED_MASTER_KEY;
|
return tecNEED_MASTER_KEY;
|
||||||
|
|||||||
@@ -79,15 +79,6 @@ preflight1 (PreflightContext const& ctx)
|
|||||||
TER
|
TER
|
||||||
preflight2 (PreflightContext const& ctx)
|
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) &&
|
if(!( ctx.flags & tapNO_CHECK_SIGN) &&
|
||||||
checkValidity(ctx.app.getHashRouter(),
|
checkValidity(ctx.app.getHashRouter(),
|
||||||
ctx.tx, ctx.rules, ctx.app.config(),
|
ctx.tx, ctx.rules, ctx.app.config(),
|
||||||
@@ -128,7 +119,6 @@ Transactor::Transactor(
|
|||||||
ApplyContext& ctx)
|
ApplyContext& ctx)
|
||||||
: ctx_ (ctx)
|
: ctx_ (ctx)
|
||||||
, j_ (ctx.journal)
|
, j_ (ctx.journal)
|
||||||
, mSigMaster (false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,9 +275,6 @@ void Transactor::preCompute ()
|
|||||||
{
|
{
|
||||||
account_ = ctx_.tx.getAccountID(sfAccount);
|
account_ = ctx_.tx.getAccountID(sfAccount);
|
||||||
assert(account_ != zero);
|
assert(account_ != zero);
|
||||||
mSigningPubKey =
|
|
||||||
RippleAddress::createAccountPublic(
|
|
||||||
ctx_.tx.getSigningPubKey());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TER Transactor::apply ()
|
TER Transactor::apply ()
|
||||||
@@ -316,8 +303,6 @@ TER Transactor::apply ()
|
|||||||
|
|
||||||
if (terResult != tesSUCCESS) return terResult;
|
if (terResult != tesSUCCESS) return terResult;
|
||||||
|
|
||||||
checkMasterSign ();
|
|
||||||
|
|
||||||
view().update (sle);
|
view().update (sle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,21 +329,6 @@ Transactor::checkSign (PreclaimContext const& ctx)
|
|||||||
return checkSingleSign (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
|
TER
|
||||||
Transactor::checkSingleSign (PreclaimContext const& ctx)
|
Transactor::checkSingleSign (PreclaimContext const& ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ protected:
|
|||||||
XRPAmount mFeeDue;
|
XRPAmount mFeeDue;
|
||||||
XRPAmount mPriorBalance; // Balance before fees.
|
XRPAmount mPriorBalance; // Balance before fees.
|
||||||
XRPAmount mSourceBalance; // Balance after fees.
|
XRPAmount mSourceBalance; // Balance after fees.
|
||||||
bool mSigMaster;
|
|
||||||
RippleAddress mSigningPubKey;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Process the transaction. */
|
/** Process the transaction. */
|
||||||
@@ -151,7 +149,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void setSeq ();
|
void setSeq ();
|
||||||
TER payFee ();
|
TER payFee ();
|
||||||
void checkMasterSign ();
|
|
||||||
static TER checkSingleSign (PreclaimContext const& ctx);
|
static TER checkSingleSign (PreclaimContext const& ctx);
|
||||||
static TER checkMultiSign (PreclaimContext const& ctx);
|
static TER checkMultiSign (PreclaimContext const& ctx);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user