mirror of
https://github.com/monero-project/monero.git
synced 2025-08-09 00:32:22 -04:00
wallet_rpc_server: new estimate_tx_size_and_weight RPC
This commit is contained in:
parent
a48ef0a65a
commit
0de8a0d37d
6 changed files with 86 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue