// Copyright (c) 2014-2018, MyMonero.com
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"use strict" ;
//
function tests ( Module )
{
console . log ( "Module is of type:" , typeof Module )
{
console . time ( "send_step2__try_create_transaction" )
const args _str = '{"final_total_wo_fee":"200000000","change_amount":"2733719296","fee_amount":"66280704","using_outs":[{"amount":"3000000000","public_key":"41be1978f58cabf69a9bed5b6cb3c8d588621ef9b67602328da42a213ee42271","rct":"86a2c9f1f8e66848cd99bfda7a14d4ac6c3525d06947e21e4e55fe42a368507eb5b234ccdd70beca8b1fc8de4f2ceb1374e0f1fd8810849e7f11316c2cc063060008ffa5ac9827b776993468df21af8c963d12148622354f950cbe1369a92a0c","global_index":"7611174","index":"1","tx_pub_key":"bd703d7f37995cc7071fb4d2929594b5e2a4c27d2b7c68a9064500ca7bc638b8"}],"payment_id_string":"d2f602b240fbe624","nettype_string":"MAINNET","to_address_string":"4APbcAKxZ2KPVPMnqa5cPtJK25tr7maE7LrJe67vzumiCtWwjDBvYnHZr18wFexJpih71Mxsjv8b7EpQftpB9NjPPXmZxHN","from_address_string":"43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg","sec_viewKey_string":"7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104","sec_spendKey_string":"4e6d43cd03812b803c6f3206689f5fcc910005fc7e91d50d79b0776dbefcd803","fee_per_b":"24658","fee_mask":"10000","fork_version":"10","unlock_time":"0","priority":"1","mix_outs":[{"amount":"0","outputs":[{"global_index":"7453099","public_key":"31f3a7fec0f6f09067e826b6c2904fd4b1684d7893dcf08c5b5d22e317e148bb","rct":"ea6bcb193a25ce2787dd6abaaeef1ee0c924b323c6a5873db1406261e86145fc"},{"global_index":"7500097","public_key":"f9d923500671da05a1bf44b932b872f0c4a3c88e6b3d4bf774c8be915e25f42b","rct":"dcae4267a6c382bcd71fd1af4d2cbceb3749d576d7a3acc473dd579ea9231a52"},{"global_index":"7548483","public_key":"839cbbb73685654b93e824c4843e745e8d5f7742e83494932307bf300641c480","rct":"aa99d492f1d6f1b20dcd95b8fff8f67a219043d0d94b4551759016b4888573e7"},{"global_index":"7554755","public_key":"b8860f0697988c8cefd7b4285fbb8bec463f136c2b9a9cadb3e57cebee10717f","rct":"327f9b07bee9c4c25b5a990123cd2444228e5704ebe32016cd632866710279b5"},{"global_index":"7561477","public_key":"561d734cb90bc4a64d49d37f85ea85575243e2ed749a3d6dcb4d27aa6bec6e88","rct":"b5393e038df95b94bfda62b44a29141cac9e356127270af97193460d51949841"},{"global_index":"7567062","public_key":"db1024ef67e7e73608ef8afab62f49e2402c8da3dc3197008e3ba720ad3c94a8","rct":"1fedf95621881b77f823a70aa83ece26aef62974976d2b8cd87ed4862a4ec92c"},{"global_index":"7567508","public_key":"6283f3cd2f050bba90276443fe04f6076ad2ad46a515bf07b84d424a3ba43d27","rct":"10e16bb8a8b7b0c8a4b193467b010976b962809c9f3e6c047335dba09daa351f"},{"global_index":"7568716","public_key":"7a7deb4eef81c1f5ce9cbd0552891cb19f1014a03a5863d549630824c7c7c0d3","rct":"735d059dc3526334ac705ddc44c4316bb8805d2426dcea9544cde50cf6c7a850"},{"global_index":"7571196","public_key":"535208e354cae530ed7ce752935e555d630cf2edd7f91525024ed9c332b2a347","rct":"c3cf838faa14e993536c5581ca582fb0d96b70f713cf88f7f15c89336e5853ec"},{"global_index":"7571333","public_key":"e73f27b7eb001aa7eac13df82814cda65b42ceeb6ef36227c25d5cbf82f6a5e4","rct":"5f45f33c6800cdae202b37abe6d87b53d6873e7b30f3527161f44fa8db3104b6"},{"global_index":"7571335","public_key":"fce982db8e7a6b71a1e632c7de8c5cbf54e8bacdfbf250f1ffc2a8d2f7055ce3","rct":"407bdcc48e70eb3ef2cc22cefee6c6b5a3c59fd17bde12fda5f1a44a0fb39d14"}]}]}'
const ret _string = Module . send _step2 _ _try _create _transaction ( args _str )
console . log ( "send_step2__try_create_transaction ret" , ret _string )
console . timeEnd ( "send_step2__try_create_transaction" )
}
{
console . time ( "decode_address" )
const args =
{
"address" : "43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg" ,
"nettype_string" : "MAINNET"
}
const ret _string = Module . decode _address ( JSON . stringify ( args ) )
console . timeEnd ( "decode_address" )
console . log ( "decode_address ret" , ret _string )
}
{
console . time ( "is_subaddress" )
const args _str = '{"nettype_string":"MAINNET","address":"4L6Gcy9TAHqPVPMnqa5cPtJK25tr7maE7LrJe67vzumiCtWwjDBvYnHZr18wFexJpih71Mxsjv8b7EpQftpB9NjPaL41VrjstLM5WevLZx"}'
const ret _string = Module . is _subaddress ( args _str )
console . timeEnd ( "is_subaddress" )
console . log ( "is_subaddress ret" , ret _string )
}
{
console . time ( "is_integrated_address" )
const args _str = '{"nettype_string":"MAINNET","address":"4L6Gcy9TAHqPVPMnqa5cPtJK25tr7maE7LrJe67vzumiCtWwjDBvYnHZr18wFexJpih71Mxsjv8b7EpQftpB9NjPaL41VrjstLM5WevLZx"}'
const ret _string = Module . is _integrated _address ( args _str )
console . timeEnd ( "is_integrated_address" )
console . log ( "is_integrated_address ret" , ret _string )
}
{
console . time ( "new_integrated_address" )
const args _str = '{"nettype_string":"MAINNET","address":"43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg","short_pid":"b79f8efc81f58f67"}'
const ret _string = Module . new _integrated _address ( args _str )
console . timeEnd ( "new_integrated_address" )
console . log ( "new_integrated_address ret" , ret _string )
}
{
console . time ( "new_payment_id" )
const args _str = '{}'
const ret _string = Module . new _payment _id ( args _str )
console . timeEnd ( "new_payment_id" )
console . log ( "new_payment_id ret" , ret _string )
}
{
console . time ( "newly_created_wallet" )
const args _str = '{"nettype_string":"MAINNET","locale_language_code":"en-US"}'
const ret _string = Module . newly _created _wallet ( args _str )
console . timeEnd ( "newly_created_wallet" )
console . log ( "newly_created_wallet ret" , ret _string )
}
{
console . time ( "are_equal_mnemonics" )
const args _str = '{"a":"foxe selfish hum nexus juven dodeg pepp ember biscuti elap jazz vibrate biscui","b":"fox sel hum nex juv dod pep emb bis ela jaz vib bis"}'
const ret _string = Module . are _equal _mnemonics ( args _str )
console . timeEnd ( "are_equal_mnemonics" )
console . log ( "are_equal_mnemonics ret" , ret _string )
}
{
console . time ( "mnemonic_from_seed" )
const args _str = '{"seed_string":"9c973aa296b79bbf452781dd3d32ad7f","wordset_name":"English"}'
const ret _string = Module . mnemonic _from _seed ( args _str )
console . timeEnd ( "mnemonic_from_seed" )
console . log ( "mnemonic_from_seed ret" , ret _string )
}
{
console . time ( "seed_and_keys_from_mnemonic" )
const args _str = '{"mnemonic_string":"foxe selfish hum nexus juven dodeg pepp ember biscuti elap jazz vibrate biscui","nettype_string":"MAINNET"}'
const ret _string = Module . seed _and _keys _from _mnemonic ( args _str )
console . timeEnd ( "seed_and_keys_from_mnemonic" )
console . log ( "seed_and_keys_from_mnemonic ret" , ret _string )
}
{
console . time ( "validate_components_for_login w seed" )
const args _str = '{"address_string":"43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg","sec_viewKey_string":"7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104","sec_spendKey_string":"4e6d43cd03812b803c6f3206689f5fcc910005fc7e91d50d79b0776dbefcd803","seed_string":"9c973aa296b79bbf452781dd3d32ad7f","nettype_string":"MAINNET"}'
const ret _string = Module . validate _components _for _login ( args _str )
console . timeEnd ( "validate_components_for_login w seed" )
console . log ( "validate_components_for_login w seed ret" , ret _string )
}
{
console . time ( "validate_components_for_login w both keys" )
const args _str = '{"address_string":"43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg","sec_viewKey_string":"7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104","sec_spendKey_string":"4e6d43cd03812b803c6f3206689f5fcc910005fc7e91d50d79b0776dbefcd803","nettype_string":"MAINNET"}'
const ret _string = Module . validate _components _for _login ( args _str )
console . timeEnd ( "validate_components_for_login w both keys" )
console . log ( "validate_components_for_login w both keys ret" , ret _string )
}
{
console . time ( "validate_components_for_login view only" )
const args _str = '{"address_string":"43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg","sec_viewKey_string":"7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104","nettype_string":"MAINNET"}'
const ret _string = Module . validate _components _for _login ( args _str )
console . timeEnd ( "validate_components_for_login view only" )
console . log ( "validate_components_for_login view only ret" , ret _string )
}
{
console . time ( "address_and_keys_from_seed" )
const args _str = '{"seed_string":"9c973aa296b79bbf452781dd3d32ad7f","nettype_string":"MAINNET"}'
const ret _string = Module . address _and _keys _from _seed ( args _str )
console . timeEnd ( "address_and_keys_from_seed" )
console . log ( "address_and_keys_from_seed ret" , ret _string )
}
{
console . time ( "estimated_tx_network_fee" )
const args _str = '{"fee_per_b":"24658","priority":"1"}'
const ret _string = Module . estimated _tx _network _fee ( args _str )
console . timeEnd ( "estimated_tx_network_fee" )
console . log ( "estimated_tx_network_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}'
const ret _string = Module . estimate _rct _tx _size ( args _str )
console . timeEnd ( "estimate_rct_tx_size" )
console . log ( "estimate_rct_tx_size ret" , ret _string )
}
{
console . time ( "generate_key_image" )
const args _str = '{"sec_viewKey_string":"7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104","sec_spendKey_string":"4e6d43cd03812b803c6f3206689f5fcc910005fc7e91d50d79b0776dbefcd803","pub_spendKey_string":"3eb884d3440d71326e27cc07a861b873e72abd339feb654660c36a008a0028b3","tx_pub_key":"fc7f85bf64c6e4f6aa612dbc8ddb1bb77a9283656e9c2b9e777c9519798622b2","out_index":"0"}'
const ret _string = Module . generate _key _image ( args _str )
console . timeEnd ( "generate_key_image" )
console . log ( "generate_key_image ret" , ret _string )
}
{
console . time ( "generate_key_derivation" )
const args _str = '{"pub":"904e49462268d771cc1649084c35aa1296bfb214880fe2e7f373620a3e2ba597","sec":"52aa4c69b93b780885c9d7f51e6fd5795904962c61a2e07437e130784846f70d"}'
const ret _string = Module . generate _key _derivation ( args _str )
console . timeEnd ( "generate_key_derivation" )
console . log ( "generate_key_derivation ret" , ret _string )
}
{
console . time ( "derive_public_key" )
const args _str = '{"derivation":"591c749f1868c58f37ec3d2a9d2f08e7f98417ac4f8131e3a57c1fd71273ad00","out_index":"1","pub":"904e49462268d771cc1649084c35aa1296bfb214880fe2e7f373620a3e2ba597"}'
const ret _string = Module . derive _public _key ( args _str )
console . timeEnd ( "derive_public_key" )
console . log ( "derive_public_key ret" , ret _string )
}
{
console . time ( "derive_subaddress_public_key" )
const args _str = '{"derivation":"591c749f1868c58f37ec3d2a9d2f08e7f98417ac4f8131e3a57c1fd71273ad00","out_index":"1","output_key":"904e49462268d771cc1649084c35aa1296bfb214880fe2e7f373620a3e2ba597"}'
const ret _string = Module . derive _subaddress _public _key ( args _str )
console . timeEnd ( "derive_subaddress_public_key" )
console . log ( "derive_subaddress_public_key ret" , ret _string )
}
{
console . time ( "derivation_to_scalar" )
const args _str = '{"derivation":"7a4c13a037d4bd2a7dd99a8c24669e9e04ca4e8a90e5b6703e88e87ad51c1849","output_index":1}'
const ret _string = Module . derivation _to _scalar ( args _str )
console . timeEnd ( "derivation_to_scalar" )
console . log ( "derivation_to_scalar ret" , ret _string )
}
{
console . time ( "decodeRct" )
const args _str = '{"i":"1","sk":"9b1529acb638f497d05677d7505d354b4ba6bc95484008f6362f93160ef3e503","rv":{"type":"1","ecdhInfo":[{"mask":"3ad9d0b3398691b94558e0f750e07e5e0d7d12411cd70b3841159e6c6b10db02","amount":"b3189d8adb5a26568e497eb8e376a7d7d946ebb1daef4c2c87a2c30b65915506"},{"mask":"97b00af8ecba3cb71b9660cc9e1ac110abd21a4c5e50a2c125f964caa96bef0c","amount":"60269d8adb5a26568e497eb8e376a7d7d946ebb1daef4c2c87a2c30b65915506"},{"mask":"db67f5066d9455db404aeaf435ad948bc9f27344bc743e3a32583a9e6695cb08","amount":"b3189d8adb5a26568e497eb8e376a7d7d946ebb1daef4c2c87a2c30b65915506"}],"outPk":[{"mask":"9adc531a9c79a49a4257f24e5e5ea49c2fc1fb4eef49e00d5e5aba6cb6963a7d"},{"mask":"89f40499d6786a4027a24d6674d0940146fd12d8bc6007d338f19f05040e7a41"},{"mask":"f413d28bd5ffdc020528bcb2c19919d7484fbc9c3dd30de34ecff5b8a904e7f6"}]}}'
const ret _string = Module . decodeRct ( args _str )
console . timeEnd ( "decodeRct" )
console . log ( "decodeRct ret" , ret _string )
}
{
console . time ( "decodeRctSimple" )
const args _str = '{"i":"0","sk":"a2259749f7aad692e000af4b7f383f4441ba4085bf70e518081365750db73b06","rv":{"type":"3","ecdhInfo":[{"mask":"dc9a2e8a66a336f67bb1a150f6de4522f09c451a10f450d7ee096baa75660a05","amount":"0c8f7514fd1d7c4f49795f33254739ce8e96275b17f50a03c877ed4b56896601"},{"mask":"f0d94c21aa892ad4e0d492f5fce4b8e99ff5e1ed687134b9419a2290e8701004","amount":"dbaeca613d37b53ff0a22a1fb6e09150baa6f4f5f6e145ef78a78cc19624a702"}],"outPk":[{"mask":"4dd9e7e2a2d8f31f065562923079399ec6c90d4b155d289208001994815bd01f"},{"mask":"c23cdb07e56bcb6a9ad087122b7079f2c34e217bcbddd16ca6031ab8828f7a84"}]}}'
const ret _string = Module . decodeRctSimple ( args _str )
console . timeEnd ( "decodeRctSimple" )
console . log ( "decodeRctSimple ret" , ret _string )
}
{
console . time ( "send_funds" )
const task _id = "something unique" ;
//
Module . fromCpp _ _send _funds _ _get _unspent _outs = function ( task _id , req _params )
{
console . log ( "fromCpp__send_funds__get_unspent_outs" , task _id , req _params )
const args = {
task _id : task _id ,
// err_msg: "here's a test error", // errors must be sent back so that C++ can free heap vals container
res : { "per_kb_fee" : 24450000 , "amount" : "4911514979789" , "outputs" : [ { "amount" : "400000000000" , "public_key" : "cfdbedf495dc30be82d4934b72af8b1af98b4a35faf984f2c16e4866f45330ae" , "index" : 0 , "global_index" : 660333 , "rct" : "40dd3f5c6c1ff8fe353cb08881c182c29ff7d9ab0055ef36f54514db7e894ef17b1117f21a7ec92dae74f07a6dfdf791eb6d8946615c16ea38ab5a0fb0538d056eb5f5bcd5cccb8b91744845d4f3486eaa9e7d9d2ac51f7364628abf44150100" , "tx_id" : 2455631 , "tx_hash" : "354d9874b7b13befcf8f079520ad72b78dc62de6081765ce5490345c7623d41a" , "tx_pub_key" : "fc7f85bf64c6e4f6aa612dbc8ddb1bb77a9283656e9c2b9e777c9519798622b2" , "tx_prefix_hash" : "4448cbd20af2f4f14286707cc35b742e5eaf184037317017794d003457d720e2" , "spend_key_images" : [ "ae30ee23051dc0bdf10303fbd3b7d8035a958079eb66516b1740f2c9b02c804e" , "3eb5bdbf119de8b0fea2b52e2c63ebfd2be152713326f7e0acb9c996a9007611" , "3c8ee840913cb4163f5b705aeb1da0b9b234be67cb61abf21c6648f40964479f" , "72fb0972751bfbcdd3ba62114d4371a25d54cf0e4c6c8ecb5bc0e3af1fafadab" , "810aca616598c564ca856330a3677592a5390bdddadf3e82d1563731dd2eef3c" , "423b9e89ed014f453eed8e914d7d8e77ca9f75805e5251750c35b09120b38755" , "dde80dee4ed041ffc2d85c020509fbd568e0ce440b9a12a3268ffe5490d027f8" ] , "timestamp" : "2018-11-14T19:31:53Z" , "height" : 1293044 } , { "amount" : "364000000000" , "public_key" : "583ee3787e11559d0440a2edbdc8ec993f68913a234875d2df401f7726c1dad5" , "index" : 1 , "global_index" : 664673 , "rct" : "98caf1149c4bfdac3603df8649721074aeb36d072a78dedc00c23ad9037ff4b89716ecc91c27637dde21492c6820dbbd4d7be5cc6a1e0ddbb6750a6802f042083f5ebc5807837be21951cf833674a7ea8896661cf6eaa45c0736ffc5fb88fd0a" , "tx_id" : 2457238 , "tx_hash" : "a727cbcf59cc35f07066b314b53bc6239c4129f60e9ba1c7a8d5591b7a0b3055" , "tx_pub_key" : "74b6ba3dd36a85e6e9b5fe4fc093c1e57ec0dc52cbac5e487a2b7a8da091893d" , "tx_prefix_hash" : "e6d3a3cf89fa01b093abaeff0085919331ca9cfdadeccfa58ed0d8de528b29ae" , "spend_key_images" : [ "673ca2516ebb41d612692f3223c367457f685e92c3b6556b28630f9231bf5f54" , "169baea6bc976ef3bd689e8e810d5d33ca80e2cea6ef28903db324b975a2156b" , "e848a44a4aefea9d0870bc96d87707e0bf123f311682f252481bbe553e1a91ed" , "5ddeb3b324094dec2a7ad6091937370c847c870c9abd730ee86062f8a4a93b24" , "033f1c75e5c5682725f392dc722a14aa28aa6bb05823277065a09e4dd5005881" , "dbb8e201a3635adf1cddfcd7053eb4d5c3e38afbb41f6cd1311bcf98adda1700" ] , "timestamp" : "2018-11-14T19:31:53Z" , "height" : 1293420 } , { "amount" : "238000000000" , "public_key" : "fa933b1558dab5303b3e8cb58bf936138bf480bae78c16ca258ab10408d88ccf" , "index" : 1 , "global_index" : 666623 , "rct" : "95f97e430358a5f163b5c26e11a3306bbe9b27275daecc0f013426db9041c00e55efd221fbb8fd0b49c85184b968f2a342c1d09d853272f497da357d78f68d02d4f4b44284ee0468ffa8a05739a2cfd292958e8fdc01d5eaa789d4c9689e3204" , "tx_id" : 2457958 , "tx_hash" : "cfeef2b05585a781f9310dc0e4d46ab1e9d052cfce11bfd0a58b2b519d20ff49" , "tx_pub_key" : "4296d3473870305a732a7bc6a9290f0ec3ced426312ac75501a4211d4ef04c58" , "tx_prefix_hash" : "3cbdd08ac6ac67738f871eb254fced02559937c148cd848a616ea5bca9e71e76" , "spend_key_images" : [ "3bf1610dc8e8dbf16d28400b3bd8c0cc4e673b79152593cc709f88b7b12892d5" , "ab99d869af5ba68c806e0a8ce2cc1ae2f9b8cf8166162c01523641de5cc1df6b" , "602b8b4b6c9aa86d9b2ace0b1bfdf9f4b3721650304bf5e79fd0f08ac6b8c363" , "bda71e2b0b7c501e46e0c4489d1a1f167e1e46c472e78ad7f093d5e52daa386a" , "a4ccce434fb8d0ec049ab1faf615e965e5024fdd36ff35c856f2cacec34461c0" ] , "timestamp" : "2018-11-14T19:31:53Z" , "height" : 1293554 } , { "amount" : "202000000000" , "public_key" : "2ee8b8b5a2201ef17bdd4112cdd80242dcaab30826b87206973c8347c8ffa4dc" , "index" : 1 , "global_index" : 689429 , "rct" : "14051b217814eae62febf95e9ee0fa92f5aa7714b1a05ca89ae096494ff81eeee416437476f845c0b2891e9f1d4ef25c283eebd72dbd532463de0b7b74b2b604b29478a9ea4c16d01e67716a8b9d29cb9f49703a15b16f37b73f9e5a2bf2230d" , "tx_id" : 2466863 , "tx_hash" : "26966c9217160117dc465e959be39264b84819d9875cecc6c8a63c26c7bfc3a3" , "tx_pub_key" : "4ff9f870ac27c8f91a8e87d678304801155242c71832dff41a1b64fa8f1fb486" , "tx_prefix_hash" : "e4cd3a2ea71bd7c63d8958785c98337bff59dbfda2f8a7f76868e3c9f3d38f84" , "spend_key_images" : [ "c968adaa4c2323409cecfb6c9b170b86e9c1e5edee8ee60a879a949b892eef4b" , "f6331c40c29efb0adab369f9d6e91dbc74afc19994efb62ae4d93be7fdd82551" , " 68462 abf8bb0b84232694b5fc4bbc2e61af9c5a45c5b5a4d184c5a2dbde2e710
} ;
setTimeout ( function ( ) {
Module . send _cb _I _ _got _unspent _outs ( JSON . stringify ( args ) )
} )
}
Module . fromCpp _ _send _funds _ _get _random _outs = function ( task _id , req _params )
{
console . log ( "fromCpp__send_funds__get_random_outs" , task _id , req _params )
const args = {
task _id : task _id ,
// err_msg: "here's a test error", // errors must be sent back so that C++ can free heap vals container
res : { "amount_outs" : [ { "amount" : "0" , "outputs" : [ { "global_index" : "6478600" , "public_key" : "1a51a97c32b92ee16bcbdefcd572f36610cd76823a44528a96ff0d024e2a6b6d" , "rct" : "3c3a83bedf703b50da3ea1f001a794a03e36199c8289e80dbf4834c0b32d8bd5" } , { "global_index" : "7387285" , "public_key" : "6fdaa719986cf4b1f0c0ab057796c8d292c51e2c6f4fa988a8f85517b3d0d3df" , "rct" : "52a20ff6e02c18c10a7b91de3ce94f36de3287e4e77400fc140032184ff30dfe" } , { "global_index" : "7680334" , "public_key" : "c8de7e6b67ab6e4033590ab423382b9d9c290b3be037360637b3c050a75e9280" , "rct" : "83ed23ab140d68a712782ee39494d7f691d6afe44782e818af7292bdb51f4db8" } , { "global_index" : "7722664" , "public_key" : "8f7e355241f03105faf475f3070b11ef1b0cdecabf165c39a92564c32d09756f" , "rct" : "f43c2a397de781d18a9b0b242265263cb2ed26fb40cc9fac1228e2434ddc866f" } , { "global_index" : "7829810" , "public_key" : "ffffb90a2fa4a30eab0dc89d0fe7fbdbe95055b49001fc163756dca8982163d0" , "rct" : "ef12dd0adc8aa6051c18f9846900bb279f8c9e9b97930a8aae37911e30a7aedd" } , { "global_index" : "7861666" , "public_key" : "bf243c7511088ca6065b71bbe47c69056e1517b159d659c5b82f0c7f841259a4" , "rct" : "b8a348ed838b7bf556827745b7ef71c7fef2cbe4c2b83c67f5eb903e081c23c3" } , { "global_index" : "7866897" , "public_key" : "18df6f38df05eb1cae8119073fdcc3cc09fc79b3ec4baaa3bb3cc63d93e76d82" , "rct" : "927d87944cfb827033c685d05d907c4455f662d64efd397566799f7aa8006cb9" } , { "global_index" : "7867193" , "public_key" : "d1ad81ab293058a548f5b168e5ddadb1447c7b7914031053149eb53973be3620" , "rct" : "0160dd071e3859deefa289d27e996e356169f90985d75006741b6a36c71c38da" } , { "global_index" : "7876522" , "public_key" : "f46ee44b2ef816e7427a9bce0964b07592c86e23429a1c20602e64bcf0139bae" , "rct" : "8b1ffcdd2e86e5207672233a9cb30d2b8729fac1cb9f326023ffa65db4e09bdf" } , { "global_index" : "7885794" , "public_key" : "bc6e9dfe5354fbee384fdb11e23b3a244228027b85af52eac4362438bcd20e23" , "rct" : "f59c663f7d415dfbf6459ae7337c29b9f81ae1f7ffdf3b4f452611ea9b838d8c" } , { "global_index" : "7826288" , "public_key" : "bcdf302f813eb0d1f10046538e6d226344197a12f1f2b54e2f095ca234799818" , "rct" : "76d3bc9e1147252be5a4bd45f4552427e93ead62b69be93f1bfb73645d4b94fb" } ] } , { "amount" : "0" , "outputs" : [ { "global_index" : "7572314" , "public_key" : "0477758ef7a78fb0c99cbb2a0f9faa4c85e1ee8b99cd9ffb102a539e570b3b44" , "rct" : "34e6aaa6f3aeb45df8dc74e626cc0845e3db6f5f9bd59506cc1fee7e7dddffbe" } , { "global_index" : "7772070" , "public_key" : "e74d40544df0746c613a854f6401b544999ce4242eb1718b5e1ab7ca3ecda08d" , "rct" : "a827403583c7283c05cb3db3ec2930ed14684afa4b5b906b63a71d19e2cc2ad2" } , { "global_index" : "7783300" , "public_key" : "c2416f761ce191530bc84253fea43cf83e3fb7d03cfd5befdcf84aeed8cde2bd" , "rct" : "2498a64a44d6b1dd6ae87e66bb9cf51e9a46f93a964c9645e7316cf5ded3761e" } , { "global_index" : "7835881" , "public_key" : "3878b4d45c1fdb9afc8d177e427fad6b6609cc1382efeec9138e4e759baee6a4" , "rct" : "2ea2bab06178288253ec4d46f3d16d419d7f9cbfa2d4d8b7586a2e044c14f87d" } , { "global_index" : "7845569" , "public_key" : "bf78585e53b21925dfff9462e0928479f3892cd98b991f5973a85ddff1b63267" , "rct" : "dc539fbee461867eada54ee4c46becdc505e4f79a0c9c2d5e6587ca9e8bd10da" } , { "global_index" : "7877601" , "public_key" : "939b7fca3c60bd00e63328daffc51bfc6f9d85cb402c9e740a7773a84f98957d" , "rct" : "a2f921124806ac9204a1a06afbaedcb305a26b01027ab381292ffe4074c40022" } , { "global_index" : "7883058" , "public_key" : "977f6e676a84a91d5120a534ec531ed22b1d60725da8d5a32628aa753b0eebb7" , "rct" : "fbf474120aac8003388b2af9706ae2502a1fee6b1bd692776b5b9d1aa2b3a977" } , { "global_index" : "7884736" , "public_key" : "3fe000a8d5b63150c38f0ebf9995848a3f7e86470efeb9eee0e89817b2d90f7c" , "rct" : "d0d85fc88b015dfb2c056d36a43bb7a6858c9b67a1062096964e5e935aa2854f" } , { "global_index" : "7885562" , "public_key" : "d361e28435b72229dd3d532c60df465a84a478d495226915ed959d12e75f6fa2" , "rct" : "b55ad4ed092a446da60ddb2edd6ab287a05cc329b580c7c99ec46327378dbe86" } , { "global_index" : "7886354" , "public_key" : "918ff14531d53b667b361ff1a5a04f6cc5eaa90f4053cbef99e060841516cbbd" , "rct" : "f3b7251a54f186d43c563df7a0fb4b47a15d5ed49ed1f869efe09bf295dfd030" } , { "global_index" : "7531500" , "public_key" : "85ffad7f0cd7ab3eb0ee32a7395342ce5341ba7bc0f42566af4a3b915029647f" , "rct" : "a8bd4bae14ffbb80ac3f4eecc3133113a157f743be565dafc10b039311ec5308" } ] } , { "amount" : "0" , "outputs" : [ { "global_index" : "6299870" , " publ
} ;
setTimeout ( function ( ) {
Module . send _cb _II _ _got _random _outs ( JSON . stringify ( args ) )
} )
}
Module . fromCpp _ _send _funds _ _submit _raw _tx = function ( task _id , req _params )
{
console . log ( "fromCpp__send_funds__submit_raw_tx" , task _id , req _params )
const args = {
task _id : task _id ,
// err_msg: "here's a test error", // errors must be sent back so that C++ can free heap vals container
res : { }
} ;
setTimeout ( function ( ) {
Module . send _cb _III _ _submitted _tx ( JSON . stringify ( args ) )
} )
}
Module . fromCpp _ _send _funds _ _status _update = function ( task _id , req _params )
{
console . log ( "fromCpp__send_funds__status_update" , task _id , req _params )
}
Module . fromCpp _ _send _funds _ _error = function ( task _id , req _params )
{
console . log ( "fromCpp__send_funds__error" , task _id , req _params )
console . timeEnd ( "send_funds" )
}
Module . fromCpp _ _send _funds _ _success = function ( task _id , req _params )
{
console . log ( "fromCpp__send_funds__success" , task _id , req _params )
console . timeEnd ( "send_funds" )
}
const args =
{
task _id : task _id ,
is _sweeping : true ,
payment _id _string : "d2f602b240fbe624" ,
sending _amount : 0 ,
from _address _string : "43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg" ,
sec _viewKey _string : "7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104" ,
sec _spendKey _string : "4e6d43cd03812b803c6f3206689f5fcc910005fc7e91d50d79b0776dbefcd803" ,
pub _spendKey _string : "3eb884d3440d71326e27cc07a861b873e72abd339feb654660c36a008a0028b3" ,
to _address _string : "4APbcAKxZ2KPVPMnqa5cPtJK25tr7maE7LrJe67vzumiCtWwjDBvYnHZr18wFexJpih71Mxsjv8b7EpQftpB9NjPPXmZxHN" ,
priority : 1 ,
unlock _time : 0 , // optional
nettype _string : "MAINNET"
}
const args _str = JSON . stringify ( args , null , '' )
Module . send _funds ( args _str ) ;
}
{
console . time ( "encrypt_payment_id" )
const args _str = '{"payment_id":"f0756322689f8299","public_key":"9c8bd8a9ff8703ddd5e28a36dc5c5586d2ec0b4bfd9190adeea825db5808ead2","secret_key":"74f277a60613a4efa33258b9814c78e0ff7a53cf8d2cd248ee921ac7f607f800"}'
const ret _string = Module . encrypt _payment _id ( args _str )
console . timeEnd ( "encrypt_payment_id" )
console . log ( "encrypt_payment_id ret" , ret _string )
}
}
console . time ( "Load module" )
require ( '../monero_utils/MyMoneroCoreBridge' ) ( { asmjs : false } ) . then ( function ( instance ) // this can be switched to manually test asmjs vs wasm - can be exposed to option
{
console . timeEnd ( "Load module" )
console . log ( "Loaded instance" )
tests ( instance . Module )
} ) . catch ( function ( e )
{
console . error ( "Exception while loading module:" , e )
} )