Add estimate_tx_weight

pull/91/head
Guten Ye 5 years ago
parent 2526c66094
commit 0f0c5a3050

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

@ -292,6 +292,7 @@ EMSCRIPTEN_BINDINGS(my_module)
//
emscripten::function("estimated_tx_network_fee", &estimated_tx_network_fee);
emscripten::function("estimate_fee", &estimate_fee);
emscripten::function("estimate_tx_weight", &estimate_tx_weight);
emscripten::function("estimate_rct_tx_size", &estimate_rct_tx_size);
//
emscripten::function("generate_key_image", &generate_key_image);

@ -140,6 +140,13 @@ function tests(Module)
console.timeEnd("estimate_fee")
console.log("estimate_fee ret", ret_string)
}
{
console.time("estimate_tx_weight")
const args = {"use_rct": "true", "n_inputs": "2", "mixin": "10", "n_outputs": "2","extra_size": "0", "bulletproof": "true"}
const ret_string = Module.estimate_tx_weight(JSON.stringify(args))
console.timeEnd("estimate_tx_weight")
console.log("estimate_tx_weight 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