Skip to content

Conversation

@amackillop
Copy link
Contributor

Implement a callback-based payment receive method that fires a JavaScript callback immediately when each payment is received, rather than waiting for the full timeout before returning.

Key changes:

  • Add receive_payment_with_callback() in Rust with ThreadsafeFunction
  • Add ReceivedPayment struct with Clone derive for callback use
  • Update TypeScript definitions for the new method

Testing revealed that while callbacks fire correctly, the RPC calls are deferred until the Rust function returns due to Node.js event loop blocking. The PLAN.md has been updated with:

  • Documentation of this architectural limitation
  • Solution 3: Async Rust implementation for truly instant callbacks
  • Implementation roadmap for future work

Current behavior: Callbacks queue during event loop, execute after return. This still improves UX by enabling per-payment notifications rather than batching, and sets the foundation for the async fix.

Implement a callback-based payment receive method that fires a
JavaScript callback immediately when each payment is received,
rather than waiting for the full timeout before returning.

Key changes:
- Add receive_payment_with_callback() in Rust with ThreadsafeFunction
- Add ReceivedPayment struct with Clone derive for callback use
- Update TypeScript definitions for the new method

Testing revealed that while callbacks fire correctly, the RPC calls
are deferred until the Rust function returns due to Node.js event
loop blocking. The PLAN.md has been updated with:
- Documentation of this architectural limitation
- Solution 3: Async Rust implementation for truly instant callbacks
- Implementation roadmap for future work

Current behavior: Callbacks queue during event loop, execute after
return. This still improves UX by enabling per-payment notifications
rather than batching, and sets the foundation for the async fix.
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