Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion payjoin-cli/src/app/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
4 changes: 2 additions & 2 deletions payjoin-ffi/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn TransactionExists>,
) -> 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())
Expand Down
14 changes: 8 additions & 6 deletions payjoin/src/core/receive/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Monitor>::check_payment`] to confirm the status of the transaction in the
/// Call [`Receiver<Monitor>::check_for_broadcast`] to confirm the status of the transaction in the
/// network and conclude the Payjoin session.
impl Receiver<Monitor> {
/// Checks the network for the Payjoin proposal or the fallback transaction using the passed
Expand All @@ -1484,7 +1484,7 @@ impl Receiver<Monitor> {
/// 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<Option<bitcoin::Transaction>, ImplementationError>,
) -> MaybeFatalOrSuccessTransition<SessionEvent, Self, Error> {
Expand Down Expand Up @@ -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(_)));
Expand All @@ -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");

Expand All @@ -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()))
Expand Down Expand Up @@ -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");

Expand Down
12 changes: 6 additions & 6 deletions payjoin/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down
Loading