Skip to content

Async callback wrappers in FFI#1425

Closed
spacebear21 wants to merge 2 commits intopayjoin:masterfrom
spacebear21:async-callback-wrappers
Closed

Async callback wrappers in FFI#1425
spacebear21 wants to merge 2 commits intopayjoin:masterfrom
spacebear21:async-callback-wrappers

Conversation

@spacebear21
Copy link
Collaborator

I'm exploring this approach as a workaround for FFI downstream languages, without needing to modify the core rust API. Code by ClaudeTM

Pull Request Checklist

Please confirm the following before requesting review:

Gate tokio behind a new `async_callbacks` feature so downstream
languages (e.g. Dart) can opt-in to async callback bridging
without pulling tokio into default builds.
Introduce async alternatives for the five receiver validation
callbacks (CanBroadcast, IsScriptOwned, IsOutputKnown, ProcessPsbt,
TransactionExists) behind the `async_callbacks` feature flag.

Languages like Dart are inherently async and cannot block inside a
sync callback. The bridge methods accept async callback traits and
use `tokio::task::block_in_place` + `Handle::current().block_on()`
to call them from within the core library's sync closure API,
avoiding breaking changes to the core.
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 23310324081

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 84.125%

Totals Coverage Status
Change from base Build 23300212261: 0.0%
Covered Lines: 10646
Relevant Lines: 12655

💛 - Coveralls

@spacebear21
Copy link
Collaborator Author

Closing this approach as it doesn't work with wasm targets i.e. doesn't solve the issue for JS bindings

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