Skip to content

Conversation

@BitcoinErrorLog
Copy link
Contributor

Summary

This PR implements the core Paykit integration module for Bitkit iOS:

  • PaykitManager: Singleton managing PaykitClient lifecycle and executor registration. Maps LDKNode.Network to Paykit network configs (mainnet/testnet/regtest/signet).

  • BitkitBitcoinExecutor: Implements BitcoinExecutorFFI, bridging Bitkit's LightningService.send(address:) to Paykit's onchain payment interface. Uses semaphore-based async-to-sync bridging for FFI compatibility.

  • BitkitLightningExecutor: Implements LightningExecutorFFI, bridging LightningService.send(bolt11:) to Paykit. Includes payment completion polling to extract preimage proof, SHA256 verification, and hex data handling.

  • PaykitIntegrationHelper: Convenience methods for setup and payment execution, plus AsyncBridge utilities for sync/async bridging.

Key Features

  1. Network Configuration Mapping: Automatically maps Bitkit's Env.network to Paykit's network enums
  2. Async-to-Sync Bridging: Handles Swift async/await conversion for sync FFI calls
  3. Payment Completion Polling: Polls for Lightning payment completion to retrieve preimage
  4. Thread Safety: Uses dispatch semaphores for thread-safe async bridging

Prerequisites

PaykitMobile UniFFI bindings must be generated and linked before these components are fully functional. TODOs in the code mark where binding code should be uncommented.

Test plan

  • Generate PaykitMobile bindings with cargo build --features mobile
  • Link static library and headers to Xcode project
  • Uncomment FFI binding code in PaykitManager and executors
  • Test PaykitIntegrationHelper.setup() during app startup
  • Verify Lightning payments return preimage proof
  • Verify onchain payments return txid

JOHN added 2 commits December 14, 2025 17:47
- Document LightningService and CoreService integration points
- Map Paykit executor methods to Bitkit APIs
- Document async/sync bridging patterns
- Document error handling and network configuration
- Outline payment completion strategies
- Document transaction details extraction approaches
Implements the core Paykit integration components:

- PaykitManager: Singleton managing PaykitClient lifecycle and executor
  registration. Maps LDKNode.Network to Paykit network configs.

- BitkitBitcoinExecutor: Implements BitcoinExecutorFFI, bridging Bitkit's
  LightningService.send(address:) to Paykit's onchain payment interface.
  Uses semaphore-based async-to-sync bridging.

- BitkitLightningExecutor: Implements LightningExecutorFFI, bridging
  LightningService.send(bolt11:) to Paykit. Includes payment completion
  polling to extract preimage proof.

- PaykitIntegrationHelper: Convenience methods for setup and payment
  execution, plus AsyncBridge utilities.

Note: PaykitMobile bindings (UniFFI generated) must be linked before
these components are fully functional. TODOs mark where binding code
should be uncommented once available.
@BitcoinErrorLog
Copy link
Contributor Author

Opened in error - should be on fork

@ovitrif ovitrif deleted the paykit-integration-phase2 branch December 17, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants