From 7c126bf090688354e2c8cb9745ed8a7aef967596 Mon Sep 17 00:00:00 2001 From: ishi Date: Sat, 28 Sep 2024 10:16:50 +0530 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43cf0e7..ce880ce 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Docker is required for linux builds. ```bash dart pub global activate ffigen -cargo install flutter_rust_bridge_codegen +cargo install flutter_rust_bridge_codegen --version 2.0.0-dev.31 cargo install cargo-expand cargo install cargo-ndk @if [ $$(uname) == "Darwin" ] ; then cargo install cargo-lipo ; fi From 03a5c3a665a6bb64e5c58daa35e0f6e7d8ee5d56 Mon Sep 17 00:00:00 2001 From: claddy <0xcladdy@gmail.com> Date: Thu, 10 Oct 2024 02:22:43 +0530 Subject: [PATCH 2/3] test: verify, payments on unblinded address undetected --- rust/src/api/wallet.rs | 44 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/rust/src/api/wallet.rs b/rust/src/api/wallet.rs index 7374f47..40ca358 100644 --- a/rust/src/api/wallet.rs +++ b/rust/src/api/wallet.rs @@ -9,7 +9,6 @@ use lwk_wollet::full_scan_with_electrum_client; // use lwk_wollet::elements_miniscript::descriptor; use lwk_wollet::AddressResult; use lwk_wollet::ElectrumClient; -use lwk_wollet::Update; use lwk_wollet::WolletDescriptor; pub use std::sync::Mutex; @@ -234,10 +233,10 @@ impl Wallet { #[cfg(test)] mod tests { - - use std::{thread, time::Duration}; - use super::*; + use elements::AssetId; + use lwk_wollet::bitcoin::Address; + use std::{thread, time::Duration}; #[test] fn testable_wallets() { let mnemonic = @@ -415,7 +414,6 @@ mod tests { // .unwrap_err(); // assert_eq!(err.to_string(), "FIXME"); // * */ - // // Create tx sending the unblinded utxo // let node_address = server.node_getnewaddress(); @@ -443,4 +441,40 @@ mod tests { // // TODO: more cases // } + + #[test] + fn test_unblinded_detection() { + let network = Network::Testnet; + let mnemonic = ""; + let descriptor = Descriptor::new_confidential(network, mnemonic.to_string()) + .expect("Failed to create descriptor"); + let wallet = Wallet::init(network, "/tmp/lwk_test".to_string(), descriptor).expect(""); + + let confidential_address = wallet.address_last_unused().unwrap(); + println!("The confidential address is {}", confidential_address); + + //Write code to halt for the payment to be made. maybe we can add a timer? or take an input from user that confirms that he did the pyment or not. + + let electrum_url = "les.bullbitcoin.com:995".to_string(); + wallet.sync(electrum_url.clone()).unwrap(); + + let balance_before = wallet.balances().unwrap(); + let txs_before = wallet.txs().unwrap(); + + assert!(balance.get(0), >0); + assert!(!txs_before.is_empty()); + + let blinding_key = wallet.blinding_key().unwrap(); + let unblinded_address = ""; + let unblinded_address = println!("The unblinded address is {}", unblinded_address); + println!("Fund the unblinded address"); + + wallet.sync(electrum_url.clone()).unwrap(); + + let balance_after = wallet.balances().unwrap(); + let txs_after = wallet.txs().unwrap(); + + assert!(balance_after.get(0), "{}", balance_before.get(0)); + println!("Payment to unblinded address not detected"); + } } From 46f61705599d4ce5425a5aabf7fe624c13bccacd Mon Sep 17 00:00:00 2001 From: claddy <0xcladdy@gmail.com> Date: Fri, 11 Oct 2024 09:04:38 +0530 Subject: [PATCH 3/3] Add pause and wait fn --- rust/src/api/wallet.rs | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/rust/src/api/wallet.rs b/rust/src/api/wallet.rs index 40ca358..ae7d3f1 100644 --- a/rust/src/api/wallet.rs +++ b/rust/src/api/wallet.rs @@ -234,9 +234,9 @@ impl Wallet { #[cfg(test)] mod tests { use super::*; - use elements::AssetId; - use lwk_wollet::bitcoin::Address; - use std::{thread, time::Duration}; + use std::io; + use std::io::Write; + #[test] fn testable_wallets() { let mnemonic = @@ -441,40 +441,41 @@ mod tests { // // TODO: more cases // } - + pub fn pause_and_wait(msg: &str) { + println!("******{}******", msg); + println!("Press enter to continue"); + let mut input = String::new(); + io::stdin().read_line(&mut input).expect("Failed to read line"); + } #[test] fn test_unblinded_detection() { let network = Network::Testnet; - let mnemonic = ""; + let mnemonic = "coyote error drink treat canal spider company fat bridge drink amateur injury"; let descriptor = Descriptor::new_confidential(network, mnemonic.to_string()) .expect("Failed to create descriptor"); let wallet = Wallet::init(network, "/tmp/lwk_test".to_string(), descriptor).expect(""); let confidential_address = wallet.address_last_unused().unwrap(); - println!("The confidential address is {}", confidential_address); + println!("The confidential address is {:?}", confidential_address); - //Write code to halt for the payment to be made. maybe we can add a timer? or take an input from user that confirms that he did the pyment or not. - - let electrum_url = "les.bullbitcoin.com:995".to_string(); + let electrum_url = "blockstream.info:465".to_string(); + pause_and_wait(&format!("Fund confidential address {:?}", confidential_address)); wallet.sync(electrum_url.clone()).unwrap(); let balance_before = wallet.balances().unwrap(); let txs_before = wallet.txs().unwrap(); + assert!(balance_before.get(0).is_some(), "No balance before funding"); + assert!(!txs_before.is_empty(), "No transactions before funding"); - assert!(balance.get(0), >0); - assert!(!txs_before.is_empty()); - - let blinding_key = wallet.blinding_key().unwrap(); - let unblinded_address = ""; - let unblinded_address = println!("The unblinded address is {}", unblinded_address); - println!("Fund the unblinded address"); + let unblinded_address = confidential_address.standard; + println!("The unblinded address is {}", unblinded_address); + pause_and_wait(&format!("Fund unblinded address {}", unblinded_address)); wallet.sync(electrum_url.clone()).unwrap(); let balance_after = wallet.balances().unwrap(); - let txs_after = wallet.txs().unwrap(); - assert!(balance_after.get(0), "{}", balance_before.get(0)); - println!("Payment to unblinded address not detected"); + assert_eq!(balance_after.get(0), balance_before.get(0)); + println!("Payment to unblinded address not detected.") } }