From 2b1bccb6871a05def49215e5301501ab7c6f7552 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Wed, 1 Jan 2025 11:48:51 +0100 Subject: [PATCH] Add check_transaction_alone and scan transactions in mempool --- src/main.rs | 7 +++++++ src/scan.rs | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main.rs b/src/main.rs index e926f37..cdc4c16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -226,6 +226,13 @@ fn create_new_tx_message(transaction: Vec) -> Result { } let partial_tweak = compute_partial_tweak_to_transaction(&tx)?; + + let found = check_transaction_alone(&tx, &partial_tweak)?; + + if found.len() > 0 { + debug!("Found {} modified outputs in {}", found.len(), tx.txid()); + } + Ok(NewTxMessage::new( transaction.to_lower_hex_string(), Some(partial_tweak.to_string()), diff --git a/src/scan.rs b/src/scan.rs index 2efff56..e669a6e 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -82,6 +82,17 @@ fn get_script_to_secret_map( Ok(res) } +pub fn check_transaction_alone(tx: &Transaction, tweak_data: &PublicKey) -> Result> { + let sp_wallet = WALLET.get().ok_or(Error::msg("Wallet not initialized"))?; + let updates = sp_wallet.get_wallet()?.update_wallet_with_transaction(tx, 0, *tweak_data)?; + + if updates.len() > 0 { + sp_wallet.save()?; + } + + Ok(updates) +} + fn check_block( blkfilter: BlockFilter, blkhash: BlockHash,