diff --git a/crates/mdk-uniffi/CHANGELOG.md b/crates/mdk-uniffi/CHANGELOG.md index c3915680..f2cdd956 100644 --- a/crates/mdk-uniffi/CHANGELOG.md +++ b/crates/mdk-uniffi/CHANGELOG.md @@ -31,6 +31,8 @@ ### Added +- **`clear_pending_commit` method**: Added `clear_pending_commit(group_id)` to allow callers to roll back an uncommitted pending MLS commit. ([#196](https://github.com/marmot-protocol/mdk/pull/196)) + ### Fixed ### Removed diff --git a/crates/mdk-uniffi/src/lib.rs b/crates/mdk-uniffi/src/lib.rs index 195e4552..217fcd7d 100644 --- a/crates/mdk-uniffi/src/lib.rs +++ b/crates/mdk-uniffi/src/lib.rs @@ -796,6 +796,23 @@ impl Mdk { Ok(()) } + /// Clear pending commit for a group + /// + /// This rolls back the group to its pre-commit state — no epoch advance, no member changes. + /// Call this when publish exhausts retries to recover from failed relay publishes. + /// + /// # Arguments + /// * `mls_group_id` - The MLS group ID to clear the pending commit for (hex-encoded) + /// + /// # Returns + /// * `Ok(())` - if the pending commit was cleared successfully + /// * `Err` - if the group doesn't exist or another error occurs + pub fn clear_pending_commit(&self, mls_group_id: String) -> Result<(), MdkUniffiError> { + let group_id = parse_group_id(&mls_group_id)?; + self.lock()?.clear_pending_commit(&group_id)?; + Ok(()) + } + /// Sync group metadata from MLS pub fn sync_group_metadata_from_mls(&self, mls_group_id: String) -> Result<(), MdkUniffiError> { let group_id = parse_group_id(&mls_group_id)?;