From 13acc00c9534dabea1637d6b2ee8a1e36d2b9233 Mon Sep 17 00:00:00 2001 From: RichardAH Date: Fri, 18 Aug 2023 03:43:47 +0200 Subject: [PATCH] feat: support Concise Transaction Identifier (CTID) (XLS-37) (#4418) * add CTIM to tx rpc --------- Co-authored-by: Rome Reginelli Co-authored-by: Elliot Lee Co-authored-by: Denis Angell --- src/ripple/rpc/handlers/Tx.cpp | 3 +++ src/ripple/rpc/impl/RPCHelpers.cpp | 1 + src/test/app/NetworkID_test.cpp | 6 ------ src/test/rpc/Transaction_test.cpp | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ripple/rpc/handlers/Tx.cpp b/src/ripple/rpc/handlers/Tx.cpp index d4bdf9a57..02f733d0d 100644 --- a/src/ripple/rpc/handlers/Tx.cpp +++ b/src/ripple/rpc/handlers/Tx.cpp @@ -217,6 +217,9 @@ doTxHelp(RPC::Context& context, TxArgs args) ClosedInterval(args.ctid->first, args.ctid->second); } + if (!args.hash) + return {result, rpcTXN_NOT_FOUND}; + if (args.ledgerRange) { v = context.app.getMasterTransaction().fetch(*(args.hash), range, ec); diff --git a/src/ripple/rpc/impl/RPCHelpers.cpp b/src/ripple/rpc/impl/RPCHelpers.cpp index 75771abcd..76c093308 100644 --- a/src/ripple/rpc/impl/RPCHelpers.cpp +++ b/src/ripple/rpc/impl/RPCHelpers.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/src/test/app/NetworkID_test.cpp b/src/test/app/NetworkID_test.cpp index 51c4595da..5dbbff0c5 100644 --- a/src/test/app/NetworkID_test.cpp +++ b/src/test/app/NetworkID_test.cpp @@ -68,14 +68,9 @@ public: jv[jss::Destination] = alice.human(); jv[jss::TransactionType] = "Payment"; jv[jss::Amount] = "10000000000"; - if (env.app().config().NETWORK_ID > 1024) - jv[jss::NetworkID] = - std::to_string(env.app().config().NETWORK_ID); - env(jv, fee(1000), sig(env.master)); } - // run tx env(jv, fee(1000), ter(expectedOutcome)); env.close(); }; @@ -127,7 +122,6 @@ public: { test::jtx::Env env{*this, makeNetworkConfig(1025)}; BEAST_EXPECT(env.app().config().NETWORK_ID == 1025); - // try to submit a txn without network id, this should not work { env.fund(XRP(200), alice); diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index b930ad566..a77bef81b 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -367,7 +367,7 @@ class Transaction_test : public beast::unit_test::suite if (deltaEndSeq) BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool()); else - BEAST_EXPECT(result[jss::result][jss::searched_all].asBool()); + BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool()); } // Find transactions outside of provided range. @@ -435,7 +435,7 @@ class Transaction_test : public beast::unit_test::suite result[jss::result][jss::status] == jss::error && result[jss::result][jss::error] == NOT_FOUND); - BEAST_EXPECT(result[jss::result][jss::searched_all].asBool()); + BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool()); } // Provide range without providing the `binary`