Skip to content

Commit

Permalink
test: verify, payments on unblinded address undetected
Browse files Browse the repository at this point in the history
  • Loading branch information
claddyy committed Oct 9, 2024
1 parent 7c126bf commit 082cfe4
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion rust/src/api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ impl Wallet {
mod tests {

use std::{thread, time::Duration};

use elements::AssetId;
use lwk_wollet::bitcoin::Address;
use super::*;
#[test]
fn testable_wallets() {
Expand Down Expand Up @@ -443,4 +444,41 @@ 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_bef = wallet.balances().unwrap();
let txs_bef = wallet.txs().unwrap();

assert!(balance.get(0), >0);
assert!(!txs_bef.is_empty());

let add = elements::Address::from_str(&confidential_address).unwrap();
let unblinded_address = add.to_unconfidential();

println!("The unblinded address is {}", unblinded_address);
println!("Fund the unblinded address");

wallet.sync(electrum_url.clone()).unwrap();

let balance = wallet.balances().unwrap();
let txs = wallet.txs().unwrap();

assert!(balance.get(0), "{}", balance_bef.get(0));
println!("Payment to unblinded address not detected");
}

}

0 comments on commit 082cfe4

Please sign in to comment.