mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
add error message, address isAddable xrp edgecases
This commit is contained in:
@@ -530,15 +530,33 @@ isFakeXRP(STAmount const& amount)
|
||||
inline bool
|
||||
isAddable(STAmount const& amt1, STAmount const& amt2)
|
||||
{
|
||||
// special case: adding anything to zero is always fine
|
||||
if (amt1 == beast::zero || amt2 == beast::zero)
|
||||
return true;
|
||||
|
||||
// special case: adding two xrp amounts together.
|
||||
// this is just an overflow check
|
||||
if (isXRP(amt1) && isXRP(amt2))
|
||||
{
|
||||
XRPAmount A = (amt1.signum() == -1 ? -(amt1.xrp()) : amt1.xrp());
|
||||
XRPAmount B = (amt2.signum() == -1 ? -(amt2.xrp()) : amt2.xrp());
|
||||
|
||||
XRPAmount finalAmt = A + B;
|
||||
return (finalAmt >= A && finalAmt >= B);
|
||||
}
|
||||
|
||||
static const STAmount one {IOUAmount{1, 0}, noIssue()};
|
||||
static const STAmount maxLoss {IOUAmount{1, -4}, noIssue()};
|
||||
|
||||
STAmount A = amt1;
|
||||
STAmount B = amt2;
|
||||
|
||||
if (isXRP(A))
|
||||
A = STAmount{IOUAmount{A.xrp().drops(), -6}, noIssue()};
|
||||
|
||||
if (isXRP(B))
|
||||
B = STAmount{IOUAmount{B.xrp().drops(), -6}, noIssue()};
|
||||
|
||||
A.setIssue(noIssue());
|
||||
B.setIssue(noIssue());
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ transResults()
|
||||
MAKE_ERROR(tecINSUFFICIENT_FUNDS, "Not enough funds available to complete requested transaction."),
|
||||
MAKE_ERROR(tecOBJECT_NOT_FOUND, "A requested object could not be located."),
|
||||
MAKE_ERROR(tecINSUFFICIENT_PAYMENT, "The payment is not sufficient."),
|
||||
|
||||
MAKE_ERROR(tecPRECISION_LOSS, "The IOU amounts used by the transaction cannot interact."),
|
||||
MAKE_ERROR(tefALREADY, "The exact transaction was already in this ledger."),
|
||||
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),
|
||||
MAKE_ERROR(tefBAD_AUTH, "Transaction's public key is not authorized."),
|
||||
|
||||
Reference in New Issue
Block a user