mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-01 07:55:49 +00:00
deposit_authorized gives error if source not in ledger (#2640)
This commit is contained in:
@@ -93,6 +93,7 @@ enum error_code_i
|
|||||||
rpcCOMMAND_MISSING,
|
rpcCOMMAND_MISSING,
|
||||||
rpcDST_ACT_MALFORMED,
|
rpcDST_ACT_MALFORMED,
|
||||||
rpcDST_ACT_MISSING,
|
rpcDST_ACT_MISSING,
|
||||||
|
rpcDST_ACT_NOT_FOUND,
|
||||||
rpcDST_AMT_MALFORMED,
|
rpcDST_AMT_MALFORMED,
|
||||||
rpcDST_AMT_MISSING,
|
rpcDST_AMT_MISSING,
|
||||||
rpcDST_ISR_MALFORMED,
|
rpcDST_ISR_MALFORMED,
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ public:
|
|||||||
add (rpcCHANNEL_AMT_MALFORMED, "channelAmtMalformed","Payment channel amount is malformed.");
|
add (rpcCHANNEL_AMT_MALFORMED, "channelAmtMalformed","Payment channel amount is malformed.");
|
||||||
add (rpcCOMMAND_MISSING, "commandMissing", "Missing command entry.");
|
add (rpcCOMMAND_MISSING, "commandMissing", "Missing command entry.");
|
||||||
add (rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed.");
|
add (rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed.");
|
||||||
add (rpcDST_ACT_MISSING, "dstActMissing", "Destination account does not exist.");
|
add (rpcDST_ACT_MISSING, "dstActMissing", "Destination account not provided.");
|
||||||
|
add (rpcDST_ACT_NOT_FOUND, "dstActNotFound", "Destination account not found.");
|
||||||
add (rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency/issuer is malformed.");
|
add (rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency/issuer is malformed.");
|
||||||
add (rpcDST_ISR_MALFORMED, "dstIsrMalformed", "Destination issuer is malformed.");
|
add (rpcDST_ISR_MALFORMED, "dstIsrMalformed", "Destination issuer is malformed.");
|
||||||
add (rpcFORBIDDEN, "forbidden", "Bad credentials.");
|
add (rpcFORBIDDEN, "forbidden", "Bad credentials.");
|
||||||
|
|||||||
@@ -77,11 +77,18 @@ Json::Value doDepositAuthorized (RPC::Context& context)
|
|||||||
if (!ledger)
|
if (!ledger)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
// If source account is not in the ledger it can't be authorized.
|
||||||
|
if (! ledger->exists (keylet::account(srcAcct)))
|
||||||
|
{
|
||||||
|
RPC::inject_error (rpcSRC_ACT_NOT_FOUND, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// If destination account is not in the ledger you can't deposit to it, eh?
|
// If destination account is not in the ledger you can't deposit to it, eh?
|
||||||
auto const sleDest = ledger->read (keylet::account(dstAcct));
|
auto const sleDest = ledger->read (keylet::account(dstAcct));
|
||||||
if (! sleDest)
|
if (! sleDest)
|
||||||
{
|
{
|
||||||
RPC::inject_error (rpcDST_ACT_MISSING, result);
|
RPC::inject_error (rpcDST_ACT_NOT_FOUND, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,13 +197,23 @@ public:
|
|||||||
"json", "deposit_authorized", args.toStyledString())};
|
"json", "deposit_authorized", args.toStyledString())};
|
||||||
verifyErr (result, "lgrNotFound", "ledgerNotFound");
|
verifyErr (result, "lgrNotFound", "ledgerNotFound");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// alice is not yet funded.
|
||||||
|
Json::Value args {depositAuthArgs (alice, becky)};
|
||||||
|
Json::Value const result {env.rpc (
|
||||||
|
"json", "deposit_authorized", args.toStyledString())};
|
||||||
|
verifyErr (result, "srcActNotFound",
|
||||||
|
"Source account not found.");
|
||||||
|
}
|
||||||
|
env.fund(XRP(1000), alice);
|
||||||
|
env.close();
|
||||||
{
|
{
|
||||||
// becky is not yet funded.
|
// becky is not yet funded.
|
||||||
Json::Value args {depositAuthArgs (alice, becky)};
|
Json::Value args {depositAuthArgs (alice, becky)};
|
||||||
Json::Value const result {env.rpc (
|
Json::Value const result {env.rpc (
|
||||||
"json", "deposit_authorized", args.toStyledString())};
|
"json", "deposit_authorized", args.toStyledString())};
|
||||||
verifyErr (result, "dstActMissing",
|
verifyErr (result, "dstActNotFound",
|
||||||
"Destination account does not exist.");
|
"Destination account not found.");
|
||||||
}
|
}
|
||||||
env.fund(XRP(1000), becky);
|
env.fund(XRP(1000), becky);
|
||||||
env.close();
|
env.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user