Skip to content

Commit

Permalink
Change TER response codes from _XRP to _NATIVE. (XRPLF#184)
Browse files Browse the repository at this point in the history
* Change `_XRP` response codes to `_NATIVE`

* Update ServerDefinitions_test.cpp
  • Loading branch information
dangell7 authored Nov 9, 2023
1 parent 2a18ec5 commit 1959045
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
26 changes: 13 additions & 13 deletions src/ripple/app/tx/impl/Payment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Payment::preflight(PreflightContext const& ctx)
auto const& uSrcCurrency = maxSourceAmount.getCurrency();
auto const& uDstCurrency = saDstAmount.getCurrency();

// isZero() is XRP. FIX!
// isZero() is XAH. FIX!
bool const bXRPDirect = uSrcCurrency.isZero() && uDstCurrency.isZero();

if (!isLegalNet(saDstAmount) || !isLegalNet(maxSourceAmount))
Expand Down Expand Up @@ -132,36 +132,36 @@ Payment::preflight(PreflightContext const& ctx)
{
// Consistent but redundant transaction.
JLOG(j.trace()) << "Malformed transaction: "
<< "SendMax specified for XRP to XRP.";
return temBAD_SEND_XRP_MAX;
<< "SendMax specified for XAH to XAH.";
return temBAD_SEND_NATIVE_MAX;
}
if (bXRPDirect && bPaths)
{
// XRP is sent without paths.
// XAH is sent without paths.
JLOG(j.trace()) << "Malformed transaction: "
<< "Paths specified for XRP to XRP.";
return temBAD_SEND_XRP_PATHS;
<< "Paths specified for XAH to XAH.";
return temBAD_SEND_NATIVE_PATHS;
}
if (bXRPDirect && partialPaymentAllowed)
{
// Consistent but redundant transaction.
JLOG(j.trace()) << "Malformed transaction: "
<< "Partial payment specified for XRP to XRP.";
return temBAD_SEND_XRP_PARTIAL;
<< "Partial payment specified for XAH to XAH.";
return temBAD_SEND_NATIVE_PARTIAL;
}
if (bXRPDirect && limitQuality)
{
// Consistent but redundant transaction.
JLOG(j.trace()) << "Malformed transaction: "
<< "Limit quality specified for XRP to XRP.";
return temBAD_SEND_XRP_LIMIT;
<< "Limit quality specified for XAH to XAH.";
return temBAD_SEND_NATIVE_LIMIT;
}
if (bXRPDirect && !defaultPathsAllowed)
{
// Consistent but redundant transaction.
JLOG(j.trace()) << "Malformed transaction: "
<< "No ripple direct specified for XRP to XRP.";
return temBAD_SEND_XRP_NO_DIRECT;
<< "No ripple direct specified for XAH to XAH.";
return temBAD_SEND_NATIVE_NO_DIRECT;
}

auto const deliverMin = tx[~sfDeliverMin];
Expand Down Expand Up @@ -252,7 +252,7 @@ Payment::preclaim(PreclaimContext const& ctx)
// TODO: dedupe
// Another transaction could create the account and then this
// transaction would succeed.
return tecNO_DST_INSUF_XRP;
return tecNO_DST_INSUF_NATIVE;
}
}
else if (
Expand Down
12 changes: 6 additions & 6 deletions src/ripple/protocol/TER.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ enum TEMcodes : TERUnderlyingType {
temBAD_PATH,
temBAD_PATH_LOOP,
temBAD_REGKEY,
temBAD_SEND_XRP_LIMIT,
temBAD_SEND_XRP_MAX,
temBAD_SEND_XRP_NO_DIRECT,
temBAD_SEND_XRP_PARTIAL,
temBAD_SEND_XRP_PATHS,
temBAD_SEND_NATIVE_LIMIT,
temBAD_SEND_NATIVE_MAX,
temBAD_SEND_NATIVE_NO_DIRECT,
temBAD_SEND_NATIVE_PARTIAL,
temBAD_SEND_NATIVE_PATHS,
temBAD_SEQUENCE,
temBAD_SIGNATURE,
temBAD_SRC_ACCOUNT,
Expand Down Expand Up @@ -276,7 +276,7 @@ enum TECcodes : TERUnderlyingType {
tecINSUF_RESERVE_LINE = 122,
tecINSUF_RESERVE_OFFER = 123,
tecNO_DST = 124,
tecNO_DST_INSUF_XRP = 125,
tecNO_DST_INSUF_NATIVE = 125,
tecNO_LINE_INSUF_RESERVE = 126,
tecNO_LINE_REDUNDANT = 127,
tecPATH_DRY = 128,
Expand Down
18 changes: 9 additions & 9 deletions src/ripple/protocol/impl/TER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ transResults()
MAKE_ERROR(tecFAILED_PROCESSING, "Failed to correctly process transaction."),
MAKE_ERROR(tecINSUF_RESERVE_LINE, "Insufficient reserve to add trust line."),
MAKE_ERROR(tecINSUF_RESERVE_OFFER, "Insufficient reserve to create offer."),
MAKE_ERROR(tecNO_DST, "Destination does not exist. Send XRP to create it."),
MAKE_ERROR(tecNO_DST_INSUF_XRP, "Destination does not exist. Too little XRP sent to create it."),
MAKE_ERROR(tecNO_DST, "Destination does not exist. Send XAH to create it."),
MAKE_ERROR(tecNO_DST_INSUF_NATIVE, "Destination does not exist. Too little XAH sent to create it."),
MAKE_ERROR(tecNO_LINE_INSUF_RESERVE, "No such line. Too little reserve to create it."),
MAKE_ERROR(tecNO_LINE_REDUNDANT, "Can't set non-existent line to default."),
MAKE_ERROR(tecPATH_DRY, "Path could not send partial amount."),
MAKE_ERROR(tecPATH_PARTIAL, "Path could not send full amount."),
MAKE_ERROR(tecNO_ALTERNATIVE_KEY, "The operation would remove the ability to sign transactions with the account."),
MAKE_ERROR(tecNO_REGULAR_KEY, "Regular key is not set."),
MAKE_ERROR(tecOVERSIZE, "Object exceeded serialization limits."),
MAKE_ERROR(tecUNFUNDED, "Not enough XRP to satisfy the reserve requirement."),
MAKE_ERROR(tecUNFUNDED, "Not enough XAH to satisfy the reserve requirement."),
MAKE_ERROR(tecUNFUNDED_ADD, "DEPRECATED."),
MAKE_ERROR(tecUNFUNDED_OFFER, "Insufficient balance to fund created offer."),
MAKE_ERROR(tecUNFUNDED_PAYMENT, "Insufficient balance to send."),
Expand Down Expand Up @@ -139,19 +139,19 @@ transResults()
MAKE_ERROR(temBAD_AMOUNT, "Can only send positive amounts."),
MAKE_ERROR(temBAD_CURRENCY, "Malformed: Bad currency."),
MAKE_ERROR(temBAD_EXPIRATION, "Malformed: Bad expiration."),
MAKE_ERROR(temBAD_FEE, "Invalid fee, negative or not XRP."),
MAKE_ERROR(temBAD_FEE, "Invalid fee, negative or not XAH."),
MAKE_ERROR(temBAD_ISSUER, "Malformed: Bad issuer."),
MAKE_ERROR(temBAD_LIMIT, "Limits must be non-negative."),
MAKE_ERROR(temBAD_OFFER, "Malformed: Bad offer."),
MAKE_ERROR(temBAD_PATH, "Malformed: Bad path."),
MAKE_ERROR(temBAD_PATH_LOOP, "Malformed: Loop in path."),
MAKE_ERROR(temBAD_QUORUM, "Malformed: Quorum is unreachable."),
MAKE_ERROR(temBAD_REGKEY, "Malformed: Regular key cannot be same as master key."),
MAKE_ERROR(temBAD_SEND_XRP_LIMIT, "Malformed: Limit quality is not allowed for XRP to XRP."),
MAKE_ERROR(temBAD_SEND_XRP_MAX, "Malformed: Send max is not allowed for XRP to XRP."),
MAKE_ERROR(temBAD_SEND_XRP_NO_DIRECT, "Malformed: No Ripple direct is not allowed for XRP to XRP."),
MAKE_ERROR(temBAD_SEND_XRP_PARTIAL, "Malformed: Partial payment is not allowed for XRP to XRP."),
MAKE_ERROR(temBAD_SEND_XRP_PATHS, "Malformed: Paths are not allowed for XRP to XRP."),
MAKE_ERROR(temBAD_SEND_NATIVE_LIMIT, "Malformed: Limit quality is not allowed for XAH to XAH."),
MAKE_ERROR(temBAD_SEND_NATIVE_MAX, "Malformed: Send max is not allowed for XAH to XAH."),
MAKE_ERROR(temBAD_SEND_NATIVE_NO_DIRECT, "Malformed: No Ripple direct is not allowed for XAH to XAH."),
MAKE_ERROR(temBAD_SEND_NATIVE_PARTIAL, "Malformed: Partial payment is not allowed for XAH to XAH."),
MAKE_ERROR(temBAD_SEND_NATIVE_PATHS, "Malformed: Paths are not allowed for XAH to XAH."),
MAKE_ERROR(temBAD_SEQUENCE, "Malformed: Sequence is not in the past."),
MAKE_ERROR(temBAD_SIGNATURE, "Malformed: Bad signature."),
MAKE_ERROR(temBAD_SIGNER, "Malformed: No signer may duplicate account or other signers."),
Expand Down
4 changes: 2 additions & 2 deletions src/test/app/AccountDelete_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,12 @@ class AccountDelete_test : public beast::unit_test::suite
// Verify that becky's account root is gone.
BEAST_EXPECT(!env.closed()->exists(beckyAcctKey));

// All it takes is a large enough XRP payment to resurrect
// All it takes is a large enough XAH payment to resurrect
// becky's account. Try too small a payment.
env(pay(alice,
becky,
drops(env.current()->fees().accountReserve(0)) - XRP(1)),
ter(tecNO_DST_INSUF_XRP));
ter(tecNO_DST_INSUF_NATIVE));
env.close();

// Actually resurrect becky's account.
Expand Down
4 changes: 2 additions & 2 deletions src/test/app/PayStrand_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ struct PayStrand_test : public beast::unit_test::suite
env(pay(alice, carol, XRP(100)),
path(~USD, ~XRP),
txflags(tfNoRippleDirect),
ter(temBAD_SEND_XRP_PATHS));
ter(temBAD_SEND_NATIVE_PATHS));
}

{
Expand All @@ -1117,7 +1117,7 @@ struct PayStrand_test : public beast::unit_test::suite
path(~USD, ~XRP),
sendmax(XRP(200)),
txflags(tfNoRippleDirect),
ter(temBAD_SEND_XRP_MAX));
ter(temBAD_SEND_NATIVE_MAX));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/app/TrustAndBalance_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TrustAndBalance_test : public beast::unit_test::suite
using namespace test::jtx;

Env env{*this, features};
env(pay(env.master, "alice", XRP(1)), ter(tecNO_DST_INSUF_XRP));
env(pay(env.master, "alice", XRP(1)), ter(tecNO_DST_INSUF_NATIVE));
env.close();
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/rpc/AccountTx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,12 +723,12 @@ class AccountTx_test : public beast::unit_test::suite
}
}

// All it takes is a large enough XRP payment to resurrect
// All it takes is a large enough XAH payment to resurrect
// becky's account. Try too small a payment.
env(pay(alice,
becky,
drops(env.current()->fees().accountReserve(0)) - XRP(1)),
ter(tecNO_DST_INSUF_XRP));
ter(tecNO_DST_INSUF_NATIVE));
env.close();

// Actually resurrect becky's account.
Expand Down
12 changes: 6 additions & 6 deletions src/test/rpc/ServerDefinitions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ServerDefinitions_test : public beast::unit_test::suite
"tecNO_ALTERNATIVE_KEY" : 130,
"tecNO_AUTH" : 134,
"tecNO_DST" : 124,
"tecNO_DST_INSUF_XRP" : 125,
"tecNO_DST_INSUF_NATIVE" : 125,
"tecNO_ENTRY" : 140,
"tecNO_ISSUER" : 133,
"tecNO_LINE" : 135,
Expand Down Expand Up @@ -285,11 +285,11 @@ class ServerDefinitions_test : public beast::unit_test::suite
"temBAD_PATH_LOOP" : -290,
"temBAD_QUORUM" : -271,
"temBAD_REGKEY" : -289,
"temBAD_SEND_XRP_LIMIT" : -288,
"temBAD_SEND_XRP_MAX" : -287,
"temBAD_SEND_XRP_NO_DIRECT" : -286,
"temBAD_SEND_XRP_PARTIAL" : -285,
"temBAD_SEND_XRP_PATHS" : -284,
"temBAD_SEND_NATIVE_LIMIT" : -288,
"temBAD_SEND_NATIVE_MAX" : -287,
"temBAD_SEND_NATIVE_NO_DIRECT" : -286,
"temBAD_SEND_NATIVE_PARTIAL" : -285,
"temBAD_SEND_NATIVE_PATHS" : -284,
"temBAD_SEQUENCE" : -283,
"temBAD_SIGNATURE" : -282,
"temBAD_SIGNER" : -272,
Expand Down

0 comments on commit 1959045

Please sign in to comment.