diff --git a/.github/scripts/rename/copyright.sh b/.github/scripts/rename/copyright.sh index c5a9fb2cd3..3d690321b9 100755 --- a/.github/scripts/rename/copyright.sh +++ b/.github/scripts/rename/copyright.sh @@ -76,11 +76,11 @@ fi if ! grep -q 'Dev Null' src/test/rpc/ValidatorInfo_test.cpp; then echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/rpc/ValidatorInfo_test.cpp)" > src/test/rpc/ValidatorInfo_test.cpp fi -if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/DoManifest.cpp; then - echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/DoManifest.cpp)" > src/xrpld/rpc/handlers/DoManifest.cpp +if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/server_info/Manifest.cpp; then + echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/server_info/Manifest.cpp)" > src/xrpld/rpc/handlers/server_info/Manifest.cpp fi -if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/ValidatorInfo.cpp; then - echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/ValidatorInfo.cpp)" > src/xrpld/rpc/handlers/ValidatorInfo.cpp +if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp; then + echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp)" > src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp fi if ! grep -q 'Bougalis' include/xrpl/basics/SlabAllocator.h; then echo -e "// Copyright (c) 2022, Nikolaos D. Bougalis \n\n$(cat include/xrpl/basics/SlabAllocator.h)" > include/xrpl/basics/SlabAllocator.h # cspell: ignore Nikolaos Bougalis nikb diff --git a/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp b/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp index 627d3b7d3f..1faaeab805 100644 --- a/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp +++ b/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp @@ -143,7 +143,7 @@ public: Serializer msg; msg.add64(v); - auto const data = msg.getData(); + auto data = msg.getData(); #ifdef DEBUG_OUTPUT std::cout << "m: " << std::setw(20) << mantissa() << ", e: " << std::setw(12) << exponent() diff --git a/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp b/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp index 67542ac559..46744c17a7 100644 --- a/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp +++ b/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp @@ -14,7 +14,7 @@ getIntBytes(STBase const* obj) { static_assert(std::is_integral::value, "Only integral types"); - auto const& num(static_cast const*>(obj)); + auto const& num(static_cast const*>(obj)); // NOLINT T const data = adjustWasmEndianess(num->value()); auto const* b = reinterpret_cast(&data); auto const* e = reinterpret_cast(&data + 1); @@ -42,13 +42,13 @@ getAnyFieldData(STBase const* obj) return Unexpected(HostFunctionError::NOT_LEAF_FIELD); case STI_ACCOUNT: { - auto const* account(dynamic_cast(obj)); + auto const* account(static_cast(obj)); // NOLINT auto const& data = account->value(); return Bytes{data.begin(), data.end()}; } case STI_ISSUE: { - auto const* issue(dynamic_cast(obj)); + auto const* issue(static_cast(obj)); // NOLINT Asset const& asset(issue->value()); // XRP and IOU will be processed by serializer if (asset.holds()) @@ -61,7 +61,7 @@ getAnyFieldData(STBase const* obj) } case STI_VL: { - auto const* vl(dynamic_cast(obj)); + auto const* vl(static_cast(obj)); // NOLINT auto const& data = vl->value(); return Bytes{data.begin(), data.end()}; } @@ -84,7 +84,7 @@ getAnyFieldData(STBase const* obj) // LCOV_EXCL_STOP case STI_UINT256: { - auto const* uint256Obj(dynamic_cast(obj)); + auto const* uint256Obj(static_cast(obj)); // NOLINT auto const& data = uint256Obj->value(); return Bytes{data.begin(), data.end()}; } @@ -165,14 +165,14 @@ locateField(STObject const& obj, Slice const& locator) if (STI_ARRAY == field->getSType()) { - auto const* arr = dynamic_cast(field); + auto const* arr = static_cast(field); // NOLINT if (sfieldCode < 0 || std::cmp_greater_equal(sfieldCode, arr->size())) return Unexpected(HostFunctionError::INDEX_OUT_OF_BOUNDS); field = &(arr->operator[](sfieldCode)); } else if (STI_OBJECT == field->getSType()) { - auto const* o = dynamic_cast(field); + auto const* o = static_cast(field); // NOLINT auto const it = knownSFields.find(sfieldCode); if (it == knownSFields.end()) @@ -183,7 +183,7 @@ locateField(STObject const& obj, Slice const& locator) } else if (STI_VECTOR256 == field->getSType()) { - auto const* v = dynamic_cast(field); + auto const* v = static_cast(field); // NOLINT if (sfieldCode < 0 || std::cmp_greater_equal(sfieldCode, v->size())) return Unexpected(HostFunctionError::INDEX_OUT_OF_BOUNDS); return FieldValue(&(v->operator[](sfieldCode))); @@ -206,9 +206,9 @@ getArrayLen(FieldValue const& variantField) if (STBase const* const* field = std::get_if(&variantField)) { if ((*field)->getSType() == STI_VECTOR256) - return dynamic_cast(*field)->size(); + return static_cast(*field)->size(); // NOLINT if ((*field)->getSType() == STI_ARRAY) - return dynamic_cast(*field)->size(); + return static_cast(*field)->size(); // NOLINT } // uint256 is not an array so that variant should still return NO_ARRAY diff --git a/src/libxrpl/tx/wasm/HostFuncWrapper.cpp b/src/libxrpl/tx/wasm/HostFuncWrapper.cpp index 88598469e0..e420565727 100644 --- a/src/libxrpl/tx/wasm/HostFuncWrapper.cpp +++ b/src/libxrpl/tx/wasm/HostFuncWrapper.cpp @@ -328,7 +328,7 @@ static inline HostFunctions* getHF(void* env) { auto const* udata = reinterpret_cast(env); - HostFunctions const* hf = reinterpret_cast(udata->first); + HostFunctions* hf = reinterpret_cast(udata->first); // NOLINT return hf; } @@ -341,7 +341,7 @@ checkGas(void* env) auto const* runtime = reinterpret_cast(hf->getRT()); if (runtime == nullptr) { - wasm_trap_t const* trap = reinterpret_cast( + wasm_trap_t* trap = reinterpret_cast( // NOLINT WasmEngine::instance().newTrap("hf no runtime")); // LCOV_EXCL_LINE return Unexpected(trap); // LCOV_EXCL_LINE } @@ -352,14 +352,14 @@ checkGas(void* env) if (runtime->setGas(x) < 0) { - wasm_trap_t const* trap = reinterpret_cast( + wasm_trap_t* trap = reinterpret_cast( // NOLINT WasmEngine::instance().newTrap("can't set gas")); // LCOV_EXCL_LINE return Unexpected(trap); // LCOV_EXCL_LINE } if (gas < impFunc.gas) { - wasm_trap_t const* trap = + wasm_trap_t* const trap = // NOLINT reinterpret_cast(WasmEngine::instance().newTrap("hf out of gas")); return Unexpected(trap); } diff --git a/src/libxrpl/tx/wasm/WasmiVM.cpp b/src/libxrpl/tx/wasm/WasmiVM.cpp index 622311540a..e624d1540d 100644 --- a/src/libxrpl/tx/wasm/WasmiVM.cpp +++ b/src/libxrpl/tx/wasm/WasmiVM.cpp @@ -918,7 +918,7 @@ WasmiEngine::newTrap(std::string const& txt) if (!txt.empty()) wasm_name_new(&msg, txt.size() + 1, txt.c_str()); // include 0 - wasm_trap_t const* trap = wasm_trap_new(store_.get(), &msg); + wasm_trap_t* trap = wasm_trap_new(store_.get(), &msg); // NOLINT if (!txt.empty()) wasm_byte_vec_delete(&msg); diff --git a/src/test/app/EscrowSmart_test.cpp b/src/test/app/EscrowSmart_test.cpp index ee8e30f2f3..93f6095028 100644 --- a/src/test/app/EscrowSmart_test.cpp +++ b/src/test/app/EscrowSmart_test.cpp @@ -176,7 +176,7 @@ struct EscrowSmart_test : public beast::unit_test::suite Env env( *this, envconfig([](std::unique_ptr cfg) { - cfg->START_UP = StartUpType::FRESH; + cfg->START_UP = StartUpType::Fresh; return cfg; }), features); @@ -375,7 +375,7 @@ struct EscrowSmart_test : public beast::unit_test::suite // transaction processing This is necessary because the config // cannot be updated in the middle of a test, and we cannot easily // create a Smart Escrow while the compute limit is set to 0 - env.app().openLedger().modify([&](OpenView& view, beast::Journal j) { + env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { auto sle = std::make_shared(keylet); sle->setAccountID(sfAccount, alice.id()); diff --git a/src/test/rpc/KeyGeneration_test.cpp b/src/test/rpc/KeyGeneration_test.cpp index 87d2ded7ad..f11df0dffb 100644 --- a/src/test/rpc/KeyGeneration_test.cpp +++ b/src/test/rpc/KeyGeneration_test.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 2720c10140..9bfd3f6818 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/xrpld/rpc/detail/Handler.cpp b/src/xrpld/rpc/detail/Handler.cpp index 0f95e69d3f..05fc1cb0b4 100644 --- a/src/xrpld/rpc/detail/Handler.cpp +++ b/src/xrpld/rpc/detail/Handler.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -75,7 +75,7 @@ Handler const handlerArray[]{ {"account_nfts", byRef(&doAccountNFTs), Role::USER, NO_CONDITION}, {"account_objects", byRef(&doAccountObjects), Role::USER, NO_CONDITION}, {"account_offers", byRef(&doAccountOffers), Role::USER, NO_CONDITION}, - {"account_tx", byRef(&doAccountTxJson), Role::USER, NO_CONDITION}, + {"account_tx", byRef(&doAccountTx), Role::USER, NO_CONDITION}, {"amm_info", byRef(&doAMMInfo), Role::USER, NO_CONDITION}, {"blacklist", byRef(&doBlackList), Role::ADMIN, NO_CONDITION}, {"book_changes", byRef(&doBookChanges), Role::USER, NO_CONDITION}, diff --git a/src/xrpld/rpc/handlers/ChannelVerify.cpp b/src/xrpld/rpc/handlers/ChannelVerify.cpp new file mode 100644 index 0000000000..91b23db4e6 --- /dev/null +++ b/src/xrpld/rpc/handlers/ChannelVerify.cpp @@ -0,0 +1,71 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace xrpl { + +// { +// public_key: +// channel_id: 256-bit channel id +// drops: 64-bit uint (as string) +// signature: signature to verify +// } +Json::Value +doChannelVerify(RPC::JsonContext& context) +{ + auto const& params(context.params); + for (auto const& p : {jss::public_key, jss::channel_id, jss::amount, jss::signature}) + { + if (!params.isMember(p)) + return RPC::missing_field_error(p); + } + + std::optional pk; + { + std::string const strPk = params[jss::public_key].asString(); + pk = parseBase58(TokenType::AccountPublic, strPk); + + if (!pk) + { + auto pkHex = strUnHex(strPk); + if (!pkHex) + return rpcError(rpcPUBLIC_MALFORMED); + auto const pkType = publicKeyType(makeSlice(*pkHex)); + if (!pkType) + return rpcError(rpcPUBLIC_MALFORMED); + pk.emplace(makeSlice(*pkHex)); + } + } + + uint256 channelId; + if (!channelId.parseHex(params[jss::channel_id].asString())) + return rpcError(rpcCHANNEL_MALFORMED); + + std::optional const optDrops = + params[jss::amount].isString() ? to_uint64(params[jss::amount].asString()) : std::nullopt; + + if (!optDrops) + return rpcError(rpcCHANNEL_AMT_MALFORMED); + + std::uint64_t const drops = *optDrops; + + auto sig = strUnHex(params[jss::signature].asString()); + if (!sig || sig->empty()) + return rpcError(rpcINVALID_PARAMS); + + Serializer msg; + serializePayChanAuthorization(msg, channelId, XRPAmount(drops)); + + Json::Value result; + result[jss::signature_verified] = verify(*pk, msg.slice(), makeSlice(*sig)); + return result; +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/Handlers.h b/src/xrpld/rpc/handlers/Handlers.h index a5a96baa31..23328cf52a 100644 --- a/src/xrpld/rpc/handlers/Handlers.h +++ b/src/xrpld/rpc/handlers/Handlers.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { @@ -19,7 +19,7 @@ doAccountObjects(RPC::JsonContext&); Json::Value doAccountOffers(RPC::JsonContext&); Json::Value -doAccountTxJson(RPC::JsonContext&); +doAccountTx(RPC::JsonContext&); Json::Value doAMMInfo(RPC::JsonContext&); Json::Value diff --git a/src/xrpld/rpc/handlers/AccountChannels.cpp b/src/xrpld/rpc/handlers/account/AccountChannels.cpp similarity index 100% rename from src/xrpld/rpc/handlers/AccountChannels.cpp rename to src/xrpld/rpc/handlers/account/AccountChannels.cpp diff --git a/src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp b/src/xrpld/rpc/handlers/account/AccountCurrencies.cpp similarity index 100% rename from src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp rename to src/xrpld/rpc/handlers/account/AccountCurrencies.cpp diff --git a/src/xrpld/rpc/handlers/AccountInfo.cpp b/src/xrpld/rpc/handlers/account/AccountInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/AccountInfo.cpp rename to src/xrpld/rpc/handlers/account/AccountInfo.cpp diff --git a/src/xrpld/rpc/handlers/AccountLines.cpp b/src/xrpld/rpc/handlers/account/AccountLines.cpp similarity index 100% rename from src/xrpld/rpc/handlers/AccountLines.cpp rename to src/xrpld/rpc/handlers/account/AccountLines.cpp diff --git a/src/xrpld/rpc/handlers/account/AccountNFTs.cpp b/src/xrpld/rpc/handlers/account/AccountNFTs.cpp new file mode 100644 index 0000000000..b879968e4e --- /dev/null +++ b/src/xrpld/rpc/handlers/account/AccountNFTs.cpp @@ -0,0 +1,160 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace xrpl { + +/** General RPC command that can retrieve objects in the account root. + { + account: + ledger_hash: // optional + ledger_index: // optional + type: // optional, defaults to all account objects types + limit: // optional + marker: // optional, resume previous query + } +*/ +Json::Value +doAccountNFTs(RPC::JsonContext& context) +{ + auto const& params = context.params; + if (!params.isMember(jss::account)) + return RPC::missing_field_error(jss::account); + + if (!params[jss::account].isString()) + return RPC::invalid_field_error(jss::account); + + auto id = parseBase58(params[jss::account].asString()); + if (!id) + { + return rpcError(rpcACT_MALFORMED); + } + + std::shared_ptr ledger; + auto result = RPC::lookupLedger(ledger, context); + if (ledger == nullptr) + return result; + auto const accountID{id.value()}; + + if (!ledger->exists(keylet::account(accountID))) + return rpcError(rpcACT_NOT_FOUND); + + unsigned int limit = 0; + if (auto err = readLimitField(limit, RPC::Tuning::accountNFTokens, context)) + return *err; + + uint256 marker; + bool const markerSet = params.isMember(jss::marker); + + if (markerSet) + { + auto const& m = params[jss::marker]; + if (!m.isString()) + return RPC::expected_field_error(jss::marker, "string"); + + if (!marker.parseHex(m.asString())) + return RPC::invalid_field_error(jss::marker); + } + + auto const first = keylet::nftpage(keylet::nftpage_min(accountID), marker); + auto const last = keylet::nftpage_max(accountID); + + auto cp = ledger->read( + Keylet(ltNFTOKEN_PAGE, ledger->succ(first.key, last.key.next()).value_or(last.key))); + + std::uint32_t cnt = 0; + auto& nfts = (result[jss::account_nfts] = Json::arrayValue); + + // Continue iteration from the current page: + bool pastMarker = marker.isZero(); + bool markerFound = false; + uint256 const maskedMarker = marker & nft::pageMask; + while (cp) + { + auto arr = cp->getFieldArray(sfNFTokens); + + for (auto const& o : arr) + { + // Scrolling past the marker gets weird. We need to look at + // a couple of conditions. + // + // 1. If the low 96-bits don't match, then we compare only + // against the low 96-bits, since that's what determines + // the sort order of the pages. + // + // 2. However, within one page there can be a number of + // NFTokenIDs that all have the same low 96 bits. If we're + // in that case then we need to compare against the full + // 256 bits. + uint256 const nftokenID = o[sfNFTokenID]; + uint256 const maskedNftokenID = nftokenID & nft::pageMask; + + if (!pastMarker) + { + if (maskedNftokenID < maskedMarker) + continue; + + if (maskedNftokenID == maskedMarker && nftokenID < marker) + continue; + + if (nftokenID == marker) + { + markerFound = true; + continue; + } + } + + if (markerSet && !markerFound) + return RPC::invalid_field_error(jss::marker); + + pastMarker = true; + + { + Json::Value& obj = nfts.append(o.getJson(JsonOptions::none)); + + // Pull out the components of the nft ID. + obj[sfFlags.jsonName] = nft::getFlags(nftokenID); + obj[sfIssuer.jsonName] = to_string(nft::getIssuer(nftokenID)); + obj[sfNFTokenTaxon.jsonName] = nft::toUInt32(nft::getTaxon(nftokenID)); + obj[jss::nft_serial] = nft::getSerial(nftokenID); + if (std::uint16_t const xferFee = {nft::getTransferFee(nftokenID)}) + obj[sfTransferFee.jsonName] = xferFee; + } + + if (++cnt == limit) + { + result[jss::limit] = limit; + result[jss::marker] = to_string(o.getFieldH256(sfNFTokenID)); + return result; + } + } + + if (auto npm = (*cp)[~sfNextPageMin]) + { + cp = ledger->read(Keylet(ltNFTOKEN_PAGE, *npm)); + } + else + { + cp = nullptr; + } + } + + if (markerSet && !markerFound) + return RPC::invalid_field_error(jss::marker); + + result[jss::account] = toBase58(accountID); + context.loadType = Resource::feeMediumBurdenRPC; + return result; +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/AccountObjects.cpp b/src/xrpld/rpc/handlers/account/AccountObjects.cpp similarity index 68% rename from src/xrpld/rpc/handlers/AccountObjects.cpp rename to src/xrpld/rpc/handlers/account/AccountObjects.cpp index 12132122c1..c09920f4a6 100644 --- a/src/xrpld/rpc/handlers/AccountObjects.cpp +++ b/src/xrpld/rpc/handlers/account/AccountObjects.cpp @@ -11,156 +11,11 @@ #include #include #include -#include #include namespace xrpl { -/** General RPC command that can retrieve objects in the account root. - { - account: - ledger_hash: // optional - ledger_index: // optional - type: // optional, defaults to all account objects types - limit: // optional - marker: // optional, resume previous query - } -*/ - -Json::Value -doAccountNFTs(RPC::JsonContext& context) -{ - auto const& params = context.params; - if (!params.isMember(jss::account)) - return RPC::missing_field_error(jss::account); - - if (!params[jss::account].isString()) - return RPC::invalid_field_error(jss::account); - - auto id = parseBase58(params[jss::account].asString()); - if (!id) - { - return rpcError(rpcACT_MALFORMED); - } - - std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); - if (ledger == nullptr) - return result; - auto const accountID{id.value()}; - - if (!ledger->exists(keylet::account(accountID))) - return rpcError(rpcACT_NOT_FOUND); - - unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::accountNFTokens, context)) - return *err; - - uint256 marker; - bool const markerSet = params.isMember(jss::marker); - - if (markerSet) - { - auto const& m = params[jss::marker]; - if (!m.isString()) - return RPC::expected_field_error(jss::marker, "string"); - - if (!marker.parseHex(m.asString())) - return RPC::invalid_field_error(jss::marker); - } - - auto const first = keylet::nftpage(keylet::nftpage_min(accountID), marker); - auto const last = keylet::nftpage_max(accountID); - - auto cp = ledger->read( - Keylet(ltNFTOKEN_PAGE, ledger->succ(first.key, last.key.next()).value_or(last.key))); - - std::uint32_t cnt = 0; - auto& nfts = (result[jss::account_nfts] = Json::arrayValue); - - // Continue iteration from the current page: - bool pastMarker = marker.isZero(); - bool markerFound = false; - uint256 const maskedMarker = marker & nft::pageMask; - while (cp) - { - auto arr = cp->getFieldArray(sfNFTokens); - - for (auto const& o : arr) - { - // Scrolling past the marker gets weird. We need to look at - // a couple of conditions. - // - // 1. If the low 96-bits don't match, then we compare only - // against the low 96-bits, since that's what determines - // the sort order of the pages. - // - // 2. However, within one page there can be a number of - // NFTokenIDs that all have the same low 96 bits. If we're - // in that case then we need to compare against the full - // 256 bits. - uint256 const nftokenID = o[sfNFTokenID]; - uint256 const maskedNftokenID = nftokenID & nft::pageMask; - - if (!pastMarker) - { - if (maskedNftokenID < maskedMarker) - continue; - - if (maskedNftokenID == maskedMarker && nftokenID < marker) - continue; - - if (nftokenID == marker) - { - markerFound = true; - continue; - } - } - - if (markerSet && !markerFound) - return RPC::invalid_field_error(jss::marker); - - pastMarker = true; - - { - Json::Value& obj = nfts.append(o.getJson(JsonOptions::none)); - - // Pull out the components of the nft ID. - obj[sfFlags.jsonName] = nft::getFlags(nftokenID); - obj[sfIssuer.jsonName] = to_string(nft::getIssuer(nftokenID)); - obj[sfNFTokenTaxon.jsonName] = nft::toUInt32(nft::getTaxon(nftokenID)); - obj[jss::nft_serial] = nft::getSerial(nftokenID); - if (std::uint16_t const xferFee = {nft::getTransferFee(nftokenID)}) - obj[sfTransferFee.jsonName] = xferFee; - } - - if (++cnt == limit) - { - result[jss::limit] = limit; - result[jss::marker] = to_string(o.getFieldH256(sfNFTokenID)); - return result; - } - } - - if (auto npm = (*cp)[~sfNextPageMin]) - { - cp = ledger->read(Keylet(ltNFTOKEN_PAGE, *npm)); - } - else - { - cp = nullptr; - } - } - - if (markerSet && !markerFound) - return RPC::invalid_field_error(jss::marker); - - result[jss::account] = toBase58(accountID); - context.loadType = Resource::feeMediumBurdenRPC; - return result; -} - /** Gathers all objects for an account in a ledger. @param ledger Ledger to search account objects. @param account AccountID to find objects for. diff --git a/src/xrpld/rpc/handlers/AccountOffers.cpp b/src/xrpld/rpc/handlers/account/AccountOffers.cpp similarity index 100% rename from src/xrpld/rpc/handlers/AccountOffers.cpp rename to src/xrpld/rpc/handlers/account/AccountOffers.cpp diff --git a/src/xrpld/rpc/handlers/AccountTx.cpp b/src/xrpld/rpc/handlers/account/AccountTx.cpp similarity index 99% rename from src/xrpld/rpc/handlers/AccountTx.cpp rename to src/xrpld/rpc/handlers/account/AccountTx.cpp index f46a71308c..acd5912ee0 100644 --- a/src/xrpld/rpc/handlers/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/account/AccountTx.cpp @@ -364,7 +364,7 @@ populateJsonResponse( // resume previous query // } Json::Value -doAccountTxJson(RPC::JsonContext& context) +doAccountTx(RPC::JsonContext& context) { if (!context.app.config().useTxTables()) return rpcError(rpcNOT_ENABLED); diff --git a/src/xrpld/rpc/handlers/GatewayBalances.cpp b/src/xrpld/rpc/handlers/account/GatewayBalances.cpp similarity index 100% rename from src/xrpld/rpc/handlers/GatewayBalances.cpp rename to src/xrpld/rpc/handlers/account/GatewayBalances.cpp diff --git a/src/xrpld/rpc/handlers/NoRippleCheck.cpp b/src/xrpld/rpc/handlers/account/NoRippleCheck.cpp similarity index 100% rename from src/xrpld/rpc/handlers/NoRippleCheck.cpp rename to src/xrpld/rpc/handlers/account/NoRippleCheck.cpp diff --git a/src/xrpld/rpc/handlers/OwnerInfo.cpp b/src/xrpld/rpc/handlers/account/OwnerInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/OwnerInfo.cpp rename to src/xrpld/rpc/handlers/account/OwnerInfo.cpp diff --git a/src/xrpld/rpc/handlers/BlackList.cpp b/src/xrpld/rpc/handlers/admin/BlackList.cpp similarity index 100% rename from src/xrpld/rpc/handlers/BlackList.cpp rename to src/xrpld/rpc/handlers/admin/BlackList.cpp diff --git a/src/xrpld/rpc/handlers/UnlList.cpp b/src/xrpld/rpc/handlers/admin/UnlList.cpp similarity index 100% rename from src/xrpld/rpc/handlers/UnlList.cpp rename to src/xrpld/rpc/handlers/admin/UnlList.cpp diff --git a/src/xrpld/rpc/handlers/CanDelete.cpp b/src/xrpld/rpc/handlers/admin/data/CanDelete.cpp similarity index 100% rename from src/xrpld/rpc/handlers/CanDelete.cpp rename to src/xrpld/rpc/handlers/admin/data/CanDelete.cpp diff --git a/src/xrpld/rpc/handlers/LedgerCleanerHandler.cpp b/src/xrpld/rpc/handlers/admin/data/LedgerCleaner.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerCleanerHandler.cpp rename to src/xrpld/rpc/handlers/admin/data/LedgerCleaner.cpp diff --git a/src/xrpld/rpc/handlers/LedgerRequest.cpp b/src/xrpld/rpc/handlers/admin/data/LedgerRequest.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerRequest.cpp rename to src/xrpld/rpc/handlers/admin/data/LedgerRequest.cpp diff --git a/src/xrpld/rpc/handlers/ValidationCreate.cpp b/src/xrpld/rpc/handlers/admin/keygen/ValidationCreate.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ValidationCreate.cpp rename to src/xrpld/rpc/handlers/admin/keygen/ValidationCreate.cpp diff --git a/src/xrpld/rpc/handlers/WalletPropose.cpp b/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp similarity index 98% rename from src/xrpld/rpc/handlers/WalletPropose.cpp rename to src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp index a5005ce701..ec06017b1b 100644 --- a/src/xrpld/rpc/handlers/WalletPropose.cpp +++ b/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/src/xrpld/rpc/handlers/WalletPropose.h b/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.h similarity index 100% rename from src/xrpld/rpc/handlers/WalletPropose.h rename to src/xrpld/rpc/handlers/admin/keygen/WalletPropose.h diff --git a/src/xrpld/rpc/handlers/LogLevel.cpp b/src/xrpld/rpc/handlers/admin/log/LogLevel.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LogLevel.cpp rename to src/xrpld/rpc/handlers/admin/log/LogLevel.cpp diff --git a/src/xrpld/rpc/handlers/LogRotate.cpp b/src/xrpld/rpc/handlers/admin/log/LogRotate.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LogRotate.cpp rename to src/xrpld/rpc/handlers/admin/log/LogRotate.cpp diff --git a/src/xrpld/rpc/handlers/Connect.cpp b/src/xrpld/rpc/handlers/admin/peer/Connect.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Connect.cpp rename to src/xrpld/rpc/handlers/admin/peer/Connect.cpp diff --git a/src/xrpld/rpc/handlers/Reservations.cpp b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp similarity index 63% rename from src/xrpld/rpc/handlers/Reservations.cpp rename to src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp index fb874247ad..dcd97bb2e4 100644 --- a/src/xrpld/rpc/handlers/Reservations.cpp +++ b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp @@ -9,7 +9,6 @@ #include #include -#include namespace xrpl { @@ -66,46 +65,4 @@ doPeerReservationsAdd(RPC::JsonContext& context) return result; } -Json::Value -doPeerReservationsDel(RPC::JsonContext& context) -{ - auto const& params = context.params; - - // We repeat much of the parameter parsing from `doPeerReservationsAdd`. - if (!params.isMember(jss::public_key)) - return RPC::missing_field_error(jss::public_key); - if (!params[jss::public_key].isString()) - return RPC::expected_field_error(jss::public_key, "a string"); - - std::optional optPk = - parseBase58(TokenType::NodePublic, params[jss::public_key].asString()); - if (!optPk) - return rpcError(rpcPUBLIC_MALFORMED); - PublicKey const& nodeId = *optPk; - - auto const previous = context.app.getPeerReservations().erase(nodeId); - - Json::Value result{Json::objectValue}; - if (previous) - { - result[jss::previous] = previous->toJson(); - } - return result; -} - -Json::Value -doPeerReservationsList(RPC::JsonContext& context) -{ - auto const& reservations = context.app.getPeerReservations().list(); - // Enumerate the reservations in context.app.getPeerReservations() - // as a Json::Value. - Json::Value result{Json::objectValue}; - Json::Value& jaReservations = result[jss::reservations] = Json::arrayValue; - for (auto const& reservation : reservations) - { - jaReservations.append(reservation.toJson()); - } - return result; -} - } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp new file mode 100644 index 0000000000..14d017779d --- /dev/null +++ b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp @@ -0,0 +1,41 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace xrpl { + +Json::Value +doPeerReservationsDel(RPC::JsonContext& context) +{ + auto const& params = context.params; + + // We repeat much of the parameter parsing from `doPeerReservationsAdd`. + if (!params.isMember(jss::public_key)) + return RPC::missing_field_error(jss::public_key); + if (!params[jss::public_key].isString()) + return RPC::expected_field_error(jss::public_key, "a string"); + + std::optional optPk = + parseBase58(TokenType::NodePublic, params[jss::public_key].asString()); + if (!optPk) + return rpcError(rpcPUBLIC_MALFORMED); + PublicKey const& nodeId = *optPk; + + auto const previous = context.app.getPeerReservations().erase(nodeId); + + Json::Value result{Json::objectValue}; + if (previous) + { + result[jss::previous] = previous->toJson(); + } + return result; +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp new file mode 100644 index 0000000000..119af3f73c --- /dev/null +++ b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp @@ -0,0 +1,24 @@ +#include +#include + +#include +#include + +namespace xrpl { + +Json::Value +doPeerReservationsList(RPC::JsonContext& context) +{ + auto const& reservations = context.app.getPeerReservations().list(); + // Enumerate the reservations in context.app.getPeerReservations() + // as a Json::Value. + Json::Value result{Json::objectValue}; + Json::Value& jaReservations = result[jss::reservations] = Json::arrayValue; + for (auto const& reservation : reservations) + { + jaReservations.append(reservation.toJson()); + } + return result; +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/Peers.cpp b/src/xrpld/rpc/handlers/admin/peer/Peers.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Peers.cpp rename to src/xrpld/rpc/handlers/admin/peer/Peers.cpp diff --git a/src/xrpld/rpc/handlers/LedgerAccept.cpp b/src/xrpld/rpc/handlers/admin/server_control/LedgerAccept.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerAccept.cpp rename to src/xrpld/rpc/handlers/admin/server_control/LedgerAccept.cpp diff --git a/src/xrpld/rpc/handlers/Stop.cpp b/src/xrpld/rpc/handlers/admin/server_control/Stop.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Stop.cpp rename to src/xrpld/rpc/handlers/admin/server_control/Stop.cpp diff --git a/src/xrpld/rpc/handlers/PayChanClaim.cpp b/src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp similarity index 59% rename from src/xrpld/rpc/handlers/PayChanClaim.cpp rename to src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp index b24a241147..73d185be44 100644 --- a/src/xrpld/rpc/handlers/PayChanClaim.cpp +++ b/src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -83,61 +82,4 @@ doChannelAuthorize(RPC::JsonContext& context) return result; } -// { -// public_key: -// channel_id: 256-bit channel id -// drops: 64-bit uint (as string) -// signature: signature to verify -// } -Json::Value -doChannelVerify(RPC::JsonContext& context) -{ - auto const& params(context.params); - for (auto const& p : {jss::public_key, jss::channel_id, jss::amount, jss::signature}) - { - if (!params.isMember(p)) - return RPC::missing_field_error(p); - } - - std::optional pk; - { - std::string const strPk = params[jss::public_key].asString(); - pk = parseBase58(TokenType::AccountPublic, strPk); - - if (!pk) - { - auto pkHex = strUnHex(strPk); - if (!pkHex) - return rpcError(rpcPUBLIC_MALFORMED); - auto const pkType = publicKeyType(makeSlice(*pkHex)); - if (!pkType) - return rpcError(rpcPUBLIC_MALFORMED); - pk.emplace(makeSlice(*pkHex)); - } - } - - uint256 channelId; - if (!channelId.parseHex(params[jss::channel_id].asString())) - return rpcError(rpcCHANNEL_MALFORMED); - - std::optional const optDrops = - params[jss::amount].isString() ? to_uint64(params[jss::amount].asString()) : std::nullopt; - - if (!optDrops) - return rpcError(rpcCHANNEL_AMT_MALFORMED); - - std::uint64_t const drops = *optDrops; - - auto sig = strUnHex(params[jss::signature].asString()); - if (!sig || sig->empty()) - return rpcError(rpcINVALID_PARAMS); - - Serializer msg; - serializePayChanAuthorization(msg, channelId, XRPAmount(drops)); - - Json::Value result; - result[jss::signature_verified] = verify(*pk, msg.slice(), makeSlice(*sig)); - return result; -} - } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/SignHandler.cpp b/src/xrpld/rpc/handlers/admin/signing/Sign.cpp similarity index 100% rename from src/xrpld/rpc/handlers/SignHandler.cpp rename to src/xrpld/rpc/handlers/admin/signing/Sign.cpp diff --git a/src/xrpld/rpc/handlers/SignFor.cpp b/src/xrpld/rpc/handlers/admin/signing/SignFor.cpp similarity index 100% rename from src/xrpld/rpc/handlers/SignFor.cpp rename to src/xrpld/rpc/handlers/admin/signing/SignFor.cpp diff --git a/src/xrpld/rpc/handlers/ConsensusInfo.cpp b/src/xrpld/rpc/handlers/admin/status/ConsensusInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ConsensusInfo.cpp rename to src/xrpld/rpc/handlers/admin/status/ConsensusInfo.cpp diff --git a/src/xrpld/rpc/handlers/FetchInfo.cpp b/src/xrpld/rpc/handlers/admin/status/FetchInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/FetchInfo.cpp rename to src/xrpld/rpc/handlers/admin/status/FetchInfo.cpp diff --git a/src/xrpld/rpc/handlers/GetCounts.cpp b/src/xrpld/rpc/handlers/admin/status/GetCounts.cpp similarity index 100% rename from src/xrpld/rpc/handlers/GetCounts.cpp rename to src/xrpld/rpc/handlers/admin/status/GetCounts.cpp diff --git a/src/xrpld/rpc/handlers/GetCounts.h b/src/xrpld/rpc/handlers/admin/status/GetCounts.h similarity index 100% rename from src/xrpld/rpc/handlers/GetCounts.h rename to src/xrpld/rpc/handlers/admin/status/GetCounts.h diff --git a/src/xrpld/rpc/handlers/Print.cpp b/src/xrpld/rpc/handlers/admin/status/Print.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Print.cpp rename to src/xrpld/rpc/handlers/admin/status/Print.cpp diff --git a/src/xrpld/rpc/handlers/ValidatorInfo.cpp b/src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ValidatorInfo.cpp rename to src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp diff --git a/src/xrpld/rpc/handlers/ValidatorListSites.cpp b/src/xrpld/rpc/handlers/admin/status/ValidatorListSites.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ValidatorListSites.cpp rename to src/xrpld/rpc/handlers/admin/status/ValidatorListSites.cpp diff --git a/src/xrpld/rpc/handlers/Validators.cpp b/src/xrpld/rpc/handlers/admin/status/Validators.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Validators.cpp rename to src/xrpld/rpc/handlers/admin/status/Validators.cpp diff --git a/src/xrpld/rpc/handlers/LedgerHandler.cpp b/src/xrpld/rpc/handlers/ledger/Ledger.cpp similarity index 99% rename from src/xrpld/rpc/handlers/LedgerHandler.cpp rename to src/xrpld/rpc/handlers/ledger/Ledger.cpp index 0707ad1ffe..6bf627d29c 100644 --- a/src/xrpld/rpc/handlers/LedgerHandler.cpp +++ b/src/xrpld/rpc/handlers/ledger/Ledger.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/xrpld/rpc/handlers/LedgerHandler.h b/src/xrpld/rpc/handlers/ledger/Ledger.h similarity index 100% rename from src/xrpld/rpc/handlers/LedgerHandler.h rename to src/xrpld/rpc/handlers/ledger/Ledger.h diff --git a/src/xrpld/rpc/handlers/LedgerClosed.cpp b/src/xrpld/rpc/handlers/ledger/LedgerClosed.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerClosed.cpp rename to src/xrpld/rpc/handlers/ledger/LedgerClosed.cpp diff --git a/src/xrpld/rpc/handlers/LedgerCurrent.cpp b/src/xrpld/rpc/handlers/ledger/LedgerCurrent.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerCurrent.cpp rename to src/xrpld/rpc/handlers/ledger/LedgerCurrent.cpp diff --git a/src/xrpld/rpc/handlers/LedgerData.cpp b/src/xrpld/rpc/handlers/ledger/LedgerData.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerData.cpp rename to src/xrpld/rpc/handlers/ledger/LedgerData.cpp diff --git a/src/xrpld/rpc/handlers/LedgerDiff.cpp b/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerDiff.cpp rename to src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp diff --git a/src/xrpld/rpc/handlers/LedgerEntry.cpp b/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp similarity index 99% rename from src/xrpld/rpc/handlers/LedgerEntry.cpp rename to src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp index d27574944d..377983718e 100644 --- a/src/xrpld/rpc/handlers/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/xrpld/rpc/handlers/LedgerEntryHelpers.h b/src/xrpld/rpc/handlers/ledger/LedgerEntryHelpers.h similarity index 100% rename from src/xrpld/rpc/handlers/LedgerEntryHelpers.h rename to src/xrpld/rpc/handlers/ledger/LedgerEntryHelpers.h diff --git a/src/xrpld/rpc/handlers/LedgerHeader.cpp b/src/xrpld/rpc/handlers/ledger/LedgerHeader.cpp similarity index 100% rename from src/xrpld/rpc/handlers/LedgerHeader.cpp rename to src/xrpld/rpc/handlers/ledger/LedgerHeader.cpp diff --git a/src/xrpld/rpc/handlers/AMMInfo.cpp b/src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/AMMInfo.cpp rename to src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp diff --git a/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp b/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp new file mode 100644 index 0000000000..83b26729a1 --- /dev/null +++ b/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +#include + +namespace xrpl { + +Json::Value +doBookChanges(RPC::JsonContext& context) +{ + std::shared_ptr ledger; + + Json::Value result = RPC::lookupLedger(ledger, context); + if (ledger == nullptr) + return result; + + return RPC::computeBookChanges(ledger); +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/BookOffers.cpp b/src/xrpld/rpc/handlers/orderbook/BookOffers.cpp similarity index 95% rename from src/xrpld/rpc/handlers/BookOffers.cpp rename to src/xrpld/rpc/handlers/orderbook/BookOffers.cpp index ec53473821..33d1e938ad 100644 --- a/src/xrpld/rpc/handlers/BookOffers.cpp +++ b/src/xrpld/rpc/handlers/orderbook/BookOffers.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -205,16 +204,4 @@ doBookOffers(RPC::JsonContext& context) return jvResult; } -Json::Value -doBookChanges(RPC::JsonContext& context) -{ - std::shared_ptr ledger; - - Json::Value result = RPC::lookupLedger(ledger, context); - if (ledger == nullptr) - return result; - - return RPC::computeBookChanges(ledger); -} - } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/DepositAuthorized.cpp b/src/xrpld/rpc/handlers/orderbook/DepositAuthorized.cpp similarity index 100% rename from src/xrpld/rpc/handlers/DepositAuthorized.cpp rename to src/xrpld/rpc/handlers/orderbook/DepositAuthorized.cpp diff --git a/src/xrpld/rpc/handlers/GetAggregatePrice.cpp b/src/xrpld/rpc/handlers/orderbook/GetAggregatePrice.cpp similarity index 100% rename from src/xrpld/rpc/handlers/GetAggregatePrice.cpp rename to src/xrpld/rpc/handlers/orderbook/GetAggregatePrice.cpp diff --git a/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp b/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp new file mode 100644 index 0000000000..3ee8935f3a --- /dev/null +++ b/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp @@ -0,0 +1,24 @@ +#include +#include + +#include +#include +#include + +namespace xrpl { + +Json::Value +doNFTBuyOffers(RPC::JsonContext& context) +{ + if (!context.params.isMember(jss::nft_id)) + return RPC::missing_field_error(jss::nft_id); + + uint256 nftId; + + if (!nftId.parseHex(context.params[jss::nft_id].asString())) + return RPC::invalid_field_error(jss::nft_id); + + return enumerateNFTOffers(context, nftId, keylet::nft_buys(nftId)); +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/NFTOffers.cpp b/src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h similarity index 82% rename from src/xrpld/rpc/handlers/NFTOffers.cpp rename to src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h index 5fe2e3bede..8f68aeaadd 100644 --- a/src/xrpld/rpc/handlers/NFTOffers.cpp +++ b/src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h @@ -1,3 +1,5 @@ +#pragma once + #include #include #include @@ -14,7 +16,7 @@ namespace xrpl { -static void +inline void appendNftOfferJson( Application const& app, std::shared_ptr const& offer, @@ -42,7 +44,7 @@ appendNftOfferJson( // limit: integer // optional // marker: opaque // optional, resume previous query // } -static Json::Value +inline Json::Value enumerateNFTOffers(RPC::JsonContext& context, uint256 const& nftId, Keylet const& directory) { unsigned int limit = 0; @@ -127,32 +129,4 @@ enumerateNFTOffers(RPC::JsonContext& context, uint256 const& nftId, Keylet const return result; } -Json::Value -doNFTSellOffers(RPC::JsonContext& context) -{ - if (!context.params.isMember(jss::nft_id)) - return RPC::missing_field_error(jss::nft_id); - - uint256 nftId; - - if (!nftId.parseHex(context.params[jss::nft_id].asString())) - return RPC::invalid_field_error(jss::nft_id); - - return enumerateNFTOffers(context, nftId, keylet::nft_sells(nftId)); -} - -Json::Value -doNFTBuyOffers(RPC::JsonContext& context) -{ - if (!context.params.isMember(jss::nft_id)) - return RPC::missing_field_error(jss::nft_id); - - uint256 nftId; - - if (!nftId.parseHex(context.params[jss::nft_id].asString())) - return RPC::invalid_field_error(jss::nft_id); - - return enumerateNFTOffers(context, nftId, keylet::nft_buys(nftId)); -} - } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp b/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp new file mode 100644 index 0000000000..9dbd9ef49f --- /dev/null +++ b/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp @@ -0,0 +1,24 @@ +#include +#include + +#include +#include +#include + +namespace xrpl { + +Json::Value +doNFTSellOffers(RPC::JsonContext& context) +{ + if (!context.params.isMember(jss::nft_id)) + return RPC::missing_field_error(jss::nft_id); + + uint256 nftId; + + if (!nftId.parseHex(context.params[jss::nft_id].asString())) + return RPC::invalid_field_error(jss::nft_id); + + return enumerateNFTOffers(context, nftId, keylet::nft_sells(nftId)); +} + +} // namespace xrpl diff --git a/src/xrpld/rpc/handlers/PathFind.cpp b/src/xrpld/rpc/handlers/orderbook/PathFind.cpp similarity index 100% rename from src/xrpld/rpc/handlers/PathFind.cpp rename to src/xrpld/rpc/handlers/orderbook/PathFind.cpp diff --git a/src/xrpld/rpc/handlers/RipplePathFind.cpp b/src/xrpld/rpc/handlers/orderbook/RipplePathFind.cpp similarity index 100% rename from src/xrpld/rpc/handlers/RipplePathFind.cpp rename to src/xrpld/rpc/handlers/orderbook/RipplePathFind.cpp diff --git a/src/xrpld/rpc/handlers/Feature1.cpp b/src/xrpld/rpc/handlers/server_info/Feature.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Feature1.cpp rename to src/xrpld/rpc/handlers/server_info/Feature.cpp diff --git a/src/xrpld/rpc/handlers/Fee1.cpp b/src/xrpld/rpc/handlers/server_info/Fee.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Fee1.cpp rename to src/xrpld/rpc/handlers/server_info/Fee.cpp diff --git a/src/xrpld/rpc/handlers/DoManifest.cpp b/src/xrpld/rpc/handlers/server_info/Manifest.cpp similarity index 100% rename from src/xrpld/rpc/handlers/DoManifest.cpp rename to src/xrpld/rpc/handlers/server_info/Manifest.cpp diff --git a/src/xrpld/rpc/handlers/ServerDefinitions.cpp b/src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ServerDefinitions.cpp rename to src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp diff --git a/src/xrpld/rpc/handlers/ServerInfo.cpp b/src/xrpld/rpc/handlers/server_info/ServerInfo.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ServerInfo.cpp rename to src/xrpld/rpc/handlers/server_info/ServerInfo.cpp diff --git a/src/xrpld/rpc/handlers/ServerState.cpp b/src/xrpld/rpc/handlers/server_info/ServerState.cpp similarity index 100% rename from src/xrpld/rpc/handlers/ServerState.cpp rename to src/xrpld/rpc/handlers/server_info/ServerState.cpp diff --git a/src/xrpld/rpc/handlers/Version.h b/src/xrpld/rpc/handlers/server_info/Version.h similarity index 100% rename from src/xrpld/rpc/handlers/Version.h rename to src/xrpld/rpc/handlers/server_info/Version.h diff --git a/src/xrpld/rpc/handlers/Subscribe.cpp b/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Subscribe.cpp rename to src/xrpld/rpc/handlers/subscribe/Subscribe.cpp diff --git a/src/xrpld/rpc/handlers/Unsubscribe.cpp b/src/xrpld/rpc/handlers/subscribe/Unsubscribe.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Unsubscribe.cpp rename to src/xrpld/rpc/handlers/subscribe/Unsubscribe.cpp diff --git a/src/xrpld/rpc/handlers/Simulate.cpp b/src/xrpld/rpc/handlers/transaction/Simulate.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Simulate.cpp rename to src/xrpld/rpc/handlers/transaction/Simulate.cpp diff --git a/src/xrpld/rpc/handlers/Submit.cpp b/src/xrpld/rpc/handlers/transaction/Submit.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Submit.cpp rename to src/xrpld/rpc/handlers/transaction/Submit.cpp diff --git a/src/xrpld/rpc/handlers/SubmitMultiSigned.cpp b/src/xrpld/rpc/handlers/transaction/SubmitMultiSigned.cpp similarity index 100% rename from src/xrpld/rpc/handlers/SubmitMultiSigned.cpp rename to src/xrpld/rpc/handlers/transaction/SubmitMultiSigned.cpp diff --git a/src/xrpld/rpc/handlers/TransactionEntry.cpp b/src/xrpld/rpc/handlers/transaction/TransactionEntry.cpp similarity index 100% rename from src/xrpld/rpc/handlers/TransactionEntry.cpp rename to src/xrpld/rpc/handlers/transaction/TransactionEntry.cpp diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/transaction/Tx.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Tx.cpp rename to src/xrpld/rpc/handlers/transaction/Tx.cpp diff --git a/src/xrpld/rpc/handlers/TxHistory.cpp b/src/xrpld/rpc/handlers/transaction/TxHistory.cpp similarity index 100% rename from src/xrpld/rpc/handlers/TxHistory.cpp rename to src/xrpld/rpc/handlers/transaction/TxHistory.cpp diff --git a/src/xrpld/rpc/handlers/TxReduceRelay.cpp b/src/xrpld/rpc/handlers/transaction/TxReduceRelay.cpp similarity index 100% rename from src/xrpld/rpc/handlers/TxReduceRelay.cpp rename to src/xrpld/rpc/handlers/transaction/TxReduceRelay.cpp diff --git a/src/xrpld/rpc/handlers/Ping.cpp b/src/xrpld/rpc/handlers/utility/Ping.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Ping.cpp rename to src/xrpld/rpc/handlers/utility/Ping.cpp diff --git a/src/xrpld/rpc/handlers/Random.cpp b/src/xrpld/rpc/handlers/utility/Random.cpp similarity index 100% rename from src/xrpld/rpc/handlers/Random.cpp rename to src/xrpld/rpc/handlers/utility/Random.cpp