Add estimate_fee

pull/91/head
Guten Ye 5 years ago
parent 966deb42f5
commit 2526c66094

@ -217,6 +217,16 @@ class MyMoneroCoreBridgeClass extends MyMoneroCoreBridgeEssentialsClass
mask: ret.mask,
};
}
estimate_fee(args)
{
const args_str = JSON.stringify(args);
const ret_string = this.Module.estimate_fee(args_str);
const ret = JSON.parse(ret_string);
if (typeof ret.err_msg !== 'undefined' && ret.err_msg) {
throw ret.err_msg;
}
return ret.retVal;
}
estimate_rct_tx_size(n_inputs, mixin, n_outputs, extra_size, bulletproof)
{
const args =

@ -175,6 +175,25 @@ string estimated_tx_network_fee(const string &args_string)
return serial_bridge_utils::error_ret_json_from_message(e.what());
}
}
//
string estimate_fee(const string &args_string)
{
try {
return serial_bridge::estimate_fee(args_string);
} catch (std::exception &e) {
return serial_bridge_utils::error_ret_json_from_message(e.what());
}
}
//
string estimate_tx_weight(const string &args_string)
{
try {
return serial_bridge::estimate_tx_weight(args_string);
} catch (std::exception &e) {
return serial_bridge_utils::error_ret_json_from_message(e.what());
}
}
//
string estimate_rct_tx_size(const string &args_string)
{
try {
@ -272,6 +291,7 @@ EMSCRIPTEN_BINDINGS(my_module)
emscripten::function("address_and_keys_from_seed", &address_and_keys_from_seed);
//
emscripten::function("estimated_tx_network_fee", &estimated_tx_network_fee);
emscripten::function("estimate_fee", &estimate_fee);
emscripten::function("estimate_rct_tx_size", &estimate_rct_tx_size);
//
emscripten::function("generate_key_image", &generate_key_image);

@ -133,6 +133,13 @@ function tests(Module)
console.timeEnd("estimated_tx_network_fee")
console.log("estimated_tx_network_fee ret", ret_string)
}
{
console.time("estimate_fee")
const args = {"use_per_byte_fee": "true", "use_rct": "true", "n_inputs": "2", "mixin": "10", "n_outputs": "2","extra_size": "0", "bulletproof": "true", "base_fee": "24658", "fee_quantization_mask": "10000", "priority": "2", "fork_version": "10"}
const ret_string = Module.estimate_fee(JSON.stringify(args))
console.timeEnd("estimate_fee")
console.log("estimate_fee ret", ret_string)
}
{
console.time("estimate_rct_tx_size")
const args_str = '{"n_inputs":1,"mixin":10,"n_outputs":2,"extra_size":0,"bulletproof":true}'

Loading…
Cancel
Save