mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
* Add jss fields used by Clio `nft_info`: (#4320) Add Clio-specific JSS constants to ensure a common vocabulary of keywords in Clio and this project. By providing visibility of the full API keyword namespace, it reduces the likelihood of developers introducing minor variations on names used by Clio, or unknowingly claiming a keyword that Clio has already claimed. This change moves this project slightly away from having only the code necessary for running the core server, but it is a step toward the goal of keeping this server's and Clio's APIs similar. The added JSS constants are annotated to indicate their relevance to Clio. Clio can be found here: https://github.com/XRPLF/clio Signed-off-by: ledhed2222 <ledhed2222@users.noreply.github.com> * Introduce support for a slabbed allocator: (#4218) When instantiating a large amount of fixed-sized objects on the heap the overhead that dynamic memory allocation APIs impose will quickly become significant. In some cases, allocating a large amount of memory at once and using a slabbing allocator to carve the large block into fixed-sized units that are used to service requests for memory out will help to reduce memory fragmentation significantly and, potentially, improve overall performance. This commit introduces a new `SlabAllocator<>` class that exposes an API that is _similar_ to the C++ concept of an `Allocator` but it is not meant to be a general-purpose allocator. It should not be used unless profiling and analysis of specific memory allocation patterns indicates that the additional complexity introduced will improve the performance of the system overall, and subsequent profiling proves it. A helper class, `SlabAllocatorSet<>` simplifies handling of variably sized objects that benefit from slab allocations. This commit incorporates improvements suggested by Greg Popovitch (@greg7mdp). Commit 1 of 3 in #4218. * Optimize `SHAMapItem` and leverage new slab allocator: (#4218) The `SHAMapItem` class contains a variable-sized buffer that holds the serialized data associated with a particular item inside a `SHAMap`. Prior to this commit, the buffer for the serialized data was allocated separately. Coupled with the fact that most instances of `SHAMapItem` were wrapped around a `std::shared_ptr` meant that an instantiation might result in up to three separate memory allocations. This commit switches away from `std::shared_ptr` for `SHAMapItem` and uses `boost::intrusive_ptr` instead, allowing the reference count for an instance to live inside the instance itself. Coupled with using a slab-based allocator to optimize memory allocation for the most commonly sized buffers, the net result is significant memory savings. In testing, the reduction in memory usage hovers between 400MB and 650MB. Other scenarios might result in larger savings. In performance testing with NFTs, this commit reduces memory size by about 15% sustained over long duration. Commit 2 of 3 in #4218. * Avoid using std::shared_ptr when not necessary: (#4218) The `Ledger` class contains two `SHAMap` instances: the state and transaction maps. Previously, the maps were dynamically allocated using `std::make_shared` despite the fact that they did not require lifetime management separate from the lifetime of the `Ledger` instance to which they belong. The two `SHAMap` instances are now regular member variables. Some smart pointers and dynamic memory allocation was avoided by using stack-based alternatives. Commit 3 of 3 in #4218. * Prevent replay attacks with NetworkID field: (#4370) Add a `NetworkID` field to help prevent replay attacks on and from side-chains. The new field must be used when the server is using a network id > 1024. To preserve legacy behavior, all chains with a network ID less than 1025 retain the existing behavior. This includes Mainnet, Testnet, Devnet, and hooks-testnet. If `sfNetworkID` is present in any transaction submitted to any of the nodes on one of these chains, then `telNETWORK_ID_MAKES_TX_NON_CANONICAL` is returned. Since chains with a network ID less than 1025, including Mainnet, retain the existing behavior, there is no need for an amendment. The `NetworkID` helps to prevent replay attacks because users specify a `NetworkID` field in every transaction for that chain. This change introduces a new UINT32 field, `sfNetworkID` ("NetworkID"). There are also three new local error codes for transaction results: - `telNETWORK_ID_MAKES_TX_NON_CANONICAL` - `telREQUIRES_NETWORK_ID` - `telWRONG_NETWORK` To learn about the other transaction result codes, see: https://xrpl.org/transaction-results.html Local error codes were chosen because a transaction is not necessarily malformed if it is submitted to a node running on the incorrect chain. This is a local error specific to that node and could be corrected by switching to a different node or by changing the `network_id` on that node. See: https://xrpl.org/connect-your-rippled-to-the-xrp-test-net.html In addition to using `NetworkID`, it is still generally recommended to use different accounts and keys on side-chains. However, people will undoubtedly use the same keys on multiple chains; for example, this is common practice on other blockchain networks. There are also some legitimate use cases for this. A `app.NetworkID` test suite has been added, and `core.Config` was updated to include some network_id tests. * Fix the fix for std::result_of (#4496) Newer compilers, such as Apple Clang 15.0, have removed `std::result_of` as part of C++20. The build instructions provided a fix for this (by adding a preprocessor definition), but the fix was broken. This fixes the fix by: * Adding the `conf` prefix for tool configurations (which had been forgotten). * Passing `extra_b2_flags` to `boost` package to fix its build. * Define `BOOST_ASIO_HAS_STD_INVOKE_RESULT` in order to build boost 1.77 with a newer compiler. * Use quorum specified via command line: (#4489) If `--quorum` setting is present on the command line, use the specified value as the minimum quorum. This allows for the use of a potentially fork-unsafe quorum, but it is sometimes necessary for small and test networks. Fix #4488. --------- Co-authored-by: RichardAH <richard.holland@starstone.co.nz> * Fix errors for Clang 16: (#4501) Address issues related to the removal of `std::{u,bi}nary_function` in C++17 and some warnings with Clang 16. Some warnings appeared with the upgrade to Apple clang version 14.0.3 (clang-1403.0.22.14.1). - `std::{u,bi}nary_function` were removed in C++17. They were empty classes with a few associated types. We already have conditional code to define the types. Just make it unconditional. - libc++ checks a cast in an unevaluated context to see if a type inherits from a binary function class in the standard library, e.g. `std::equal_to`, and this causes an error when the type privately inherits from such a class. Change these instances to public inheritance. - We don't need a middle-man for the empty base optimization. Prefer to inherit directly from an empty class than from `beast::detail::empty_base_optimization`. - Clang warns when all the uses of a variable are removed by conditional compilation of assertions. Add a `[[maybe_unused]]` annotation to suppress it. - As a drive-by clean-up, remove commented code. See related work in #4486. * Fix typo (#4508) * fix!: Prevent API from accepting seed or public key for account (#4404) The API would allow seeds (and public keys) to be used in place of accounts at several locations in the API. For example, when calling account_info, you could pass `"account": "foo"`. The string "foo" is treated like a seed, so the method returns `actNotFound` (instead of `actMalformed`, as most developers would expect). In the early days, this was a convenience to make testing easier. However, it allows for poor security practices, so it is no longer a good idea. Allowing a secret or passphrase is now considered a bug. Previously, it was controlled by the `strict` option on some methods. With this commit, since the API does not interpret `account` as `seed`, the option `strict` is no longer needed and is removed. Removing this behavior from the API is a [breaking change](https://xrpl.org/request-formatting.html#breaking-changes). One could argue that it shouldn't be done without bumping the API version; however, in this instance, there is no evidence that anyone is using the API in the "legacy" way. Furthermore, it is a potential security hole, as it allows users to send secrets to places where they are not needed, where they could end up in logs, error messages, etc. There's no reason to take such a risk with a seed/secret, since only the public address is needed. Resolves: #3329, #3330, #4337 BREAKING CHANGE: Remove non-strict account parsing (#3330) * Add nftoken_id, nftoken_ids, offer_id fields for NFTokens (#4447) Three new fields are added to the `Tx` responses for NFTs: 1. `nftoken_id`: This field is included in the `Tx` responses for `NFTokenMint` and `NFTokenAcceptOffer`. This field indicates the `NFTokenID` for the `NFToken` that was modified on the ledger by the transaction. 2. `nftoken_ids`: This array is included in the `Tx` response for `NFTokenCancelOffer`. This field provides a list of all the `NFTokenID`s for the `NFToken`s that were modified on the ledger by the transaction. 3. `offer_id`: This field is included in the `Tx` response for `NFTokenCreateOffer` transactions and shows the OfferID of the `NFTokenOffer` created. The fields make it easier to track specific tokens and offers. The implementation includes code (by @ledhed2222) from the Clio project to extract NFTokenIDs from mint transactions. * Ensure that switchover vars are initialized before use: (#4527) Global variables in different TUs are initialized in an undefined order. At least one global variable was accessing a global switchover variable. This caused the switchover variable to be accessed in an uninitialized state. Since the switchover is always explicitly set before transaction processing, this bug can not effect transaction processing, but could effect unit tests (and potentially the value of some global variables). Note: at the time of this patch the offending bug is not yet in production. * Move faulty assert (#4533) This assert was put in the wrong place, but it only triggers if shards are configured. This change moves the assert to the right place and updates it to ensure correctness. The assert could be hit after the server downloads some shards. It may be necessary to restart after the shards are downloaded. Note that asserts are normally checked only in debug builds, so release packages should not be affected. Introduced in: #4319 (66627b26cf) * Fix unaligned load and stores: (#4528) (#4531) Misaligned load and store operations are supported by both Intel and ARM CPUs. However, in C++, these operations are undefined behavior (UB). Substituting these operations with a `memcpy` fixes this UB. The compiled assembly code is equivalent to the original, so there is no performance penalty to using memcpy. For context: The unaligned load and store operations fixed here were originally introduced in the slab allocator (#4218). * Add missing includes for gcc 13.1: (#4555) gcc 13.1 failed to compile due to missing headers. This patch adds the needed headers. * Trivial: add comments for NFToken-related invariants (#4558) * fix node size estimation (#4536) Fix a bug in the `NODE_SIZE` auto-detection feature in `Config.cpp`. Specifically, this patch corrects the calculation for the total amount of RAM available, which was previously returned in bytes, but is now being returned in units of the system's memory unit. Additionally, the patch adjusts the node size based on the number of available hardware threads of execution. * fix: remove redundant moves (#4565) - Resolve gcc compiler warning: AccountObjects.cpp:182:47: warning: redundant move in initialization [-Wredundant-move] - The std::move() operation on trivially copyable types may generate a compile warning in newer versions of gcc. - Remove extraneous header (unused imports) from a unit test file. * Revert "Fix the fix for std::result_of (#4496)" This reverts commitcee8409d60. * Revert "Fix typo (#4508)" This reverts commit2956f14de8. * clang * [fold] bad merge * [fold] fix bad merge - add back filter for ripple state on account_channels - add back network id test (env auto adds network id in xahau) * [fold] fix build error --------- Signed-off-by: ledhed2222 <ledhed2222@users.noreply.github.com> Co-authored-by: ledhed2222 <ledhed2222@users.noreply.github.com> Co-authored-by: Nik Bougalis <nikb@bougalis.net> Co-authored-by: RichardAH <richard.holland@starstone.co.nz> Co-authored-by: John Freeman <jfreeman08@gmail.com> Co-authored-by: Mark Travis <mtrippled@users.noreply.github.com> Co-authored-by: solmsted <steven.olm@gmail.com> Co-authored-by: drlongle <drlongle@gmail.com> Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com> Co-authored-by: Scott Determan <scott.determan@yahoo.com> Co-authored-by: Ed Hennis <ed@ripple.com> Co-authored-by: Scott Schurr <scott@ripple.com> Co-authored-by: Chenna Keshava B S <21219765+ckeshava@users.noreply.github.com>
261 lines
17 KiB
C++
261 lines
17 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#include <ripple/protocol/TER.h>
|
|
#include <boost/range/adaptor/transformed.hpp>
|
|
#include <type_traits>
|
|
#include <unordered_map>
|
|
|
|
namespace ripple {
|
|
|
|
namespace detail {
|
|
|
|
static std::unordered_map<
|
|
TERUnderlyingType,
|
|
std::pair<char const* const, char const* const>> const&
|
|
transResults()
|
|
{
|
|
// clang-format off
|
|
|
|
// Macros are generally ugly, but they can help make code readable to
|
|
// humans without affecting the compiler.
|
|
#define MAKE_ERROR(code, desc) { code, { #code, desc } }
|
|
|
|
static
|
|
std::unordered_map<
|
|
TERUnderlyingType,
|
|
std::pair<char const* const, char const* const>> const results
|
|
{
|
|
MAKE_ERROR(tecCLAIM, "Fee claimed. Sequence used. No action."),
|
|
MAKE_ERROR(tecDIR_FULL, "Can not add entry to full directory."),
|
|
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 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 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."),
|
|
MAKE_ERROR(tecOWNERS, "Non-zero owner count."),
|
|
MAKE_ERROR(tecNO_ISSUER, "Issuer account does not exist."),
|
|
MAKE_ERROR(tecNO_AUTH, "Not authorized to hold asset."),
|
|
MAKE_ERROR(tecNO_LINE, "No such line."),
|
|
MAKE_ERROR(tecINSUFF_FEE, "Insufficient balance to pay fee."),
|
|
MAKE_ERROR(tecFROZEN, "Asset is frozen."),
|
|
MAKE_ERROR(tecNO_TARGET, "Target account does not exist."),
|
|
MAKE_ERROR(tecNO_PERMISSION, "No permission to perform requested operation."),
|
|
MAKE_ERROR(tecNO_ENTRY, "No matching entry found."),
|
|
MAKE_ERROR(tecINSUFFICIENT_RESERVE, "Insufficient reserve to complete requested operation."),
|
|
MAKE_ERROR(tecNEED_MASTER_KEY, "The operation requires the use of the Master Key."),
|
|
MAKE_ERROR(tecDST_TAG_NEEDED, "A destination tag is required."),
|
|
MAKE_ERROR(tecINTERNAL, "An internal error has occurred during processing."),
|
|
MAKE_ERROR(tecCRYPTOCONDITION_ERROR, "Malformed, invalid, or mismatched conditional or fulfillment."),
|
|
MAKE_ERROR(tecINVARIANT_FAILED, "One or more invariants for the transaction were not satisfied."),
|
|
MAKE_ERROR(tecEXPIRED, "Expiration time is passed."),
|
|
MAKE_ERROR(tecDUPLICATE, "Ledger object already exists."),
|
|
MAKE_ERROR(tecKILLED, "No funds transferred and no offer created."),
|
|
MAKE_ERROR(tecHAS_OBLIGATIONS, "The account cannot be deleted since it has obligations."),
|
|
MAKE_ERROR(tecTOO_SOON, "It is too early to attempt the requested operation. Please wait."),
|
|
MAKE_ERROR(tecMAX_SEQUENCE_REACHED, "The maximum sequence number was reached."),
|
|
MAKE_ERROR(tecNO_SUITABLE_NFTOKEN_PAGE, "A suitable NFToken page could not be located."),
|
|
MAKE_ERROR(tecNFTOKEN_BUY_SELL_MISMATCH, "The 'Buy' and 'Sell' NFToken offers are mismatched."),
|
|
MAKE_ERROR(tecNFTOKEN_OFFER_TYPE_MISMATCH, "The type of NFToken offer is incorrect."),
|
|
MAKE_ERROR(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER, "An NFToken offer cannot be claimed by its owner."),
|
|
MAKE_ERROR(tecINSUFFICIENT_FUNDS, "Not enough funds available to complete requested transaction."),
|
|
MAKE_ERROR(tecOBJECT_NOT_FOUND, "A requested object could not be located."),
|
|
MAKE_ERROR(tecINSUFFICIENT_PAYMENT, "The payment is not sufficient."),
|
|
MAKE_ERROR(tecHOOK_REJECTED, "Rejected by hook on sending or receiving account."),
|
|
MAKE_ERROR(tecREQUIRES_FLAG, "The transaction or part-thereof requires a flag that wasn't set."),
|
|
MAKE_ERROR(tecPRECISION_LOSS, "The amounts used by the transaction cannot interact."),
|
|
MAKE_ERROR(tecINSUF_RESERVE_SELLER, "The seller of an object has insufficient reserves, and thus cannot complete the sale."),
|
|
MAKE_ERROR(tefALREADY, "The exact transaction was already in this ledger."),
|
|
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),
|
|
MAKE_ERROR(tefBAD_AUTH, "Transaction's public key is not authorized."),
|
|
MAKE_ERROR(tefBAD_LEDGER, "Ledger in unexpected state."),
|
|
MAKE_ERROR(tefBAD_QUORUM, "Signatures provided do not meet the quorum."),
|
|
MAKE_ERROR(tefBAD_SIGNATURE, "A signature is provided for a non-signer."),
|
|
MAKE_ERROR(tefCREATED, "Can't add an already created account."),
|
|
MAKE_ERROR(tefEXCEPTION, "Unexpected program state."),
|
|
MAKE_ERROR(tefFAILURE, "Failed to apply."),
|
|
MAKE_ERROR(tefINTERNAL, "Internal error."),
|
|
MAKE_ERROR(tefMASTER_DISABLED, "Master key is disabled."),
|
|
MAKE_ERROR(tefMAX_LEDGER, "Ledger sequence too high."),
|
|
MAKE_ERROR(tefNO_AUTH_REQUIRED, "Auth is not required."),
|
|
MAKE_ERROR(tefNOT_MULTI_SIGNING, "Account has no appropriate list of multi-signers."),
|
|
MAKE_ERROR(tefPAST_SEQ, "This sequence number has already passed."),
|
|
MAKE_ERROR(tefPAST_IMPORT_SEQ, "This import sequence number has already been used."),
|
|
MAKE_ERROR(tefPAST_IMPORT_VL_SEQ, "This import validator list sequence number has already been used."),
|
|
MAKE_ERROR(tefWRONG_PRIOR, "This previous transaction does not match."),
|
|
MAKE_ERROR(tefBAD_AUTH_MASTER, "Auth for unclaimed account needs correct master key."),
|
|
MAKE_ERROR(tefINVARIANT_FAILED, "Fee claim violated invariants for the transaction."),
|
|
MAKE_ERROR(tefTOO_BIG, "Transaction affects too many items."),
|
|
MAKE_ERROR(tefNO_TICKET, "Ticket is not in ledger."),
|
|
MAKE_ERROR(tefNFTOKEN_IS_NOT_TRANSFERABLE, "The specified NFToken is not transferable."),
|
|
MAKE_ERROR(tefNONDIR_EMIT, "An emitted txn was injected into the ledger without a corresponding directory entry."),
|
|
|
|
MAKE_ERROR(telLOCAL_ERROR, "Local failure."),
|
|
MAKE_ERROR(telBAD_DOMAIN, "Domain too long."),
|
|
MAKE_ERROR(telBAD_PATH_COUNT, "Malformed: Too many paths."),
|
|
MAKE_ERROR(telBAD_PUBLIC_KEY, "Public key is not valid."),
|
|
MAKE_ERROR(telFAILED_PROCESSING, "Failed to correctly process transaction."),
|
|
MAKE_ERROR(telINSUF_FEE_P, "Fee insufficient."),
|
|
MAKE_ERROR(telNO_DST_PARTIAL, "Partial payment to create account not allowed."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE, "Can not queue at this time."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE_BALANCE, "Can not queue at this time: insufficient balance to pay all queued fees."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE_BLOCKS, "Can not queue at this time: would block later queued transaction(s)."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE_BLOCKED, "Can not queue at this time: blocking transaction in queue."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE_FEE, "Can not queue at this time: fee insufficient to replace queued transaction."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE_FULL, "Can not queue at this time: queue is full."),
|
|
MAKE_ERROR(telWRONG_NETWORK, "Transaction specifies a Network ID that differs from that of the local node."),
|
|
MAKE_ERROR(telREQUIRES_NETWORK_ID, "Transactions submitted to this node/network must include a correct NetworkID field."),
|
|
MAKE_ERROR(telNETWORK_ID_MAKES_TX_NON_CANONICAL, "Transactions submitted to this node/network must NOT include a NetworkID field."),
|
|
MAKE_ERROR(telNON_LOCAL_EMITTED_TXN, "Emitted transaction cannot be applied because it was not generated locally."),
|
|
MAKE_ERROR(telIMPORT_VL_KEY_NOT_RECOGNISED, "Import vl key was not recognized."),
|
|
MAKE_ERROR(telCAN_NOT_QUEUE_IMPORT, "Import transaction was not able to be directly applied and cannot be queued."),
|
|
MAKE_ERROR(temMALFORMED, "Malformed transaction."),
|
|
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 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_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."),
|
|
MAKE_ERROR(temBAD_SRC_ACCOUNT, "Malformed: Bad source account."),
|
|
MAKE_ERROR(temBAD_TRANSFER_RATE, "Malformed: Transfer rate must be >= 1.0 and <= 2.0"),
|
|
MAKE_ERROR(temBAD_WEIGHT, "Malformed: Weight must be a positive value."),
|
|
MAKE_ERROR(temDST_IS_SRC, "Destination may not be source."),
|
|
MAKE_ERROR(temDST_NEEDED, "Destination not specified."),
|
|
MAKE_ERROR(temINVALID, "The transaction is ill-formed."),
|
|
MAKE_ERROR(temINVALID_FLAG, "The transaction has an invalid flag."),
|
|
MAKE_ERROR(temREDUNDANT, "The transaction is redundant."),
|
|
MAKE_ERROR(temRIPPLE_EMPTY, "PathSet with no paths."),
|
|
MAKE_ERROR(temUNCERTAIN, "In process of determining result. Never returned."),
|
|
MAKE_ERROR(temUNKNOWN, "The transaction requires logic that is not implemented yet."),
|
|
MAKE_ERROR(temDISABLED, "The transaction requires logic that is currently disabled."),
|
|
MAKE_ERROR(temBAD_TICK_SIZE, "Malformed: Tick size out of range."),
|
|
MAKE_ERROR(temINVALID_ACCOUNT_ID, "Malformed: A field contains an invalid account ID."),
|
|
MAKE_ERROR(temCANNOT_PREAUTH_SELF, "Malformed: An account may not preauthorize itself."),
|
|
MAKE_ERROR(temINVALID_COUNT, "Malformed: Count field outside valid range."),
|
|
MAKE_ERROR(temSEQ_AND_TICKET, "Transaction contains a TicketSequence and a non-zero Sequence."),
|
|
MAKE_ERROR(temBAD_NFTOKEN_TRANSFER_FEE, "Malformed: The NFToken transfer fee must be between 1 and 5000, inclusive."),
|
|
|
|
MAKE_ERROR(temHOOK_DATA_TOO_LARGE, "Malformed: The hook CreateCode field is to large to be applied to the ledger."),
|
|
MAKE_ERROR(terRETRY, "Retry transaction."),
|
|
MAKE_ERROR(terFUNDS_SPENT, "DEPRECATED."),
|
|
MAKE_ERROR(terINSUF_FEE_B, "Account balance can't pay fee."),
|
|
MAKE_ERROR(terLAST, "DEPRECATED."),
|
|
MAKE_ERROR(terNO_RIPPLE, "Path does not permit rippling."),
|
|
MAKE_ERROR(terNO_ACCOUNT, "The source account does not exist."),
|
|
MAKE_ERROR(terNO_AUTH, "Not authorized to hold IOUs."),
|
|
MAKE_ERROR(terNO_LINE, "No such line."),
|
|
MAKE_ERROR(terPRE_SEQ, "Missing/inapplicable prior transaction."),
|
|
MAKE_ERROR(terOWNERS, "Non-zero owner count."),
|
|
MAKE_ERROR(terQUEUED, "Held until escalated fee drops."),
|
|
MAKE_ERROR(terPRE_TICKET, "Ticket is not yet in ledger."),
|
|
MAKE_ERROR(terNO_HOOK, "No hook with that hash exists on the ledger."),
|
|
|
|
MAKE_ERROR(tesSUCCESS, "The transaction was applied. Only final in a validated ledger."),
|
|
MAKE_ERROR(tesPARTIAL, "The transaction was applied but should be submitted again until returning tesSUCCESS."),
|
|
};
|
|
// clang-format on
|
|
|
|
#undef MAKE_ERROR
|
|
|
|
return results;
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
bool
|
|
transResultInfo(TER code, std::string& token, std::string& text)
|
|
{
|
|
auto& results = detail::transResults();
|
|
|
|
auto const r = results.find(TERtoInt(code));
|
|
|
|
if (r == results.end())
|
|
return false;
|
|
|
|
token = r->second.first;
|
|
text = r->second.second;
|
|
return true;
|
|
}
|
|
|
|
std::string
|
|
transToken(TER code)
|
|
{
|
|
std::string token;
|
|
std::string text;
|
|
|
|
return transResultInfo(code, token, text) ? token : "-";
|
|
}
|
|
|
|
std::string
|
|
transHuman(TER code)
|
|
{
|
|
std::string token;
|
|
std::string text;
|
|
|
|
return transResultInfo(code, token, text) ? text : "-";
|
|
}
|
|
|
|
std::optional<TER>
|
|
transCode(std::string const& token)
|
|
{
|
|
static auto const results = [] {
|
|
auto& byTer = detail::transResults();
|
|
auto range = boost::make_iterator_range(byTer.begin(), byTer.end());
|
|
auto tRange = boost::adaptors::transform(range, [](auto const& r) {
|
|
return std::make_pair(r.second.first, r.first);
|
|
});
|
|
std::unordered_map<std::string, TERUnderlyingType> const byToken(
|
|
tRange.begin(), tRange.end());
|
|
return byToken;
|
|
}();
|
|
|
|
auto const r = results.find(token);
|
|
|
|
if (r == results.end())
|
|
return std::nullopt;
|
|
|
|
return TER::fromInt(r->second);
|
|
}
|
|
|
|
} // namespace ripple
|