regular key set fee

This commit is contained in:
jed
2012-11-20 06:31:58 -08:00
parent e837988481
commit 280f832c14
6 changed files with 24 additions and 27 deletions

View File

@@ -122,6 +122,7 @@
<ClCompile Include="src\cpp\ripple\LedgerMaster.cpp" /> <ClCompile Include="src\cpp\ripple\LedgerMaster.cpp" />
<ClCompile Include="src\cpp\ripple\LedgerProposal.cpp" /> <ClCompile Include="src\cpp\ripple\LedgerProposal.cpp" />
<ClCompile Include="src\cpp\ripple\LedgerTiming.cpp" /> <ClCompile Include="src\cpp\ripple\LedgerTiming.cpp" />
<ClCompile Include="src\cpp\ripple\LoadMonitor.cpp" />
<ClCompile Include="src\cpp\ripple\Log.cpp" /> <ClCompile Include="src\cpp\ripple\Log.cpp" />
<ClCompile Include="src\cpp\ripple\main.cpp" /> <ClCompile Include="src\cpp\ripple\main.cpp" />
<ClCompile Include="src\cpp\ripple\NetworkOPs.cpp" /> <ClCompile Include="src\cpp\ripple\NetworkOPs.cpp" />

View File

@@ -345,6 +345,9 @@
<ClCompile Include="src\cpp\ripple\WalletAddTransactor.cpp"> <ClCompile Include="src\cpp\ripple\WalletAddTransactor.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\LoadMonitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="util\pugiconfig.hpp"> <ClInclude Include="util\pugiconfig.hpp">

View File

@@ -1,6 +1,6 @@
#include "LoadMonitor.h" #include "LoadMonitor.h"
void LoadMonitor::LoadMonitor::update() void LoadMonitor::update()
{ // call with the mutex { // call with the mutex
time_t now = time(NULL); time_t now = time(NULL);

View File

@@ -9,6 +9,7 @@ void PaymentTransactor::calculateFee()
{ {
if (mTxn.getFlags() & tfCreateAccount) if (mTxn.getFlags() & tfCreateAccount)
{ {
mFeeDue = theConfig.FEE_ACCOUNT_CREATE; mFeeDue = theConfig.FEE_ACCOUNT_CREATE;
}else Transactor::calculateFee(); }else Transactor::calculateFee();
} }
@@ -146,7 +147,13 @@ TER PaymentTransactor::doApply()
else else
{ {
mTxnAccount->setFieldAmount(sfBalance, saSrcXRPBalance - saDstAmount); 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; terResult = tesSUCCESS;
} }

View File

@@ -4,43 +4,30 @@
SETUP_LOG(); 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() 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() TER RegularKeySetTransactor::doApply()
{ {
std::cerr << "doRegularKeySet>" << std::endl; std::cerr << "doRegularKeySet>" << std::endl;
if (mTxnAccount->getFlags() & lsfPasswordSpent) if(mFeeDue.isZero())
{ {
std::cerr << "doRegularKeySet: Delay transaction: Funds already spent." << std::endl; mTxnAccount->setFlag(lsfPasswordSpent);
return terFUNDS_SPENT;
} }
mTxnAccount->setFlag(lsfPasswordSpent);
uint160 uAuthKeyID=mTxn.getFieldAccount160(sfRegularKey); uint160 uAuthKeyID=mTxn.getFieldAccount160(sfRegularKey);
mTxnAccount->setFieldAccount(sfRegularKey, uAuthKeyID); mTxnAccount->setFieldAccount(sfRegularKey, uAuthKeyID);

View File

@@ -6,6 +6,5 @@ class RegularKeySetTransactor : public Transactor
public: public:
RegularKeySetTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {} RegularKeySetTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {}
TER checkFee(); TER checkFee();
TER checkSig();
TER doApply(); TER doApply();
}; };