mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Allow multi-sign to be enabled at runtime:
This lets unit tests exercise multi-sign interfaces without having to set RIPPLE_MULTI_SIGN_ENABLE.
This commit is contained in:
@@ -29,6 +29,9 @@ namespace ripple {
|
||||
// A TransactionEngine applies serialized transactions to a ledger
|
||||
// It can also, verify signatures, verify fees, and give rejection reasons
|
||||
|
||||
struct multisign_t { multisign_t() { } };
|
||||
static multisign_t const multisign;
|
||||
|
||||
// One instance per ledger.
|
||||
// Only one transaction applied at a time.
|
||||
class TransactionEngine
|
||||
@@ -38,6 +41,13 @@ public:
|
||||
static char const* getCountedObjectName () { return "TransactionEngine"; }
|
||||
|
||||
private:
|
||||
bool enableMultiSign_ =
|
||||
#if RIPPLE_ENABLE_MULTI_SIGN
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
LedgerEntrySet mNodes;
|
||||
|
||||
void txnWrite ();
|
||||
@@ -55,6 +65,19 @@ public:
|
||||
assert (mLedger);
|
||||
}
|
||||
|
||||
TransactionEngine (Ledger::ref ledger, multisign_t)
|
||||
: enableMultiSign_(true)
|
||||
, mLedger (ledger)
|
||||
{
|
||||
assert (mLedger);
|
||||
}
|
||||
|
||||
bool
|
||||
enableMultiSign() const
|
||||
{
|
||||
return enableMultiSign_;
|
||||
}
|
||||
|
||||
LedgerEntrySet&
|
||||
view ()
|
||||
{
|
||||
|
||||
@@ -357,6 +357,8 @@ transact_SetSignerList (
|
||||
TransactionEngineParams params,
|
||||
TransactionEngine* engine)
|
||||
{
|
||||
if (! engine->enableMultiSign())
|
||||
return temDISABLED;
|
||||
return SetSignerList (txn, params, engine).apply ();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,13 +74,9 @@ Transactor::transact (
|
||||
case ttTICKET_CANCEL:
|
||||
return transact_CancelTicket (txn, params, engine);
|
||||
|
||||
#if RIPPLE_ENABLE_MULTI_SIGN
|
||||
|
||||
case ttSIGNER_LIST_SET:
|
||||
return transact_SetSignerList (txn, params, engine);
|
||||
|
||||
#endif // RIPPLE_ENABLE_MULTI_SIGN
|
||||
|
||||
default:
|
||||
return temUNKNOWN;
|
||||
}
|
||||
@@ -236,7 +232,7 @@ TER Transactor::preCheckSigningKey ()
|
||||
if (!mTxn.isKnownGood ())
|
||||
{
|
||||
if (mTxn.isKnownBad () ||
|
||||
(!(mParams & tapNO_CHECK_SIGN) && !mTxn.checkSign()))
|
||||
(!(mParams & tapNO_CHECK_SIGN) && !mTxn.checkSign(mEngine->enableMultiSign())))
|
||||
{
|
||||
mTxn.setBad ();
|
||||
m_journal.debug << "apply: Invalid transaction (bad signature)";
|
||||
@@ -307,11 +303,12 @@ TER Transactor::apply ()
|
||||
|
||||
TER Transactor::checkSign ()
|
||||
{
|
||||
#if RIPPLE_ENABLE_MULTI_SIGN
|
||||
// If the mSigningPubKey is empty, then we must be multi-signing.
|
||||
if (mSigningPubKey.getAccountPublic ().empty ())
|
||||
return checkMultiSign ();
|
||||
#endif
|
||||
if(mEngine->enableMultiSign())
|
||||
{
|
||||
// If the mSigningPubKey is empty, then we must be multi-signing.
|
||||
if (mSigningPubKey.getAccountPublic ().empty ())
|
||||
return checkMultiSign ();
|
||||
}
|
||||
|
||||
return checkSingleSign ();
|
||||
}
|
||||
|
||||
@@ -123,7 +123,13 @@ public:
|
||||
|
||||
void sign (RippleAddress const& private_key);
|
||||
|
||||
bool checkSign () const;
|
||||
bool checkSign(bool allowMultiSign =
|
||||
#if RIPPLE_ENABLE_MULTI_SIGN
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
) const;
|
||||
|
||||
bool isKnownGood () const
|
||||
{
|
||||
|
||||
@@ -190,22 +190,25 @@ void STTx::sign (RippleAddress const& private_key)
|
||||
setFieldVL (sfTxnSignature, signature);
|
||||
}
|
||||
|
||||
bool STTx::checkSign () const
|
||||
bool STTx::checkSign(bool allowMultiSign) const
|
||||
{
|
||||
if (boost::indeterminate (sig_state_))
|
||||
{
|
||||
try
|
||||
{
|
||||
#if RIPPLE_ENABLE_MULTI_SIGN
|
||||
// Determine whether we're single- or multi-signing by looking
|
||||
// at the SigningPubKey. It it's empty we must be multi-signing.
|
||||
// Otherwise we're single-signing.
|
||||
Blob const& signingPubKey = getFieldVL (sfSigningPubKey);
|
||||
sig_state_ = signingPubKey.empty () ?
|
||||
checkMultiSign () : checkSingleSign ();
|
||||
#else
|
||||
sig_state_ = checkSingleSign ();
|
||||
#endif // RIPPLE_ENABLE_MULTI_SIGN
|
||||
if (allowMultiSign)
|
||||
{
|
||||
// Determine whether we're single- or multi-signing by looking
|
||||
// at the SigningPubKey. It it's empty we must be multi-signing.
|
||||
// Otherwise we're single-signing.
|
||||
Blob const& signingPubKey = getFieldVL (sfSigningPubKey);
|
||||
sig_state_ = signingPubKey.empty () ?
|
||||
checkMultiSign () : checkSingleSign ();
|
||||
}
|
||||
else
|
||||
{
|
||||
sig_state_ = checkSingleSign ();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user