wallet_rpc_server: new estimate_tx_size_and_weight RPC

This commit is contained in:
moneromooo-monero 2019-11-06 14:18:54 +00:00
parent a48ef0a65a
commit 0de8a0d37d
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
6 changed files with 86 additions and 0 deletions

View file

@ -4291,6 +4291,25 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_estimate_tx_size_and_weight(const wallet_rpc::COMMAND_RPC_ESTIMATE_TX_SIZE_AND_WEIGHT::request& req, wallet_rpc::COMMAND_RPC_ESTIMATE_TX_SIZE_AND_WEIGHT::response& res, epee::json_rpc::error& er, const connection_context *ctx)
{
if (!m_wallet) return not_open(er);
try
{
size_t extra_size = 34 /* pubkey */ + 10 /* encrypted payment id */; // typical makeup
const std::pair<size_t, uint64_t> sw = m_wallet->estimate_tx_size_and_weight(req.rct, req.n_inputs, req.ring_size, req.n_outputs, extra_size);
res.size = sw.first;
res.weight = sw.second;
}
catch (const std::exception &e)
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "Failed to determine size and weight";
return false;
}
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_get_version(const wallet_rpc::COMMAND_RPC_GET_VERSION::request& req, wallet_rpc::COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& er, const connection_context *ctx)
{
res.version = WALLET_RPC_VERSION;