diff --git a/clients/apps/rust/src/main.rs b/clients/apps/rust/src/main.rs index 9649be1d..7b15138e 100644 --- a/clients/apps/rust/src/main.rs +++ b/clients/apps/rust/src/main.rs @@ -27,7 +27,7 @@ enum Commands { BroadcastBackupTransaction { wallet_name: String, statechain_id: String, - to_address: String, + to_address: Option, /// Transaction fee rate in sats per byte fee_rate: Option }, @@ -115,7 +115,7 @@ async fn main() -> Result<()> { }, Commands::BroadcastBackupTransaction { wallet_name, statechain_id, to_address, fee_rate } => { mercuryrustlib::coin_status::update_coins(&client_config, &wallet_name).await?; - mercuryrustlib::broadcast_backup_tx::execute(&client_config, &wallet_name, &statechain_id, &to_address, fee_rate).await?; + mercuryrustlib::broadcast_backup_tx::execute(&client_config, &wallet_name, &statechain_id, to_address, fee_rate).await?; }, Commands::ListStatecoins { wallet_name } => { mercuryrustlib::coin_status::update_coins(&client_config, &wallet_name).await?; diff --git a/clients/libs/rust/src/broadcast_backup_tx.rs b/clients/libs/rust/src/broadcast_backup_tx.rs index 93f07a31..db544d38 100644 --- a/clients/libs/rust/src/broadcast_backup_tx.rs +++ b/clients/libs/rust/src/broadcast_backup_tx.rs @@ -3,14 +3,17 @@ use anyhow::{anyhow, Result}; use electrum_client::ElectrumApi; use mercurylib::wallet::{cpfp_tx, CoinStatus}; -pub async fn execute(client_config: &ClientConfig, wallet_name: &str, statechain_id: &str, to_address: &str, fee_rate: Option) -> Result<()> { +pub async fn execute(client_config: &ClientConfig, wallet_name: &str, statechain_id: &str, to_address: Option, fee_rate: Option) -> Result<()> { let mut wallet: mercurylib::wallet::Wallet = get_wallet(&client_config.pool, &wallet_name).await?; - let is_address_valid = mercurylib::validate_address(to_address, &wallet.network)?; + if to_address.is_some() { + let to_address = to_address.clone().unwrap(); + let is_address_valid = mercurylib::validate_address(&to_address, &wallet.network)?; - if !is_address_valid { - return Err(anyhow!("Invalid address")); + if !is_address_valid { + return Err(anyhow!("Invalid address")); + } } let backup_txs = get_backup_txs(&client_config.pool, &statechain_id).await?; @@ -34,38 +37,46 @@ pub async fn execute(client_config: &ClientConfig, wallet_name: &str, statechain let backup_tx = cpfp_tx::latest_backup_tx_pays_to_user_pubkey(&backup_txs, &coin, &wallet.network)?; - let fee_rate = match fee_rate { - Some(fee_rate) => fee_rate, - None => { - let mut fee_rate_btc_per_kb = client_config.electrum_client.estimate_fee(1)?; + let cpfp_tx = if to_address.is_some() { - // Why does it happen? - if fee_rate_btc_per_kb <= 0.0 { - fee_rate_btc_per_kb = 0.00001; - } + let to_address = to_address.clone().unwrap(); - let fee_rate_sats_per_byte = fee_rate_btc_per_kb * 100000.0; + let fee_rate = match fee_rate { + Some(fee_rate) => fee_rate, + None => { + let mut fee_rate_btc_per_kb = client_config.electrum_client.estimate_fee(1)?; - if fee_rate_sats_per_byte > client_config.max_fee_rate { - client_config.max_fee_rate - } else { - fee_rate_sats_per_byte - } - }, - }; + // Why does it happen? + if fee_rate_btc_per_kb <= 0.0 { + fee_rate_btc_per_kb = 0.00001; + } - let cpfp_tx = cpfp_tx::create_cpfp_tx(&backup_tx, &coin, to_address, fee_rate, &wallet.network)?; + let fee_rate_sats_per_byte = fee_rate_btc_per_kb * 100000.0; - let tx_bytes = hex::decode(&backup_tx.tx)?; - let txid = client_config.electrum_client.transaction_broadcast_raw(&tx_bytes)?; - println!("Broadcasting backup transaction: {}", txid); + if fee_rate_sats_per_byte > client_config.max_fee_rate { + client_config.max_fee_rate + } else { + fee_rate_sats_per_byte + } + }, + }; - let tx_bytes = hex::decode(&cpfp_tx)?; - let txid = client_config.electrum_client.transaction_broadcast_raw(&tx_bytes)?; - println!("Broadcasting CPFP transaction: {}", txid); + Some(cpfp_tx::create_cpfp_tx(&backup_tx, &coin, &to_address, fee_rate, &wallet.network)?) + } else { + None + }; + let tx_bytes = hex::decode(&backup_tx.tx)?; + let mut txid = client_config.electrum_client.transaction_broadcast_raw(&tx_bytes)?; + + if cpfp_tx.is_some() { + let cpfp_tx = cpfp_tx.unwrap(); + let tx_bytes = hex::decode(&cpfp_tx)?; + txid = client_config.electrum_client.transaction_broadcast_raw(&tx_bytes)?; + } + coin.tx_cpfp = Some(txid.to_string()); - coin.withdrawal_address = Some(to_address.to_string()); + coin.withdrawal_address = if to_address.is_some() { Some(to_address.unwrap()) } else { Some(coin.backup_address.clone()) }; coin.status = CoinStatus::WITHDRAWING; let signed_statechain_id = coin.signed_statechain_id.as_ref().unwrap().to_string(); diff --git a/clients/tests/rust/src/electrs.rs b/clients/tests/rust/src/electrs.rs index 2969aef6..05cf6039 100644 --- a/clients/tests/rust/src/electrs.rs +++ b/clients/tests/rust/src/electrs.rs @@ -24,4 +24,9 @@ pub async fn check_address(client_config: &ClientConfig, address: &str, amount: } Ok(true) +} + +pub async fn get_blockheight(client_config: &ClientConfig) -> Result { + let blockheight = client_config.electrum_client.block_headers_subscribe()?.height; + Ok(blockheight) } \ No newline at end of file diff --git a/clients/tests/rust/src/main.rs b/clients/tests/rust/src/main.rs index e9e4df20..692f76b7 100644 --- a/clients/tests/rust/src/main.rs +++ b/clients/tests/rust/src/main.rs @@ -8,6 +8,7 @@ pub mod tb02_transfer_address_reuse; pub mod tb03_simple_atomic_transfer; pub mod tb04_simple_lightning_latch; pub mod tm01_sender_double_spends; +mod tv05; use anyhow::{Result, Ok}; #[tokio::main(flavor = "current_thread")] @@ -20,6 +21,7 @@ async fn main() -> Result<()> { tm01_sender_double_spends::execute().await?; ta01_sign_second_not_called::execute().await?; ta02_duplicate_deposits::execute().await?; + tv05::execute().await?; Ok(()) } diff --git a/clients/tests/rust/src/tv05.rs b/clients/tests/rust/src/tv05.rs new file mode 100644 index 00000000..29bff91f --- /dev/null +++ b/clients/tests/rust/src/tv05.rs @@ -0,0 +1,103 @@ +use std::{env, process::Command, thread, time::Duration}; + +use anyhow::{Result, Ok}; +use mercuryrustlib::{client_config::ClientConfig, CoinStatus, Wallet}; + +use crate::{bitcoin_core, electrs}; + +async fn w1_transfer_to_w2(client_config: &ClientConfig, wallet1: &Wallet, wallet2: &Wallet) -> Result<()> { + + let amount = 1000; + + let token_id = mercuryrustlib::deposit::get_token(client_config).await?; + + let deposit_address = mercuryrustlib::deposit::get_deposit_bitcoin_address(&client_config, &wallet1.name, &token_id, amount).await?; + + let _ = bitcoin_core::sendtoaddress(amount, &deposit_address)?; + + let core_wallet_address = bitcoin_core::getnewaddress()?; + let remaining_blocks = client_config.confirmation_target; + let _ = bitcoin_core::generatetoaddress(remaining_blocks, &core_wallet_address)?; + + // It appears that Electrs takes a few seconds to index the transaction + let mut is_tx_indexed = false; + + while !is_tx_indexed { + is_tx_indexed = electrs::check_address(client_config, &deposit_address, amount).await?; + thread::sleep(Duration::from_secs(1)); + } + + mercuryrustlib::coin_status::update_coins(&client_config, &wallet1.name).await?; + let wallet1: mercuryrustlib::Wallet = mercuryrustlib::sqlite_manager::get_wallet(&client_config.pool, &wallet1.name).await?; + let new_coin = wallet1.coins.iter().find(|&coin| coin.aggregated_address == Some(deposit_address.clone()) && coin.status == CoinStatus::CONFIRMED).unwrap(); + let statechain_id = new_coin.statechain_id.as_ref().unwrap(); + + assert!(new_coin.status == CoinStatus::CONFIRMED); + + let wallet2_transfer_adress = mercuryrustlib::transfer_receiver::new_transfer_address(&client_config, &wallet2.name).await?; + + let batch_id = None; + let force_send = false; + + let result = mercuryrustlib::transfer_sender::execute(&client_config, &wallet2_transfer_adress, &wallet1.name, &statechain_id, force_send, batch_id).await; + assert!(result.is_ok()); + + let transfer_receive_result = mercuryrustlib::transfer_receiver::execute(&client_config, &wallet2.name).await?; + let received_statechain_ids = transfer_receive_result.received_statechain_ids; + + assert!(received_statechain_ids.contains(&statechain_id.to_string())); + assert!(received_statechain_ids.len() == 1); + + mercuryrustlib::coin_status::update_coins(&client_config, &wallet2.name).await?; + let local_wallet_2: mercuryrustlib::Wallet = mercuryrustlib::sqlite_manager::get_wallet(&client_config.pool, &wallet2.name).await?; + let new_w2_coin = local_wallet_2.coins.iter().find(|&coin| coin.statechain_id == Some(statechain_id.clone())).unwrap(); + + assert!(new_coin.status == CoinStatus::CONFIRMED); + assert!(new_w2_coin.status == CoinStatus::CONFIRMED); + + let fee_rate = None; + + let core_wallet_address = Some(core_wallet_address); + + let result = mercuryrustlib::broadcast_backup_tx::execute(&client_config, &wallet1.name, &statechain_id, core_wallet_address.clone(), fee_rate).await; + + assert!(result.is_err()); + + let err = result.err().unwrap(); + + assert!(err.to_string() == "Electrum server error: {\"code\":2,\"message\":\"non-final\"}"); + + let _ = bitcoin_core::generatetoaddress(990, &core_wallet_address.clone().unwrap())?; + + let result = mercuryrustlib::broadcast_backup_tx::execute(&client_config, &wallet2.name, &statechain_id, core_wallet_address, fee_rate).await; + + assert!(result.is_ok()); + + Ok(()) +} + +pub async fn execute() -> Result<()> { + let _ = Command::new("rm").arg("wallet.db").arg("wallet.db-shm").arg("wallet.db-wal").output().expect("failed to execute process"); + + env::set_var("ML_NETWORK", "regtest"); + + let client_config = mercuryrustlib::client_config::load().await; + + let wallet1 = mercuryrustlib::wallet::create_wallet( + "wallet1", + &client_config).await?; + + mercuryrustlib::sqlite_manager::insert_wallet(&client_config.pool, &wallet1).await?; + + let wallet2 = mercuryrustlib::wallet::create_wallet( + "wallet2", + &client_config).await?; + + mercuryrustlib::sqlite_manager::insert_wallet(&client_config.pool, &wallet2).await?; + + w1_transfer_to_w2(&client_config, &wallet1, &wallet2).await?; + + println!("TV05 - Result as reported."); + + Ok(()) +} \ No newline at end of file diff --git a/lib/src/error.rs b/lib/src/error.rs index b2b11546..baea27fa 100644 --- a/lib/src/error.rs +++ b/lib/src/error.rs @@ -43,6 +43,7 @@ pub enum MercuryError { Bech32Error, HexError, LocktimeNotBlockHeightError, + TransactionSequenceDifferentThanZeroError, BitcoinConsensusEncodeError, MusigNonceGenError, InvalidStatechainAddressError, @@ -68,6 +69,7 @@ pub enum MercuryError { SecpError, NoBackupTransactionFound, Tx1HasMoreThanOneInput, + EmptyInput, InvalidSignature, EmptyWitness, EmptyWitnessData, diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 196b5fef..21229a6a 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -215,7 +215,7 @@ pub fn get_musig_session( input: vec![TxIn { previous_output: OutPoint { txid: input_txid, vout: input_vout }, script_sig: ScriptBuf::new(), - sequence: bitcoin::Sequence(0xFFFFFFFF), // Ignore nSequence. + sequence: bitcoin::Sequence(0x0), // Ignore nSequence. witness: Witness::default(), }], output: outputs, diff --git a/lib/src/transfer/receiver.rs b/lib/src/transfer/receiver.rs index 9fbbd838..19b22b3a 100644 --- a/lib/src/transfer/receiver.rs +++ b/lib/src/transfer/receiver.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use bitcoin::{PrivateKey, Transaction, hashes::{sha256, Hash}, Txid, Address, sighash::{TapSighashType, SighashCache, self}, TxOut, taproot::TapTweakHash}; +use bitcoin::{hashes::{sha256, Hash}, sighash::{self, SighashCache, TapSighashType}, taproot::TapTweakHash, Address, PrivateKey, Sequence, Transaction, TxOut, Txid}; use secp256k1_zkp::{PublicKey, schnorr::Signature, Secp256k1, Message, XOnlyPublicKey, musig::{MusigPubNonce, BlindingFactor, blinded_musig_pubkey_xonly_tweak_add, MusigAggNonce, MusigSession}, SecretKey, Scalar, KeyPair}; use serde::{Serialize, Deserialize}; @@ -291,6 +291,12 @@ pub fn validate_signature_scheme( break; } + if verify_transaction_sequence(&backup_tx.tx).is_err() { + println!("transaction sequence is not correct"); + sig_scheme_validation = false; + break; + } + if previous_lock_time.is_some() { let prev_lock_time = previous_lock_time.unwrap(); let current_lock_time = crate::utils::get_blockheight(&backup_tx)?; @@ -369,6 +375,27 @@ pub fn verify_transaction_signature(tx_n_hex: &str, tx0_hex: &str, fee_rate_tole } +#[cfg_attr(feature = "bindings", uniffi::export)] +pub fn verify_transaction_sequence(tx_n_hex: &str) -> Result<(), MercuryError> { + + let tx_n: Transaction = bitcoin::consensus::encode::deserialize(&hex::decode(&tx_n_hex)?)?; + + if tx_n.input.is_empty() { + return Err(MercuryError::EmptyInput); + } + + if tx_n.input.len() > 1 { + return Err(MercuryError::Tx1HasMoreThanOneInput); + } + + let input = tx_n.input.first().unwrap(); + + if input.sequence != Sequence(0) { + return Err(MercuryError::TransactionSequenceDifferentThanZeroError); + } + + Ok(()) +} fn get_tx_hash(tx_0: &Transaction, tx_n: &Transaction) -> Result { diff --git a/wasm/node_pkg/debug/mercury_wasm.js b/wasm/node_pkg/debug/mercury_wasm.js index a16e56e1..c512a748 100644 --- a/wasm/node_pkg/debug/mercury_wasm.js +++ b/wasm/node_pkg/debug/mercury_wasm.js @@ -1176,17 +1176,17 @@ module.exports.__wbg_buffer_085ec1f694018c4f = function() { return logError(func return addHeapObject(ret); }, arguments) }; +module.exports.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); +}, arguments) }; + module.exports.__wbindgen_is_function = function(arg0) { const ret = typeof(getObject(arg0)) === 'function'; _assertBoolean(ret); return ret; }; -module.exports.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - module.exports.__wbindgen_debug_string = function(arg0, arg1) { const ret = debugString(getObject(arg1)); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); diff --git a/wasm/node_pkg/debug/mercury_wasm_bg.wasm b/wasm/node_pkg/debug/mercury_wasm_bg.wasm index 9a6d27ba..141e3e35 100644 Binary files a/wasm/node_pkg/debug/mercury_wasm_bg.wasm and b/wasm/node_pkg/debug/mercury_wasm_bg.wasm differ diff --git a/wasm/node_pkg/release/mercury_wasm.js b/wasm/node_pkg/release/mercury_wasm.js index 8a34b2c7..8e08c254 100644 --- a/wasm/node_pkg/release/mercury_wasm.js +++ b/wasm/node_pkg/release/mercury_wasm.js @@ -9,6 +9,20 @@ heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + let WASM_VECTOR_LEN = 0; let cachedUint8Memory0 = null; @@ -87,20 +101,6 @@ function getInt32Memory0() { return cachedInt32Memory0; } -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); @@ -851,6 +851,10 @@ function handleError(f, args) { } } +module.exports.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); +}; + module.exports.__wbindgen_string_get = function(arg0, arg1) { const obj = getObject(arg1); const ret = typeof(obj) === 'string' ? obj : undefined; @@ -860,10 +864,6 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) { getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; -module.exports.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); -}; - module.exports.__wbindgen_boolean_get = function(arg0) { const v = getObject(arg0); const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; @@ -896,6 +896,16 @@ module.exports.__wbindgen_error_new = function(arg0, arg1) { return addHeapObject(ret); }; +module.exports.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return addHeapObject(ret); +}; + +module.exports.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); +}; + module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { const ret = getObject(arg0) == getObject(arg1); return ret; @@ -908,21 +918,11 @@ module.exports.__wbindgen_number_get = function(arg0, arg1) { getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); }; -module.exports.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - module.exports.__wbindgen_object_clone_ref = function(arg0) { const ret = getObject(arg0); return addHeapObject(ret); }; -module.exports.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - module.exports.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { const ret = getObject(arg0)[getObject(arg1)]; return addHeapObject(ret); @@ -952,11 +952,6 @@ module.exports.__wbg_node_caaf83d002149bd5 = function(arg0) { return addHeapObject(ret); }; -module.exports.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) { - const ret = getObject(arg0).msCrypto; - return addHeapObject(ret); -}; - module.exports.__wbg_require_94a9da52636aacbf = function() { return handleError(function () { const ret = module.require; return addHeapObject(ret); @@ -967,6 +962,11 @@ module.exports.__wbindgen_is_function = function(arg0) { return ret; }; +module.exports.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); +}; + module.exports.__wbg_randomFillSync_290977693942bf03 = function() { return handleError(function (arg0, arg1) { getObject(arg0).randomFillSync(takeObject(arg1)); }, arguments) }; diff --git a/wasm/node_pkg/release/mercury_wasm_bg.wasm b/wasm/node_pkg/release/mercury_wasm_bg.wasm index 24d83658..8771c484 100644 Binary files a/wasm/node_pkg/release/mercury_wasm_bg.wasm and b/wasm/node_pkg/release/mercury_wasm_bg.wasm differ diff --git a/wasm/web_pkg/debug/mercury_wasm.js b/wasm/web_pkg/debug/mercury_wasm.js index 99aee9af..a9bb0bd3 100644 --- a/wasm/web_pkg/debug/mercury_wasm.js +++ b/wasm/web_pkg/debug/mercury_wasm.js @@ -1156,15 +1156,15 @@ function __wbg_get_imports() { const ret = getObject(arg0).buffer; return addHeapObject(ret); }, arguments) }; + imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; imports.wbg.__wbindgen_is_function = function(arg0) { const ret = typeof(getObject(arg0)) === 'function'; _assertBoolean(ret); return ret; }; - imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); - }, arguments) }; imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { const ret = debugString(getObject(arg1)); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); diff --git a/wasm/web_pkg/debug/mercury_wasm_bg.wasm b/wasm/web_pkg/debug/mercury_wasm_bg.wasm index 13d86e2a..76b7a174 100644 Binary files a/wasm/web_pkg/debug/mercury_wasm_bg.wasm and b/wasm/web_pkg/debug/mercury_wasm_bg.wasm differ diff --git a/wasm/web_pkg/release/mercury_wasm.js b/wasm/web_pkg/release/mercury_wasm.js index 08db576d..cb97e308 100644 --- a/wasm/web_pkg/release/mercury_wasm.js +++ b/wasm/web_pkg/release/mercury_wasm.js @@ -6,6 +6,20 @@ heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + let WASM_VECTOR_LEN = 0; let cachedUint8Memory0 = null; @@ -84,20 +98,6 @@ function getInt32Memory0() { return cachedInt32Memory0; } -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; @@ -882,6 +882,9 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; imports.wbg.__wbindgen_string_get = function(arg0, arg1) { const obj = getObject(arg1); const ret = typeof(obj) === 'string' ? obj : undefined; @@ -890,9 +893,6 @@ function __wbg_get_imports() { getInt32Memory0()[arg0 / 4 + 1] = len1; getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; - imports.wbg.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); - }; imports.wbg.__wbindgen_boolean_get = function(arg0) { const v = getObject(arg0); const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; @@ -919,6 +919,14 @@ function __wbg_get_imports() { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; + imports.wbg.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { const ret = getObject(arg0) == getObject(arg1); return ret; @@ -929,18 +937,10 @@ function __wbg_get_imports() { getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); }; - imports.wbg.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return addHeapObject(ret); - }; imports.wbg.__wbindgen_object_clone_ref = function(arg0) { const ret = getObject(arg0); return addHeapObject(ret); }; - imports.wbg.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); - }; imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { const ret = getObject(arg0)[getObject(arg1)]; return addHeapObject(ret); @@ -964,10 +964,6 @@ function __wbg_get_imports() { const ret = getObject(arg0).node; return addHeapObject(ret); }; - imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) { - const ret = getObject(arg0).msCrypto; - return addHeapObject(ret); - }; imports.wbg.__wbg_require_94a9da52636aacbf = function() { return handleError(function () { const ret = module.require; return addHeapObject(ret); @@ -976,6 +972,10 @@ function __wbg_get_imports() { const ret = typeof(getObject(arg0)) === 'function'; return ret; }; + imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); + }; imports.wbg.__wbg_randomFillSync_290977693942bf03 = function() { return handleError(function (arg0, arg1) { getObject(arg0).randomFillSync(takeObject(arg1)); }, arguments) }; diff --git a/wasm/web_pkg/release/mercury_wasm_bg.wasm b/wasm/web_pkg/release/mercury_wasm_bg.wasm index a7bb04af..c43a1372 100644 Binary files a/wasm/web_pkg/release/mercury_wasm_bg.wasm and b/wasm/web_pkg/release/mercury_wasm_bg.wasm differ