From adf30fb819cbbdbb62da4de884186edd690e9fab Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Thu, 19 Oct 2023 12:11:12 +0200 Subject: [PATCH] `XRP` -> `XAH` (#134) * `XRP` -> `XAH` * update rpc * fix badCurrency * revert consensus update * `xah` -> `native` in rpc commands * Update Consensus.h --- src/ripple/app/misc/NetworkOPs.cpp | 5 ++ src/ripple/overlay/impl/OverlayImpl.cpp | 2 + src/ripple/protocol/SystemParameters.h | 2 +- src/ripple/protocol/UintTypes.h | 4 +- src/ripple/protocol/impl/UintTypes.cpp | 2 +- src/ripple/protocol/jss.h | 3 ++ src/test/app/Freeze_test.cpp | 8 ++-- src/test/app/Offer_test.cpp | 2 +- src/test/basics/StringUtilities_test.cpp | 2 +- src/test/protocol/STAmount_test.cpp | 2 +- src/test/rpc/Book_test.cpp | 58 ++++++++++++------------ 11 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 067962965..faf6cf5d0 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -2658,6 +2658,11 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) lpClosed->fees().accountReserve(0).decimalXRP(); l[jss::reserve_inc_xrp] = lpClosed->fees().increment.decimalXRP(); + l[jss::base_fee_native] = baseFee.decimalXRP(); + l[jss::reserve_base_native] = + lpClosed->fees().accountReserve(0).decimalXRP(); + l[jss::reserve_inc_native] = lpClosed->fees().increment.decimalXRP(); + auto const nowOffset = app_.timeKeeper().nowOffset(); if (std::abs(nowOffset.count()) >= 60) l[jss::system_time_offset] = nowOffset.count(); diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 90a0af774..43fa80a3d 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -858,7 +858,9 @@ OverlayImpl::getServerInfo() validated_ledger.removeMember(jss::base_fee); validated_ledger.removeMember(jss::reserve_base_xrp); + validated_ledger.removeMember(jss::reserve_base_native); validated_ledger.removeMember(jss::reserve_inc_xrp); + validated_ledger.removeMember(jss::reserve_inc_native); } return server_info; diff --git a/src/ripple/protocol/SystemParameters.h b/src/ripple/protocol/SystemParameters.h index a4322e1b8..e9da99297 100644 --- a/src/ripple/protocol/SystemParameters.h +++ b/src/ripple/protocol/SystemParameters.h @@ -61,7 +61,7 @@ isLegalAmountSigned(XRPAmount const& amount) static inline std::string const& systemCurrencyCode() { - static std::string const code = "XRP"; + static std::string const code = "XAH"; return code; } diff --git a/src/ripple/protocol/UintTypes.h b/src/ripple/protocol/UintTypes.h index 895da7d9e..3ad9c7bca 100644 --- a/src/ripple/protocol/UintTypes.h +++ b/src/ripple/protocol/UintTypes.h @@ -66,7 +66,7 @@ xrpCurrency(); Currency const& noCurrency(); -/** We deliberately disallow the currency that looks like "XRP" because too +/** We deliberately disallow the currency that looks like "XAH" because too many people were using it instead of the correct XRP currency. */ Currency const& badCurrency(); @@ -83,7 +83,7 @@ isFakeXRP(Currency const& c) return c == badCurrency(); } -/** Returns "", "XRP", or three letter ISO code. */ +/** Returns "", "XAH", or three letter ISO code. */ std::string to_string(Currency const& c); diff --git a/src/ripple/protocol/impl/UintTypes.cpp b/src/ripple/protocol/impl/UintTypes.cpp index ff2644b08..7657146aa 100644 --- a/src/ripple/protocol/impl/UintTypes.cpp +++ b/src/ripple/protocol/impl/UintTypes.cpp @@ -134,7 +134,7 @@ noCurrency() Currency const& badCurrency() { - static Currency const currency(0x5852500000000000); + static Currency const currency(0x5841480000000000); return currency; } diff --git a/src/ripple/protocol/jss.h b/src/ripple/protocol/jss.h index 75aba981e..166bf0623 100644 --- a/src/ripple/protocol/jss.h +++ b/src/ripple/protocol/jss.h @@ -197,6 +197,7 @@ JSS(balances); // out: GatewayBalances JSS(base); // out: LogLevel JSS(base_fee); // out: NetworkOPs JSS(base_fee_xrp); // out: NetworkOPs +JSS(base_fee_native); // out: NetworkOPs JSS(bids); // out: Subscribe JSS(binary); // in: AccountTX, LedgerEntry, // AccountTxOld, Tx LedgerData @@ -563,8 +564,10 @@ JSS(requested); // out: Manifest JSS(reservations); // out: Reservations JSS(reserve_base); // out: NetworkOPs JSS(reserve_base_xrp); // out: NetworkOPs +JSS(reserve_base_native); // out: NetworkOPs JSS(reserve_inc); // out: NetworkOPs JSS(reserve_inc_xrp); // out: NetworkOPs +JSS(reserve_inc_native); // out: NetworkOPs JSS(response); // websocket JSS(result); // RPC JSS(ripple_lines); // out: NetworkOPs diff --git a/src/test/app/Freeze_test.cpp b/src/test/app/Freeze_test.cpp index 7d4bd57eb..7be1f2569 100644 --- a/src/test/app/Freeze_test.cpp +++ b/src/test/app/Freeze_test.cpp @@ -269,7 +269,7 @@ class Freeze_test : public beast::unit_test::suite auto offers = env.rpc( "book_offers", std::string("USD/") + G1.human(), - "XRP")[jss::result][jss::offers]; + "XAH")[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; std::set accounts; @@ -283,7 +283,7 @@ class Freeze_test : public beast::unit_test::suite // test: visible offers where taker_gets is unfrozen issuer offers = env.rpc( "book_offers", - "XRP", + "XAH", std::string("USD/") + G1.human())[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; @@ -344,7 +344,7 @@ class Freeze_test : public beast::unit_test::suite // (should these actually be filtered?) offers = env.rpc( "book_offers", - "XRP", + "XAH", std::string("USD/") + G1.human())[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; @@ -352,7 +352,7 @@ class Freeze_test : public beast::unit_test::suite offers = env.rpc( "book_offers", std::string("USD/") + G1.human(), - "XRP")[jss::result][jss::offers]; + "XAH")[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; } diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index 2632b7425..a7350f529 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -1930,7 +1930,7 @@ public: env(offer(dan, XRP(500), EUR(50))); Json::Value jtp{Json::arrayValue}; - jtp[0u][0u][jss::currency] = "XRP"; + jtp[0u][0u][jss::currency] = "XAH"; env(pay(alice, bob, EUR(30)), json(jss::Paths, jtp), sendmax(USD(333))); auto jrr = ledgerEntryState(env, alice, gw1, "USD"); diff --git a/src/test/basics/StringUtilities_test.cpp b/src/test/basics/StringUtilities_test.cpp index 6146a3dcd..29808a712 100644 --- a/src/test/basics/StringUtilities_test.cpp +++ b/src/test/basics/StringUtilities_test.cpp @@ -58,7 +58,7 @@ public: // Check for things which contain some or only invalid characters testUnHexFailure("123X"); testUnHexFailure("V"); - testUnHexFailure("XRP"); + testUnHexFailure("XAH"); } void diff --git a/src/test/protocol/STAmount_test.cpp b/src/test/protocol/STAmount_test.cpp index bd3e96694..5dddd3e01 100644 --- a/src/test/protocol/STAmount_test.cpp +++ b/src/test/protocol/STAmount_test.cpp @@ -298,7 +298,7 @@ public: unexpected(STAmount().getText() != "0", "STAmount fail"); unexpected(STAmount(31).getText() != "31", "STAmount fail"); unexpected(STAmount(310).getText() != "310", "STAmount fail"); - unexpected(to_string(Currency()) != "XRP", "cHC(XRP)"); + unexpected(to_string(Currency()) != "XAH", "cHC(XAH)"); Currency c; unexpected(!to_currency(c, "USD"), "create USD currency"); unexpected(to_string(c) != "USD", "check USD currency"); diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index d930cd571..dc6a57723 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -67,7 +67,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -152,7 +152,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -237,7 +237,7 @@ public: auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; j[jss::both] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -334,7 +334,7 @@ public: auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; j[jss::both] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -437,7 +437,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -562,7 +562,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -687,7 +687,7 @@ public: auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; j[jss::both] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -834,7 +834,7 @@ public: auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; j[jss::both] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = Account("alice").human(); } @@ -992,7 +992,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = true; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = gw.human(); } @@ -1026,7 +1026,7 @@ public: Json::Value jvParams; jvParams[jss::taker] = env.master.human(); - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::ledger_index] = "validated"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); @@ -1201,7 +1201,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = false; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = gw.human(); } @@ -1277,7 +1277,7 @@ public: { auto& j = books[jss::books].append(Json::objectValue); j[jss::snapshot] = false; - j[jss::taker_gets][jss::currency] = "XRP"; + j[jss::taker_gets][jss::currency] = "XAH"; j[jss::taker_pays][jss::currency] = "USD"; j[jss::taker_pays][jss::issuer] = gw.human(); } @@ -1287,7 +1287,7 @@ public: j[jss::snapshot] = false; j[jss::taker_gets][jss::currency] = "EUR"; j[jss::taker_gets][jss::issuer] = gw.human(); - j[jss::taker_pays][jss::currency] = "XRP"; + j[jss::taker_pays][jss::currency] = "XAH"; } auto jv = wsc->invoke("subscribe", books); @@ -1403,7 +1403,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets] = Json::objectValue; auto const jrr = env.rpc( "json", "book_offers", to_string(jvParams))[jss::result]; @@ -1416,7 +1416,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = 1; auto const jrr = env.rpc( "json", "book_offers", to_string(jvParams))[jss::result]; @@ -1430,7 +1430,7 @@ public: Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; jvParams[jss::taker_pays][jss::currency] = "NOT_VALID"; - jvParams[jss::taker_gets][jss::currency] = "XRP"; + jvParams[jss::taker_gets][jss::currency] = "XAH"; auto const jrr = env.rpc( "json", "book_offers", to_string(jvParams))[jss::result]; BEAST_EXPECT(jrr[jss::error] == "srcCurMalformed"); @@ -1442,7 +1442,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "NOT_VALID"; auto const jrr = env.rpc( "json", "book_offers", to_string(jvParams))[jss::result]; @@ -1455,7 +1455,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = 1; auto const jrr = env.rpc( @@ -1469,7 +1469,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_pays][jss::issuer] = 1; jvParams[jss::taker_gets][jss::currency] = "USD"; auto const jrr = env.rpc( @@ -1483,7 +1483,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_pays][jss::issuer] = gw.human() + "DEAD"; jvParams[jss::taker_gets][jss::currency] = "USD"; auto const jrr = env.rpc( @@ -1497,7 +1497,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_pays][jss::issuer] = toBase58(noAccount()); jvParams[jss::taker_gets][jss::currency] = "USD"; auto const jrr = env.rpc( @@ -1511,7 +1511,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human() + "DEAD"; auto const jrr = env.rpc( @@ -1525,7 +1525,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = toBase58(noAccount()); auto const jrr = env.rpc( @@ -1539,7 +1539,7 @@ public: { Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_pays][jss::issuer] = alice.human(); jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); @@ -1571,7 +1571,7 @@ public: Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; jvParams[jss::taker] = 1; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); auto const jrr = env.rpc( @@ -1586,7 +1586,7 @@ public: Json::Value jvParams; jvParams[jss::ledger_index] = "validated"; jvParams[jss::taker] = env.master.human() + "DEAD"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); auto const jrr = env.rpc( @@ -1614,7 +1614,7 @@ public: jvParams[jss::ledger_index] = "validated"; jvParams[jss::taker] = env.master.human(); jvParams[jss::limit] = "0"; // NOT an integer - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); auto const jrr = env.rpc( @@ -1645,7 +1645,7 @@ public: jvParams[jss::ledger_index] = "validated"; jvParams[jss::taker_pays][jss::currency] = "USD"; jvParams[jss::taker_pays][jss::issuer] = gw.human(); - jvParams[jss::taker_gets][jss::currency] = "XRP"; + jvParams[jss::taker_gets][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); auto const jrr = env.rpc( "json", "book_offers", to_string(jvParams))[jss::result]; @@ -1680,7 +1680,7 @@ public: Json::Value jvParams; jvParams[jss::limit] = 1; jvParams[jss::ledger_index] = "validated"; - jvParams[jss::taker_pays][jss::currency] = "XRP"; + jvParams[jss::taker_pays][jss::currency] = "XAH"; jvParams[jss::taker_gets][jss::currency] = "USD"; jvParams[jss::taker_gets][jss::issuer] = gw.human(); auto jrr =