mirror of
https://github.com/Xahau/xahaud.git
synced 2026-07-24 07:30:10 +00:00
Using the "Amount" field in Payment transactions can cause incorrect interpretation. There continue to be problems from the use of this field. "Amount" is rarely the correct field to use; instead, "delivered_amount" (or "DeliveredAmount") should be used. Rename the "Amount" field to "DeliverMax", a less misleading name. With api_version: 2, remove the "Amount" field from Payment transactions. - Input: "DeliverMax" in `tx_json` is an alias for "Amount" - sign - submit (in sign-and-submit mode) - submit_multisigned - sign_for - Output: Add "DeliverMax" where transactions are provided by the API - ledger - tx - tx_history - account_tx - transaction_entry - subscribe (transactions stream) - Output: Remove "Amount" from API version 2 Fix #3484 Fix #3902
89 lines
2.9 KiB
C++
89 lines
2.9 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012-2014 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/app/main/Application.h>
|
|
#include <ripple/app/misc/DeliverMax.h>
|
|
#include <ripple/ledger/ReadView.h>
|
|
#include <ripple/protocol/jss.h>
|
|
#include <ripple/rpc/Context.h>
|
|
#include <ripple/rpc/impl/RPCHelpers.h>
|
|
|
|
namespace ripple {
|
|
|
|
// {
|
|
// ledger_hash : <ledger>,
|
|
// ledger_index : <ledger_index>
|
|
// }
|
|
//
|
|
// XXX In this case, not specify either ledger does not mean ledger current. It
|
|
// means any ledger.
|
|
Json::Value
|
|
doTransactionEntry(RPC::JsonContext& context)
|
|
{
|
|
std::shared_ptr<ReadView const> lpLedger;
|
|
Json::Value jvResult = RPC::lookupLedger(lpLedger, context);
|
|
|
|
if (!lpLedger)
|
|
return jvResult;
|
|
|
|
if (!context.params.isMember(jss::tx_hash))
|
|
{
|
|
jvResult[jss::error] = "fieldNotFoundTransaction";
|
|
}
|
|
else if (jvResult.get(jss::ledger_hash, Json::nullValue).isNull())
|
|
{
|
|
// We don't work on ledger current.
|
|
|
|
// XXX We don't support any transaction yet.
|
|
jvResult[jss::error] = "notYetImplemented";
|
|
}
|
|
else
|
|
{
|
|
uint256 uTransID;
|
|
// XXX Relying on trusted WSS client. Would be better to have a strict
|
|
// routine, returning success or failure.
|
|
if (!uTransID.parseHex(context.params[jss::tx_hash].asString()))
|
|
{
|
|
jvResult[jss::error] = "malformedRequest";
|
|
return jvResult;
|
|
}
|
|
|
|
auto [sttx, stobj] = lpLedger->txRead(uTransID);
|
|
if (!sttx)
|
|
{
|
|
jvResult[jss::error] = "transactionNotFound";
|
|
}
|
|
else
|
|
{
|
|
jvResult[jss::tx_json] = sttx->getJson(JsonOptions::none);
|
|
RPC::insertDeliverMax(
|
|
jvResult[jss::tx_json], sttx->getTxnType(), context.apiVersion);
|
|
if (stobj)
|
|
jvResult[jss::metadata] = stobj->getJson(JsonOptions::none);
|
|
// 'accounts'
|
|
// 'engine_...'
|
|
// 'ledger_...'
|
|
}
|
|
}
|
|
|
|
return jvResult;
|
|
}
|
|
|
|
} // namespace ripple
|