fixed non-standard decimal point handlinig in wallets_manager::transfer()

This commit is contained in:
sowle 2024-07-06 17:15:56 +02:00
parent b547e51719
commit 0eabc7b69e
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 10 additions and 5 deletions

View file

@ -19,6 +19,7 @@
#define API_RETURN_CODE_BAD_ARG_WRONG_FEE "BAD_ARG_WRONG_FEE"
#define API_RETURN_CODE_BAD_ARG_INVALID_ADDRESS "BAD_ARG_INVALID_ADDRESS"
#define API_RETURN_CODE_BAD_ARG_WRONG_AMOUNT "BAD_ARG_WRONG_AMOUNT"
#define API_RETURN_CODE_BAD_ARG_UNKNOWN_DECIMAL_POINT "BAD_ARG_UNKNOWN_DECIMAL_POINT"
#define API_RETURN_CODE_BAD_ARG_WRONG_PAYMENT_ID "BAD_ARG_WRONG_PAYMENT_ID"
#define API_RETURN_CODE_WRONG_PASSWORD "WRONG_PASSWORD"
#define API_RETURN_CODE_WALLET_WRONG_ID "WALLET_WRONG_ID"

View file

@ -1495,11 +1495,12 @@ std::string wallets_manager::request_alias_update(const currency::alias_rpc_deta
std::string wallets_manager::transfer(uint64_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx)
{
std::vector<currency::tx_destination_entry> dsts;
if(!tp.destinations.size())
return API_RETURN_CODE_BAD_ARG_EMPTY_DESTINATIONS;
GET_WALLET_BY_ID(wallet_id, w);
uint64_t fee = tp.fee;
//payment_id
std::vector<currency::attachment_v> attachments;
@ -1538,8 +1539,13 @@ std::string wallets_manager::transfer(uint64_t wallet_id, const view::transfer_p
return API_RETURN_CODE_BAD_ARG_INVALID_ADDRESS;
}
if(!currency::parse_amount(d.amount, dsts.back().amount))
size_t decimal_point = 0;
if (!w->get()->get_asset_decimal_point(d.asset_id, &decimal_point))
{
return API_RETURN_CODE_BAD_ARG_UNKNOWN_DECIMAL_POINT;
}
if(!currency::parse_amount(d.amount, dsts.back().amount, decimal_point))
{
return API_RETURN_CODE_BAD_ARG_WRONG_AMOUNT;
}
@ -1552,8 +1558,6 @@ std::string wallets_manager::transfer(uint64_t wallet_id, const view::transfer_p
dsts.back().asset_id = d.asset_id;
}
GET_WALLET_BY_ID(wallet_id, w);
if (payment_id.size())
{
if (!currency::is_payment_id_size_ok(payment_id))