From 65c26941e3f7b5653c09449360ef05fc1b88240f Mon Sep 17 00:00:00 2001 From: spacebear Date: Fri, 19 Jun 2026 12:59:28 -0400 Subject: [PATCH] Rename Monitor method This method does not check for "payment", it checks for transaction broadcast. --- payjoin-cli/src/app/v2/mod.rs | 2 +- payjoin-ffi/src/receive/mod.rs | 4 ++-- payjoin/src/core/receive/v2/mod.rs | 14 ++++++++------ payjoin/tests/integration.rs | 12 ++++++------ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/payjoin-cli/src/app/v2/mod.rs b/payjoin-cli/src/app/v2/mod.rs index 42601e205..8e7af2287 100644 --- a/payjoin-cli/src/app/v2/mod.rs +++ b/payjoin-cli/src/app/v2/mod.rs @@ -976,7 +976,7 @@ impl App { loop { interval.tick().await; let check_result = proposal - .check_payment(|txid| { + .check_for_broadcast(|txid| { self.wallet() .get_raw_transaction(&txid) .map_err(|e| ImplementationError::from(e.into_boxed_dyn_error())) diff --git a/payjoin-ffi/src/receive/mod.rs b/payjoin-ffi/src/receive/mod.rs index e560c1806..574355cf6 100644 --- a/payjoin-ffi/src/receive/mod.rs +++ b/payjoin-ffi/src/receive/mod.rs @@ -1505,11 +1505,11 @@ fn try_deserialize_tx( #[uniffi::export] impl Monitor { - pub fn check_payment( + pub fn check_for_broadcast( &self, transaction_exists: Arc, ) -> MonitorTransition { - MonitorTransition(Arc::new(RwLock::new(Some(self.0.clone().check_payment(|txid| { + MonitorTransition(Arc::new(RwLock::new(Some(self.0.clone().check_for_broadcast(|txid| { transaction_exists .callback(txid.to_string()) .and_then(|buf| buf.map(try_deserialize_tx).transpose()) diff --git a/payjoin/src/core/receive/v2/mod.rs b/payjoin/src/core/receive/v2/mod.rs index a57d28256..6f36e78cc 100644 --- a/payjoin/src/core/receive/v2/mod.rs +++ b/payjoin/src/core/receive/v2/mod.rs @@ -1469,7 +1469,7 @@ pub struct Monitor { /// The caller should decide the condition that must be satisfied for the Payjoin to be considered /// successful. /// -/// Call [`Receiver::check_payment`] to confirm the status of the transaction in the +/// Call [`Receiver::check_for_broadcast`] to confirm the status of the transaction in the /// network and conclude the Payjoin session. impl Receiver { /// Checks the network for the Payjoin proposal or the fallback transaction using the passed @@ -1484,7 +1484,7 @@ impl Receiver { /// provided `transaction_exists` closure. `transaction_exists` uses the transaction ID to /// search for the transaction in the network. Since a non-SegWit input signature is going to /// change the TXID of the Payjoin proposal, it cannot be monitored. - pub fn check_payment( + pub fn check_for_broadcast( &self, transaction_exists: impl Fn(Txid) -> Result, ImplementationError>, ) -> MaybeFatalOrSuccessTransition { @@ -1699,7 +1699,7 @@ pub mod test { // Nothing was spent, should be in the same state let persister = InMemoryPersister::default(); let res = monitor - .check_payment(|_| Ok(None)) + .check_for_broadcast(|_| Ok(None)) .save(&persister) .expect("InMemoryPersister shouldn't fail"); assert!(matches!(res, OptionalTransitionOutcome::Stasis(_))); @@ -1709,7 +1709,7 @@ pub mod test { // Payjoin was broadcasted, should progress to success let persister = InMemoryPersister::default(); let res = monitor - .check_payment(|_| Ok(Some(payjoin_tx.clone()))) + .check_for_broadcast(|_| Ok(Some(payjoin_tx.clone()))) .save(&persister) .expect("InMemoryPersister shouldn't fail"); @@ -1727,7 +1727,7 @@ pub mod test { // Fallback was broadcasted, should progress to success let persister = InMemoryPersister::default(); let res = monitor - .check_payment(|txid| { + .check_for_broadcast(|txid| { // Emulate if one of the fallback outpoints was double spent if txid == original_tx.compute_txid() { Ok(Some(original_tx.clone())) @@ -1764,7 +1764,9 @@ pub mod test { let persister = InMemoryPersister::default(); let res = monitor - .check_payment(|_| panic!("check_payment should return before this closure is called")) + .check_for_broadcast(|_| { + panic!("check_for_broadcast should return before this closure is called") + }) .save(&persister) .expect("InMemoryPersister shouldn't fail"); diff --git a/payjoin/tests/integration.rs b/payjoin/tests/integration.rs index fd86cec78..c88931a7b 100644 --- a/payjoin/tests/integration.rs +++ b/payjoin/tests/integration.rs @@ -557,8 +557,8 @@ mod integration { // The sender is using a non-SegWit address, so their signature is going to change the TXID. So we test whether the // function exists early and does not call the closure. monitoring_payment - .check_payment(|_| { - panic!("when the sender is using a non-SegWit address type, the check_payment function should skip the check and return success") + .check_for_broadcast(|_| { + panic!("when the sender is using a non-SegWit address type, the check_for_broadcast function should skip the check and return success") }) .save(&recv_persister) .expect("receiver should successfully monitor for the payment"); @@ -612,7 +612,7 @@ mod integration { // Receiver should be able to validate that the sender has broadcasted the Payjoin proposal. monitoring_payment - .check_payment(|txid| { + .check_for_broadcast(|txid| { let get_tx_result = receiver.get_raw_transaction(txid); match get_tx_result { Ok(tx) => @@ -694,7 +694,7 @@ mod integration { // Receiver should be able to validate that the sender has broadcasted the Payjoin proposal. monitoring_payment - .check_payment(|txid| { + .check_for_broadcast(|txid| { let get_tx_result = receiver.get_raw_transaction(txid); match get_tx_result { Ok(tx) => @@ -770,10 +770,10 @@ mod integration { ); // Receiver should be able to validate that the sender has broadcasted the fallback transaction. - // The check_payment closure should be called twice: first for the Payjoin proposal, which will not be found, + // The check_for_broadcast closure should be called twice: first for the Payjoin proposal, which will not be found, // and then for the fallback transaction, which will be found.. monitoring_payment - .check_payment(|txid| { + .check_for_broadcast(|txid| { let get_tx_result = receiver.get_raw_transaction(txid); match get_tx_result { Ok(tx) =>