Merge branch 'reserve'

This commit is contained in:
Arthur Britto
2012-12-12 21:55:25 -08:00
8 changed files with 36 additions and 58 deletions

View File

@@ -13,11 +13,11 @@
#define SECTION_ACCOUNT_PROBE_MAX "account_probe_max"
#define SECTION_DEBUG_LOGFILE "debug_logfile"
#define SECTION_FEE_ACCOUNT_CREATE "fee_account_create"
#define SECTION_FEE_DEFAULT "fee_default"
#define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create"
#define SECTION_FEE_OFFER "fee_offer"
#define SECTION_FEE_OPERATION "fee_operation"
#define SECTION_FEE_RESERVE "fee_reserve"
#define SECTION_LEDGER_HISTORY "ledger_history"
#define SECTION_IPS "ips"
#define SECTION_NETWORK_QUORUM "network_quorum"
@@ -48,7 +48,7 @@
// Fees are in XRP.
#define DEFAULT_FEE_DEFAULT 10
#define DEFAULT_FEE_ACCOUNT_CREATE 200*SYSTEM_CURRENCY_PARTS
#define DEFAULT_FEE_RESERVE 200*SYSTEM_CURRENCY_PARTS
#define DEFAULT_FEE_NICKNAME_CREATE 1000
#define DEFAULT_FEE_OFFER DEFAULT_FEE_DEFAULT
#define DEFAULT_FEE_OPERATION 1
@@ -162,7 +162,7 @@ void Config::setup(const std::string& strConf, bool bQuiet)
NETWORK_QUORUM = 0; // Don't need to see other nodes
VALIDATION_QUORUM = 1; // Only need one node to vouch
FEE_ACCOUNT_CREATE = DEFAULT_FEE_ACCOUNT_CREATE;
FEE_RESERVE = DEFAULT_FEE_RESERVE;
FEE_NICKNAME_CREATE = DEFAULT_FEE_NICKNAME_CREATE;
FEE_OFFER = DEFAULT_FEE_OFFER;
FEE_DEFAULT = DEFAULT_FEE_DEFAULT;
@@ -297,8 +297,8 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_VALIDATION_QUORUM, strTemp))
VALIDATION_QUORUM = std::max(0, boost::lexical_cast<int>(strTemp));
if (sectionSingleB(secConfig, SECTION_FEE_ACCOUNT_CREATE, strTemp))
FEE_ACCOUNT_CREATE = boost::lexical_cast<int>(strTemp);
if (sectionSingleB(secConfig, SECTION_FEE_RESERVE, strTemp))
FEE_RESERVE = boost::lexical_cast<uint64>(strTemp);
if (sectionSingleB(secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp))
FEE_NICKNAME_CREATE = boost::lexical_cast<int>(strTemp);

View File

@@ -106,9 +106,9 @@ public:
// Validation
RippleAddress VALIDATION_SEED, VALIDATION_PUB, VALIDATION_PRIV;
// Fees
// Fee schedule
uint64 FEE_DEFAULT; // Default fee.
uint64 FEE_ACCOUNT_CREATE; // Fee to create an account.
uint64 FEE_RESERVE; // Amount of XRP not allowed to send.
uint64 FEE_NICKNAME_CREATE; // Fee to create a nickname.
uint64 FEE_OFFER; // Rate per day.
int FEE_CONTRACT_OPERATION; // fee for each contract operation

View File

@@ -4,23 +4,10 @@
#define RIPPLE_PATHS_MAX 3
// only have the higher fee if the account doesn't in fact exist
void PaymentTransactor::calculateFee()
{
if (mTxn.getFlags() & tfCreateAccount)
{
const uint160 uDstAccountID = mTxn.getFieldAccount160(sfDestination);
SLE::pointer sleDst = mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
if(!sleDst) mFeeDue = theConfig.FEE_ACCOUNT_CREATE;
else Transactor::calculateFee();
}else Transactor::calculateFee();
}
TER PaymentTransactor::doApply()
{
// Ripple if source or destination is non-native or if there are paths.
const uint32 uTxFlags = mTxn.getFlags();
const bool bCreate = isSetBit(uTxFlags, tfCreateAccount);
const bool bPartialPayment = isSetBit(uTxFlags, tfPartialPayment);
const bool bLimitQuality = isSetBit(uTxFlags, tfLimitQuality);
const bool bNoRippleDirect = isSetBit(uTxFlags, tfNoRippleDirect);
@@ -87,17 +74,20 @@ TER PaymentTransactor::doApply()
if (!sleDst)
{
// Destination account does not exist.
if (bCreate && !saDstAmount.isNative())
if (!saDstAmount.isNative())
{
// This restriction could be relaxed.
Log(lsINFO) << "doPayment: Malformed transaction: Create account may only fund XRP.";
return temCREATEXRP;
}
else if (!bCreate)
else if (isSetBit(mParams, tapOPEN_LEDGER) // Ledger is not final, we can vote.
&& saDstAmount.getNValue() < theConfig.FEE_RESERVE) // Reserve is not scaled by fee.
{
Log(lsINFO) << "doPayment: Delay transaction: Destination account does not exist.";
Log(lsINFO) << "doPayment: Delay transaction: Destination account does not exist insufficent payment to create account.";
// Not a local failure. Another transaction could create account and then this transaction would succeed.
return terNO_DST;
}
@@ -148,7 +138,7 @@ TER PaymentTransactor::doApply()
STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance);
if (saSrcXRPBalance < saDstAmount)
if (saSrcXRPBalance < saDstAmount + theConfig.FEE_RESERVE) // Reserve is not scaled by fee.
{
// Transaction might succeed, if applied in a different order.
Log(lsINFO) << "doPayment: Delay transaction: Insufficient funds.";
@@ -158,13 +148,18 @@ TER PaymentTransactor::doApply()
else
{
mTxnAccount->setFieldAmount(sfBalance, saSrcXRPBalance - 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);
}
else
{
sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount);
}
terResult = tesSUCCESS;
}

View File

@@ -5,7 +5,6 @@
class PaymentTransactor : public Transactor
{
void calculateFee();
public:
PaymentTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {}

View File

@@ -912,10 +912,7 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest)
if (!txJSON.isMember("Fee"))
{
if (mNetOps->getAccountState(mNetOps->getCurrentLedger(), dstAccountID))
txJSON["Fee"] = (int) theConfig.FEE_DEFAULT;
else
txJSON["Fee"] = (int) theConfig.FEE_ACCOUNT_CREATE;
txJSON["Fee"] = (int) theConfig.FEE_DEFAULT;
}
if (txJSON.isMember("Paths") && jvRequest.isMember("build_path"))

View File

@@ -61,12 +61,12 @@ const uint32 tfPassive = 0x00010000;
const uint32 tfOfferCreateMask = ~(tfPassive);
// Payment flags:
const uint32 tfCreateAccount = 0x00010000;
const uint32 tfPaymentLegacy = 0x00010000; // Left here to avoid ledger change.
const uint32 tfPartialPayment = 0x00020000;
const uint32 tfLimitQuality = 0x00040000;
const uint32 tfNoRippleDirect = 0x00080000;
const uint32 tfPaymentMask = ~(tfCreateAccount|tfPartialPayment|tfLimitQuality|tfNoRippleDirect);
const uint32 tfPaymentMask = ~(tfPartialPayment|tfLimitQuality|tfNoRippleDirect);
#endif
// vim:ts=4