diff --git a/src/ripple/app/tx/TransactionEngine.h b/src/ripple/app/tx/TransactionEngine.h index dbfdf5f69..3a6104fef 100644 --- a/src/ripple/app/tx/TransactionEngine.h +++ b/src/ripple/app/tx/TransactionEngine.h @@ -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 () { diff --git a/src/ripple/app/tx/impl/SetSignerList.cpp b/src/ripple/app/tx/impl/SetSignerList.cpp index 9e45a4c54..6ce712404 100644 --- a/src/ripple/app/tx/impl/SetSignerList.cpp +++ b/src/ripple/app/tx/impl/SetSignerList.cpp @@ -357,6 +357,8 @@ transact_SetSignerList ( TransactionEngineParams params, TransactionEngine* engine) { + if (! engine->enableMultiSign()) + return temDISABLED; return SetSignerList (txn, params, engine).apply (); } diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 071d73c75..e8d00d90b 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -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 (); } diff --git a/src/ripple/protocol/STTx.h b/src/ripple/protocol/STTx.h index aaf7e6578..88dacaaa6 100644 --- a/src/ripple/protocol/STTx.h +++ b/src/ripple/protocol/STTx.h @@ -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 { diff --git a/src/ripple/protocol/impl/STTx.cpp b/src/ripple/protocol/impl/STTx.cpp index d927731ea..037753fbf 100644 --- a/src/ripple/protocol/impl/STTx.cpp +++ b/src/ripple/protocol/impl/STTx.cpp @@ -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 (...) {