mirror of
https://github.com/XRPLF/rippled.git
synced 2026-01-31 03:55:27 +00:00
Compare commits
6 Commits
mvadari/fi
...
copilot/ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fac09ccc3 | ||
|
|
d18a9e2e54 | ||
|
|
a7abee3c7b | ||
|
|
0affb48188 | ||
|
|
c0f1a1f094 | ||
|
|
72bf625bfe |
@@ -83,15 +83,15 @@ The [commandline](https://xrpl.org/docs/references/http-websocket-apis/api-conve
|
||||
|
||||
The `network_id` field was added in the `server_info` response in version 1.5.0 (2019), but it is not returned in [reporting mode](https://xrpl.org/rippled-server-modes.html#reporting-mode). However, use of reporting mode is now discouraged, in favor of using [Clio](https://github.com/XRPLF/clio) instead.
|
||||
|
||||
## Unreleased
|
||||
## Unreleased Changes
|
||||
|
||||
### Additions and bugfixes
|
||||
|
||||
- `book_offers`: the `proof` parameter is removed from both the RPC and CLI versions. It did not do anything.
|
||||
- `submit`: Augmented response fields (`accepted`, `applied`, `broadcast`, `queued`, `kept`, `account_sequence_next`, `account_sequence_available`, `open_ledger_cost`, `validated_ledger_index`) are now included in sign-and-submit mode. Previously, these fields were only returned when submitting a binary transaction blob. ([#6304](https://github.com/XRPLF/rippled/pull/6304))
|
||||
|
||||
## XRP Ledger server version 2.5.0
|
||||
|
||||
[Version 2.5.0](https://github.com/XRPLF/rippled/releases/tag/2.5.0) was released on June 24, 2025.
|
||||
As of 2025-04-04, version 2.5.0 is in development. You can use a pre-release version by building from source or [using the `nightly` package](https://xrpl.org/docs/infrastructure/installation/install-rippled-on-ubuntu).
|
||||
|
||||
### Additions and bugfixes in 2.5.0
|
||||
|
||||
|
||||
@@ -484,6 +484,7 @@ JSS(ports); // out: NetworkOPs
|
||||
JSS(previous); // out: Reservations
|
||||
JSS(previous_ledger); // out: LedgerPropose
|
||||
JSS(price); // out: amm_info, AuctionSlot
|
||||
JSS(proof); // in: BookOffers
|
||||
JSS(propose_seq); // out: LedgerPropose
|
||||
JSS(proposers); // out: NetworkOPs, LedgerConsensus
|
||||
JSS(protocol); // out: NetworkOPs, PeerImp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
96
src/test/rpc/Submit_test.cpp
Normal file
96
src/test/rpc/Submit_test.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include <test/jtx.h>
|
||||
|
||||
#include <xrpld/core/ConfigSections.h>
|
||||
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class Submit_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
testAugmentedFields()
|
||||
{
|
||||
testcase("Augmented fields in sign-and-submit mode");
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
// Enable signing support in config
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->loadFromString("[" SECTION_SIGNING_SUPPORT "]\ntrue");
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
|
||||
env.fund(XRP(10000), alice, bob);
|
||||
env.close();
|
||||
|
||||
// Test 1: Sign-and-submit mode should return augmented fields
|
||||
{
|
||||
Json::Value jv;
|
||||
jv[jss::tx_json][jss::TransactionType] = jss::Payment;
|
||||
jv[jss::tx_json][jss::Account] = alice.human();
|
||||
jv[jss::tx_json][jss::Destination] = bob.human();
|
||||
jv[jss::tx_json][jss::Amount] = XRP(100).value().getJson(JsonOptions::none);
|
||||
jv[jss::secret] = alice.name();
|
||||
|
||||
auto const result = env.rpc("json", "submit", to_string(jv))[jss::result];
|
||||
|
||||
// These are the augmented fields that should be present
|
||||
BEAST_EXPECT(result.isMember(jss::engine_result));
|
||||
BEAST_EXPECT(result.isMember(jss::engine_result_code));
|
||||
BEAST_EXPECT(result.isMember(jss::engine_result_message));
|
||||
|
||||
// New augmented fields from issue #3125
|
||||
BEAST_EXPECT(result.isMember(jss::accepted));
|
||||
BEAST_EXPECT(result.isMember(jss::applied));
|
||||
BEAST_EXPECT(result.isMember(jss::broadcast));
|
||||
BEAST_EXPECT(result.isMember(jss::queued));
|
||||
BEAST_EXPECT(result.isMember(jss::kept));
|
||||
|
||||
// Current ledger state fields
|
||||
BEAST_EXPECT(result.isMember(jss::account_sequence_next));
|
||||
BEAST_EXPECT(result.isMember(jss::account_sequence_available));
|
||||
BEAST_EXPECT(result.isMember(jss::open_ledger_cost));
|
||||
BEAST_EXPECT(result.isMember(jss::validated_ledger_index));
|
||||
|
||||
// Verify basic transaction fields
|
||||
BEAST_EXPECT(result.isMember(jss::tx_blob));
|
||||
BEAST_EXPECT(result.isMember(jss::tx_json));
|
||||
}
|
||||
|
||||
// Test 2: Binary blob mode should also return augmented fields (regression test)
|
||||
{
|
||||
auto jt = env.jt(pay(alice, bob, XRP(100)));
|
||||
Serializer s;
|
||||
jt.stx->add(s);
|
||||
|
||||
auto const result = env.rpc("submit", strHex(s.slice()))[jss::result];
|
||||
|
||||
// Verify augmented fields are present in binary mode too
|
||||
BEAST_EXPECT(result.isMember(jss::engine_result));
|
||||
BEAST_EXPECT(result.isMember(jss::accepted));
|
||||
BEAST_EXPECT(result.isMember(jss::applied));
|
||||
BEAST_EXPECT(result.isMember(jss::broadcast));
|
||||
BEAST_EXPECT(result.isMember(jss::queued));
|
||||
BEAST_EXPECT(result.isMember(jss::kept));
|
||||
BEAST_EXPECT(result.isMember(jss::account_sequence_next));
|
||||
BEAST_EXPECT(result.isMember(jss::account_sequence_available));
|
||||
BEAST_EXPECT(result.isMember(jss::open_ledger_cost));
|
||||
BEAST_EXPECT(result.isMember(jss::validated_ledger_index));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testAugmentedFields();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Submit, rpc, xrpl);
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -330,6 +330,7 @@ public:
|
||||
std::shared_ptr<ReadView const>& lpLedger,
|
||||
Book const&,
|
||||
AccountID const& uTakerID,
|
||||
bool const bProof,
|
||||
unsigned int iLimit,
|
||||
Json::Value const& jvMarker,
|
||||
Json::Value& jvResult) override;
|
||||
@@ -4031,6 +4032,7 @@ NetworkOPsImp::getBookPage(
|
||||
std::shared_ptr<ReadView const>& lpLedger,
|
||||
Book const& book,
|
||||
AccountID const& uTakerID,
|
||||
bool const bProof,
|
||||
unsigned int iLimit,
|
||||
Json::Value const& jvMarker,
|
||||
Json::Value& jvResult)
|
||||
@@ -4223,6 +4225,7 @@ NetworkOPsImp::getBookPage(
|
||||
std::shared_ptr<ReadView const> lpLedger,
|
||||
Book const& book,
|
||||
AccountID const& uTakerID,
|
||||
bool const bProof,
|
||||
unsigned int iLimit,
|
||||
Json::Value const& jvMarker,
|
||||
Json::Value& jvResult)
|
||||
|
||||
@@ -144,6 +144,7 @@ public:
|
||||
std::shared_ptr<ReadView const>& lpLedger,
|
||||
Book const& book,
|
||||
AccountID const& uTakerID,
|
||||
bool const bProof,
|
||||
unsigned int iLimit,
|
||||
Json::Value const& jvMarker,
|
||||
Json::Value& jvResult) = 0;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <xrpl/protocol/PublicKey.h>
|
||||
#include <xrpl/protocol/RPCErr.h>
|
||||
#include <xrpl/protocol/SystemParameters.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@@ -24,7 +25,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -129,41 +130,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static std::optional<std::int32_t>
|
||||
jvParseInt(Json::Value const& param)
|
||||
{
|
||||
if (param.isInt())
|
||||
return param.asInt();
|
||||
|
||||
if (param.isUInt() && param.asUInt() <= std::numeric_limits<std::int32_t>::max())
|
||||
return param.asInt();
|
||||
|
||||
if (param.isString())
|
||||
{
|
||||
std::int32_t v;
|
||||
if (beast::lexicalCastChecked(v, param.asString()))
|
||||
return v;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static std::optional<std::uint32_t>
|
||||
jvParseUInt(Json::Value const& param)
|
||||
{
|
||||
if (param.isUInt() || (param.isInt() && param.asInt() >= 0))
|
||||
return param.asUInt();
|
||||
|
||||
if (param.isString())
|
||||
{
|
||||
std::uint32_t v;
|
||||
if (beast::lexicalCastChecked(v, param.asString()))
|
||||
return v;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static bool
|
||||
validPublicKey(std::string const& strPk, TokenType type = TokenType::AccountPublic)
|
||||
{
|
||||
@@ -292,54 +258,24 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::int32_t ledgerMin = 0, ledgerMax = 0; // note: these are only used when properly set
|
||||
if (auto const ledgerMinOpt = jvParseInt(jvParams[1u]))
|
||||
{
|
||||
// A value of -1 instructs the server to use the most recent
|
||||
// validated ledger version available
|
||||
ledgerMin = *ledgerMinOpt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return rpcError(rpcINVALID_LGR_RANGE);
|
||||
}
|
||||
std::int64_t uLedgerMin = jvParams[1u].asInt();
|
||||
std::int64_t uLedgerMax = jvParams[2u].asInt();
|
||||
|
||||
if (auto const ledgerMaxOpt = jvParseInt(jvParams[2u]))
|
||||
{
|
||||
ledgerMax = *ledgerMaxOpt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return rpcError(rpcINVALID_LGR_RANGE);
|
||||
}
|
||||
|
||||
// `-1` means "most recent validated ledger version available"
|
||||
static std::int32_t const USE_MOST_RECENT_LEDGER = -1;
|
||||
if (ledgerMax != USE_MOST_RECENT_LEDGER && ledgerMax < ledgerMin)
|
||||
if (uLedgerMax != -1 && uLedgerMax < uLedgerMin)
|
||||
{
|
||||
if (apiVersion_ == 1)
|
||||
return rpcError(rpcLGR_IDXS_INVALID);
|
||||
return rpcError(rpcNOT_SYNCED);
|
||||
}
|
||||
|
||||
jvRequest[jss::ledger_index_min] = ledgerMin;
|
||||
jvRequest[jss::ledger_index_max] = ledgerMax;
|
||||
jvRequest[jss::ledger_index_min] = jvParams[1u].asInt();
|
||||
jvRequest[jss::ledger_index_max] = jvParams[2u].asInt();
|
||||
|
||||
if (iParams >= 4)
|
||||
{
|
||||
if (auto const limit = jvParseUInt(jvParams[3u]))
|
||||
jvRequest[jss::limit] = *limit;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::limit);
|
||||
}
|
||||
jvRequest[jss::limit] = jvParams[3u].asInt();
|
||||
|
||||
if (iParams >= 5)
|
||||
{
|
||||
if (auto const offset = jvParseInt(jvParams[4u]))
|
||||
jvRequest[jss::offset] = *offset;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::offset);
|
||||
}
|
||||
jvRequest[jss::offset] = jvParams[4u].asInt();
|
||||
}
|
||||
|
||||
return jvRequest;
|
||||
@@ -385,16 +321,35 @@ private:
|
||||
|
||||
if (jvParams.size() >= 5)
|
||||
{
|
||||
if (auto const limit = jvParseUInt(jvParams[4u]))
|
||||
try
|
||||
{
|
||||
jvRequest[jss::limit] = *limit;
|
||||
int iLimit = jvParams[4u].asInt();
|
||||
|
||||
if (iLimit > 0)
|
||||
jvRequest[jss::limit] = iLimit;
|
||||
}
|
||||
else
|
||||
catch (std::exception const&)
|
||||
{
|
||||
return RPC::invalid_field_error(jss::limit);
|
||||
}
|
||||
}
|
||||
|
||||
if (jvParams.size() == 6)
|
||||
jvRequest[jss::marker] = jvParams[5u];
|
||||
if (jvParams.size() >= 6)
|
||||
{
|
||||
try
|
||||
{
|
||||
int bProof = jvParams[5u].asInt();
|
||||
if (bProof)
|
||||
jvRequest[jss::proof] = true;
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
return RPC::invalid_field_error(jss::proof);
|
||||
}
|
||||
}
|
||||
|
||||
if (jvParams.size() == 7)
|
||||
jvRequest[jss::marker] = jvParams[6u];
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
@@ -410,12 +365,7 @@ private:
|
||||
|
||||
std::string input = jvParams[0u].asString();
|
||||
if (input.find_first_not_of("0123456789") == std::string::npos)
|
||||
{
|
||||
if (auto const seq = jvParseUInt(jvParams[0u]))
|
||||
jvRequest["can_delete"] = *seq;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::can_delete);
|
||||
}
|
||||
jvRequest["can_delete"] = jvParams[0u].asUInt();
|
||||
else
|
||||
jvRequest["can_delete"] = input;
|
||||
|
||||
@@ -431,10 +381,7 @@ private:
|
||||
if (jvParams.size() == 2)
|
||||
{
|
||||
jvRequest[jss::ip] = ip;
|
||||
if (auto const port = jvParseUInt(jvParams[1u]))
|
||||
jvRequest[jss::port] = *port;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::port);
|
||||
jvRequest[jss::port] = jvParams[1u].asUInt();
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
@@ -443,12 +390,7 @@ private:
|
||||
{
|
||||
std::size_t colon = ip.find_last_of(":");
|
||||
jvRequest[jss::ip] = std::string{ip, 0, colon};
|
||||
|
||||
if (auto const port = jvParseUInt(std::string{ip, colon + 1}))
|
||||
jvRequest[jss::port] = *port;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::port);
|
||||
|
||||
jvRequest[jss::port] = Json::Value{std::string{ip, colon + 1}}.asUInt();
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
@@ -521,12 +463,7 @@ private:
|
||||
Json::Value jvRequest(Json::objectValue);
|
||||
|
||||
if (jvParams.size())
|
||||
{
|
||||
if (auto const minCount = jvParseUInt(jvParams[0u]))
|
||||
jvRequest[jss::min_count] = *minCount;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::min_count);
|
||||
}
|
||||
jvRequest[jss::min_count] = jvParams[0u].asUInt();
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
@@ -1125,10 +1062,7 @@ private:
|
||||
{
|
||||
Json::Value jvRequest{Json::objectValue};
|
||||
|
||||
if (auto const start = jvParseUInt(jvParams[0u]))
|
||||
jvRequest[jss::start] = *start;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::start);
|
||||
jvRequest[jss::start] = jvParams[0u].asUInt();
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
@@ -1272,7 +1206,7 @@ public:
|
||||
{"amm_info", &RPCParser::parseAsIs, 1, 2},
|
||||
{"vault_info", &RPCParser::parseVault, 1, 2},
|
||||
{"book_changes", &RPCParser::parseLedgerId, 1, 1},
|
||||
{"book_offers", &RPCParser::parseBookOffers, 2, 6},
|
||||
{"book_offers", &RPCParser::parseBookOffers, 2, 7},
|
||||
{"can_delete", &RPCParser::parseCanDelete, 0, 1},
|
||||
{"channel_authorize", &RPCParser::parseChannelAuthorize, 3, 4},
|
||||
{"channel_verify", &RPCParser::parseChannelVerify, 4, 4},
|
||||
|
||||
@@ -699,6 +699,8 @@ transactionFormatResultImpl(Transaction::pointer tpTrans, unsigned apiVersion)
|
||||
jvResult[jss::engine_result] = sToken;
|
||||
jvResult[jss::engine_result_code] = tpTrans->getResult();
|
||||
jvResult[jss::engine_result_message] = sHuman;
|
||||
|
||||
RPC::populateAugmentedSubmitFields(jvResult, tpTrans);
|
||||
}
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -712,6 +714,28 @@ transactionFormatResultImpl(Transaction::pointer tpTrans, unsigned apiVersion)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
populateAugmentedSubmitFields(Json::Value& jvResult, std::shared_ptr<Transaction> const& transaction)
|
||||
{
|
||||
auto const submitResult = transaction->getSubmitResult();
|
||||
|
||||
jvResult[jss::accepted] = submitResult.any();
|
||||
jvResult[jss::applied] = submitResult.applied;
|
||||
jvResult[jss::broadcast] = submitResult.broadcast;
|
||||
jvResult[jss::queued] = submitResult.queued;
|
||||
jvResult[jss::kept] = submitResult.kept;
|
||||
|
||||
if (auto currentLedgerState = transaction->getCurrentLedgerState())
|
||||
{
|
||||
jvResult[jss::account_sequence_next] = safe_cast<Json::Value::UInt>(currentLedgerState->accountSeqNext);
|
||||
jvResult[jss::account_sequence_available] = safe_cast<Json::Value::UInt>(currentLedgerState->accountSeqAvail);
|
||||
jvResult[jss::open_ledger_cost] = to_string(currentLedgerState->minFeeRequired);
|
||||
jvResult[jss::validated_ledger_index] = safe_cast<Json::Value::UInt>(currentLedgerState->validatedLedger);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
[[nodiscard]] static XRPAmount
|
||||
getTxFee(Application const& app, Config const& config, Json::Value tx)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,18 @@ class TxQ;
|
||||
|
||||
namespace RPC {
|
||||
|
||||
/** Populate augmented submit fields into a JSON result.
|
||||
This helper populates the submit result flags (accepted, applied,
|
||||
broadcast, queued, kept) and current ledger state fields
|
||||
(account_sequence_next, account_sequence_available, open_ledger_cost,
|
||||
validated_ledger_index) from a Transaction pointer.
|
||||
|
||||
@param jvResult The JSON result to populate
|
||||
@param transaction The transaction containing the submit result and state
|
||||
*/
|
||||
void
|
||||
populateAugmentedSubmitFields(Json::Value& jvResult, std::shared_ptr<Transaction> const& transaction);
|
||||
|
||||
Json::Value
|
||||
getCurrentNetworkFee(
|
||||
Role const role,
|
||||
|
||||
@@ -162,6 +162,8 @@ doBookOffers(RPC::JsonContext& context)
|
||||
if (auto err = readLimitField(limit, RPC::Tuning::bookOffers, context))
|
||||
return *err;
|
||||
|
||||
bool const bProof(context.params.isMember(jss::proof));
|
||||
|
||||
Json::Value const jvMarker(
|
||||
context.params.isMember(jss::marker) ? context.params[jss::marker] : Json::Value(Json::nullValue));
|
||||
|
||||
@@ -169,6 +171,7 @@ doBookOffers(RPC::JsonContext& context)
|
||||
lpLedger,
|
||||
{{pay_currency, pay_issuer}, {get_currency, get_issuer}, domain},
|
||||
takerID ? *takerID : beast::zero,
|
||||
bProof,
|
||||
limit,
|
||||
jvMarker,
|
||||
jvResult);
|
||||
|
||||
@@ -127,23 +127,7 @@ doSubmit(RPC::JsonContext& context)
|
||||
jvResult[jss::engine_result_code] = transaction->getResult();
|
||||
jvResult[jss::engine_result_message] = sHuman;
|
||||
|
||||
auto const submitResult = transaction->getSubmitResult();
|
||||
|
||||
jvResult[jss::accepted] = submitResult.any();
|
||||
jvResult[jss::applied] = submitResult.applied;
|
||||
jvResult[jss::broadcast] = submitResult.broadcast;
|
||||
jvResult[jss::queued] = submitResult.queued;
|
||||
jvResult[jss::kept] = submitResult.kept;
|
||||
|
||||
if (auto currentLedgerState = transaction->getCurrentLedgerState())
|
||||
{
|
||||
jvResult[jss::account_sequence_next] = safe_cast<Json::Value::UInt>(currentLedgerState->accountSeqNext);
|
||||
jvResult[jss::account_sequence_available] =
|
||||
safe_cast<Json::Value::UInt>(currentLedgerState->accountSeqAvail);
|
||||
jvResult[jss::open_ledger_cost] = to_string(currentLedgerState->minFeeRequired);
|
||||
jvResult[jss::validated_ledger_index] =
|
||||
safe_cast<Json::Value::UInt>(currentLedgerState->validatedLedger);
|
||||
}
|
||||
RPC::populateAugmentedSubmitFields(jvResult, transaction);
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
|
||||
@@ -312,6 +312,7 @@ doSubscribe(RPC::JsonContext& context)
|
||||
lpLedger,
|
||||
field == jss::asks ? reversed(book) : book,
|
||||
takerID ? *takerID : noAccount(),
|
||||
false,
|
||||
RPC::Tuning::bookOffers.rDefault,
|
||||
jvMarker,
|
||||
jvOffers);
|
||||
|
||||
Reference in New Issue
Block a user