Do not allow negative fees.

This commit is contained in:
Arthur Britto
2012-12-25 16:21:17 -08:00
parent 77d92e1767
commit 3ccf163fb3
3 changed files with 5 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
{ temMALFORMED, "temMALFORMED", "Malformed transaction." },
{ temBAD_AMOUNT, "temBAD_AMOUNT", "Can only send positive amounts." },
{ temBAD_AUTH_MASTER, "temBAD_AUTH_MASTER", "Auth for unclaimed account needs correct master key." },
{ temBAD_FEE, "temBAD_FEE", "Negative fee." },
{ temBAD_EXPIRATION, "temBAD_EXPIRATION", "Malformed." },
{ temBAD_ISSUER, "temBAD_ISSUER", "Malformed." },
{ temBAD_LIMIT, "temBAD_LIMIT", "Limits must be non-negative." },
@@ -51,7 +52,6 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
{ temBAD_SEQUENCE, "temBAD_SEQUENCE", "Malformed: Sequence in not in the past." },
{ temDST_IS_SRC, "temDST_IS_SRC", "Destination may not be source." },
{ temDST_NEEDED, "temDST_NEEDED", "Destination not specified." },
{ temINSUF_FEE_P, "temINSUF_FEE_P", "Fee not allowed." },
{ temINVALID, "temINVALID", "The transaction is ill-formed." },
{ temINVALID_FLAG, "temINVALID_FLAG", "The transaction has an invalid flag." },
{ temREDUNDANT, "temREDUNDANT", "Sends same currency to self." },

View File

@@ -27,6 +27,7 @@ enum TER // aka TransactionEngineResult
temMALFORMED = -299,
temBAD_AMOUNT,
temBAD_AUTH_MASTER,
temBAD_FEE,
temBAD_EXPIRATION,
temBAD_ISSUER,
temBAD_LIMIT,
@@ -39,7 +40,6 @@ enum TER // aka TransactionEngineResult
temBAD_SET_ID,
temDST_IS_SRC,
temDST_NEEDED,
temINSUF_FEE_P,
temINVALID,
temINVALID_FLAG,
temREDUNDANT,

View File

@@ -57,6 +57,9 @@ TER Transactor::payFee()
return telINSUF_FEE_P;
}
if (saPaid.isNegative())
return temBAD_AMOUNT;
if (!saPaid) return tesSUCCESS;
// Deduct the fee, so it's not available during the transaction.