From 83e347c839905a45e11684c10706f06770c0679d Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Wed, 20 Mar 2013 01:21:41 -0700 Subject: [PATCH] #27 Error creating offer without auth. --- src/cpp/ripple/OfferCreateTransactor.cpp | 11 +++++++++++ src/cpp/ripple/TransactionErr.cpp | 1 + src/cpp/ripple/TransactionErr.h | 1 + test/path-test.js | 4 ++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cpp/ripple/OfferCreateTransactor.cpp b/src/cpp/ripple/OfferCreateTransactor.cpp index afff90699..686b21e83 100644 --- a/src/cpp/ripple/OfferCreateTransactor.cpp +++ b/src/cpp/ripple/OfferCreateTransactor.cpp @@ -426,6 +426,17 @@ TER OfferCreateTransactor::doApply() terResult = terNO_ACCOUNT; } + else if (isSetBit(sleTakerPays->getFieldU32(sfFlags), lsfRequireAuth)) { + SLE::pointer sleRippleState = mEngine->entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uPaysIssuerID, uPaysCurrency)); + bool bHigh = mTxnAccountID > uPaysIssuerID; + + if (!sleRippleState + || !isSetBit(sleRippleState->getFieldU32(sfFlags), (bHigh ? lsfHighAuth : lsfLowAuth))) { + cLog(lsWARNING) << "OfferCreate: delay: can't receive IOUs from issuer without auth."; + + terResult = terNO_AUTH; + } + } } STAmount saPaid; diff --git a/src/cpp/ripple/TransactionErr.cpp b/src/cpp/ripple/TransactionErr.cpp index a605a2f49..160064ffe 100644 --- a/src/cpp/ripple/TransactionErr.cpp +++ b/src/cpp/ripple/TransactionErr.cpp @@ -82,6 +82,7 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman) { terFUNDS_SPENT, "terFUNDS_SPENT", "Can't set password, password set funds already spent." }, { terINSUF_FEE_B, "terINSUF_FEE_B", "Account balance can't pay fee." }, { terNO_ACCOUNT, "terNO_ACCOUNT", "The source account does not exist." }, + { terNO_AUTH, "terNO_AUTH", "Not authorized to hold IOUs." }, { terNO_LINE, "terNO_LINE", "No such line." }, { terPRE_SEQ, "terPRE_SEQ", "Missing/inapplicable prior transaction." }, { terOWNERS, "terOWNERS", "Non-zero owner count." }, diff --git a/src/cpp/ripple/TransactionErr.h b/src/cpp/ripple/TransactionErr.h index a1d9fb690..fe54d9f4b 100644 --- a/src/cpp/ripple/TransactionErr.h +++ b/src/cpp/ripple/TransactionErr.h @@ -95,6 +95,7 @@ enum TER // aka TransactionEngineResult terFUNDS_SPENT, // This is a free transaction, therefore don't burden network. terINSUF_FEE_B, // Can't pay fee, therefore don't burden network. terNO_ACCOUNT, // Can't pay fee, therefore don't burden network. + terNO_AUTH, // Not authorized to hold IOUs. terNO_LINE, // Internal flag. terOWNERS, // Can't succeed with non-zero owner count. terPRE_SEQ, // Can't pay fee, no point in forwarding, therefore don't burden network. diff --git a/test/path-test.js b/test/path-test.js index 59ffd8cc0..ee75afbd6 100644 --- a/test/path-test.js +++ b/test/path-test.js @@ -1189,8 +1189,8 @@ buster.testCase("Indirect paths", { }); buster.testCase("Quality paths", { - // 'setUp' : testutils.build_setup(), - 'setUp' : testutils.build_setup({ verbose: true }), + 'setUp' : testutils.build_setup(), + // 'setUp' : testutils.build_setup({ verbose: true }), // 'setUp' : testutils.build_setup({ verbose: true, no_server: true }), 'tearDown' : testutils.build_teardown(),