Skip to content

Commit 06b0f68

Browse files
committed
fix(ffi): align monitor to upstream check_payment
1 parent d423a8c commit 06b0f68

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

payjoin-ffi/src/receive/mod.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,11 +1191,6 @@ pub trait TransactionExists: Send + Sync {
11911191
fn callback(&self, txid: String) -> Result<Option<Vec<u8>>, ForeignError>;
11921192
}
11931193

1194-
#[uniffi::export(with_foreign)]
1195-
pub trait OutpointSpent: Send + Sync {
1196-
fn callback(&self, outpoint: PlainOutPoint) -> Result<bool, ForeignError>;
1197-
}
1198-
11991194
#[allow(clippy::type_complexity)]
12001195
#[derive(uniffi::Object)]
12011196
pub struct MonitorTransition(
@@ -1246,24 +1241,13 @@ fn try_deserialize_tx(
12461241

12471242
#[uniffi::export]
12481243
impl Monitor {
1249-
pub fn monitor(
1250-
&self,
1251-
transaction_exists: Arc<dyn TransactionExists>,
1252-
outpoint_spent: Arc<dyn OutpointSpent>,
1253-
) -> MonitorTransition {
1254-
MonitorTransition(Arc::new(RwLock::new(Some(self.0.clone().check_payment(
1255-
|txid| {
1256-
transaction_exists
1257-
.callback(txid.to_string())
1258-
.and_then(|buf| buf.map(try_deserialize_tx).transpose())
1259-
.map_err(|e| ImplementationError::new(e).into())
1260-
},
1261-
|outpoint| {
1262-
outpoint_spent
1263-
.callback(PlainOutPoint::from(outpoint))
1264-
.map_err(|e| ImplementationError::new(e).into())
1265-
},
1266-
)))))
1244+
pub fn monitor(&self, transaction_exists: Arc<dyn TransactionExists>) -> MonitorTransition {
1245+
MonitorTransition(Arc::new(RwLock::new(Some(self.0.clone().check_payment(|txid| {
1246+
transaction_exists
1247+
.callback(txid.to_string())
1248+
.and_then(|buf| buf.map(try_deserialize_tx).transpose())
1249+
.map_err(|e| ImplementationError::new(e).into())
1250+
})))))
12671251
}
12681252
}
12691253

0 commit comments

Comments
 (0)