From 280f832c14db5277227d7cb1386d60b6797c3062 Mon Sep 17 00:00:00 2001 From: jed Date: Tue, 20 Nov 2012 06:31:58 -0800 Subject: [PATCH] regular key set fee --- ripple2010.vcxproj | 1 + ripple2010.vcxproj.filters | 3 ++ src/cpp/ripple/LoadMonitor.cpp | 2 +- src/cpp/ripple/PaymentTransactor.cpp | 9 +++++- src/cpp/ripple/RegularKeySetTransactor.cpp | 35 +++++++--------------- src/cpp/ripple/RegularKeySetTransactor.h | 1 - 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ripple2010.vcxproj b/ripple2010.vcxproj index 374a65bd6..7867ca8f9 100644 --- a/ripple2010.vcxproj +++ b/ripple2010.vcxproj @@ -122,6 +122,7 @@ + diff --git a/ripple2010.vcxproj.filters b/ripple2010.vcxproj.filters index 9e03588ae..5650c2763 100644 --- a/ripple2010.vcxproj.filters +++ b/ripple2010.vcxproj.filters @@ -345,6 +345,9 @@ Source Files + + Source Files + diff --git a/src/cpp/ripple/LoadMonitor.cpp b/src/cpp/ripple/LoadMonitor.cpp index 958fe2108..2011035ae 100644 --- a/src/cpp/ripple/LoadMonitor.cpp +++ b/src/cpp/ripple/LoadMonitor.cpp @@ -1,6 +1,6 @@ #include "LoadMonitor.h" -void LoadMonitor::LoadMonitor::update() +void LoadMonitor::update() { // call with the mutex time_t now = time(NULL); diff --git a/src/cpp/ripple/PaymentTransactor.cpp b/src/cpp/ripple/PaymentTransactor.cpp index 7577341cb..b8421d10e 100644 --- a/src/cpp/ripple/PaymentTransactor.cpp +++ b/src/cpp/ripple/PaymentTransactor.cpp @@ -9,6 +9,7 @@ void PaymentTransactor::calculateFee() { if (mTxn.getFlags() & tfCreateAccount) { + mFeeDue = theConfig.FEE_ACCOUNT_CREATE; }else Transactor::calculateFee(); } @@ -146,7 +147,13 @@ TER PaymentTransactor::doApply() else { mTxnAccount->setFieldAmount(sfBalance, saSrcXRPBalance - saDstAmount); - sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount); + // re-arm the password change fee if we can and need to + if ( (sleDst->getFlags() & lsfPasswordSpent) && + (saDstAmount > theConfig.FEE_DEFAULT) ) + { + sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount-theConfig.FEE_DEFAULT); + sleDst->clearFlag(lsfPasswordSpent); + }else sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount); terResult = tesSUCCESS; } diff --git a/src/cpp/ripple/RegularKeySetTransactor.cpp b/src/cpp/ripple/RegularKeySetTransactor.cpp index eb89bed28..f74b8f5a9 100644 --- a/src/cpp/ripple/RegularKeySetTransactor.cpp +++ b/src/cpp/ripple/RegularKeySetTransactor.cpp @@ -4,43 +4,30 @@ SETUP_LOG(); -// TODO: -TER RegularKeySetTransactor::checkSig() -{ - // Transaction's signing public key must be for the source account. - // To prove the master private key made this transaction. - if (mSigningPubKey.getAccountID() != mTxnAccountID) - { - // Signing Pub Key must be for Source Account ID. - cLog(lsWARNING) << "sourceAccountID: " << mSigningPubKey.humanAccountID(); - cLog(lsWARNING) << "txn accountID: " << mTxn.getSourceAccount().humanAccountID(); - return temBAD_SET_ID; - } - return tesSUCCESS; -} - -// TODO: this should be default fee if flag isn't set void RegularKeySetTransactor::calculateFee() { - mFeeDue = 0; + Transactor::calculateFee(); + + if ( !(mTxnAccount->getFlags() & lsfPasswordSpent) && + (mSigningPubKey.getAccountID() == mTxnAccountID)) + { // flag is armed and they signed with the right account + + mSourceBalance = mTxnAccount->getFieldAmount(sfBalance); + if(mSourceBalance < mFeeDue) mFeeDue = 0; + } } -// TODO: change to take a fee if there is one there TER RegularKeySetTransactor::doApply() { std::cerr << "doRegularKeySet>" << std::endl; - if (mTxnAccount->getFlags() & lsfPasswordSpent) + if(mFeeDue.isZero()) { - std::cerr << "doRegularKeySet: Delay transaction: Funds already spent." << std::endl; - - return terFUNDS_SPENT; + mTxnAccount->setFlag(lsfPasswordSpent); } - mTxnAccount->setFlag(lsfPasswordSpent); - uint160 uAuthKeyID=mTxn.getFieldAccount160(sfRegularKey); mTxnAccount->setFieldAccount(sfRegularKey, uAuthKeyID); diff --git a/src/cpp/ripple/RegularKeySetTransactor.h b/src/cpp/ripple/RegularKeySetTransactor.h index a6df0b356..35d744c8f 100644 --- a/src/cpp/ripple/RegularKeySetTransactor.h +++ b/src/cpp/ripple/RegularKeySetTransactor.h @@ -6,6 +6,5 @@ class RegularKeySetTransactor : public Transactor public: RegularKeySetTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {} TER checkFee(); - TER checkSig(); TER doApply(); };