Skip to content

Conversation

@kumulynja
Copy link
Contributor

@kumulynja kumulynja commented Nov 24, 2025

This PR updates bdk dart to v2.3.0-alpha.0 which uses uniffi 0.30 and updates uniffi-dart to the version with Native Assets support. Native Assets/Build hooks is the new and recommended way in Dart and Flutter to use native libraries, as it eliminates the need to bundle/distribute precompiled binaries.

It also removes the git submodule to bdk-ffi and instead adds a small wrapper in the /native folder so bdk-dart can be published to pub.dev

- Add patterns for all native binary types (.so, .dylib, .dll, .a)
- Remove lib/bdk.dart from .gitignore to include in published package
Generated bindings are now tracked in version control to enable
publishing to pub.dev. Users should not need to generate bindings
themselves when installing the package.
…fork

- Bump version to 2.3.0-alpha.0
- Upgrade uniffi from 0.29.4 to 0.30.0
- Switch to kumulynja/uniffi-dart fork
- Add camino dependency for uniffi 0.30.0 compatibility
- Update bdk_kyoto from 0.15.1 to 0.15.3
- Use placeholder UDL path (metadata extracted from library)
- Auto-detect library file by extension instead of --library flag
- Use camino::Utf8Path required by uniffi 0.30.0
- Simplify code with match expression
- Add path variables for cleaner navigation
- Add submodule init/update and version checkout
- Remove manual fat binary creation (handled by Native Assets)
- Add rsync to copy bdk-ffi source to native/ for publishing
- Update to work with uniffi 0.30.0 library mode
Add hook/build.dart to compile native libraries automatically for the\
user's platform during dart/flutter pub get, eliminating manual build\
steps for users and the need to manage pre-compiled binaries.
@reez
Copy link
Collaborator

reez commented Nov 24, 2025

@Johnosezele if you can review this too

@kumulynja
Copy link
Contributor Author

kumulynja commented Nov 24, 2025

@reez @Johnosezele Don't be scared by the big number of files changed, you don't have to review the /native folder since that is really just a copy of the /bkd-ffi/bdk-ffi folder so that the build hook has the source to build the lib from.
For publishing of the package it is needed that this source code is in the package like this, since git submodules do not work for pub.dev. Also the native_toolchain_rs package used in the build hook expects this code to be either in a folder named native or rust. So that's the main reason of the file changes, I didn't find a way around it to be able to publish the package.
This copy is being done automatically in the generate_bindings.sh script by the way.

@Johnosezele
Copy link
Contributor

@Johnosezele if you can review this too

Sure!

@reez
Copy link
Collaborator

reez commented Nov 25, 2025

side note: ci on repo passes now via #11 not sure if you need to rebase on that and/or if we can get this PR ci passing even though it targets 0.30.0

@reez reez mentioned this pull request Nov 25, 2025
15 tasks
@reez
Copy link
Collaborator

reez commented Nov 26, 2025

I really like the ideas in this pr, but as I've been looking at this pr more I think things would be clearer as separate PRs, as an example splitting things like these out from each other:

  • uniffi upgrade to 0.30.0
  • native assets migration

Thoughts?

@kumulynja
Copy link
Contributor Author

kumulynja commented Nov 26, 2025

I really like the ideas in this pr, but as I've been looking at this pr more I think things would be clearer as separate PRs, as an example splitting things like these out from each other:

  • uniffi upgrade to 0.30.0
  • native assets migration

Thoughts?

Yes, although I think there is not much done around migration to uniffi v0.30.0 specifically in this PR other than using bdk-ffi v2.3.0-alpha, which is the first bdk-ffi version using uniffi v0.30.0 if I am not mistaken. Most (if not all) of the migration work is done in bdk-ffi for that.

The reason why I needed that is because the version of uniffi-dart that has Native Assets support doesn't work for < 0.30.0, and this PR actually is more (pretty much completely) about setting bdk-dart up for Native Assets support and so to avoid needing to have platform specific code or binary publishing/binding.

So yeah, not sure if you want to have bdk-ffi-v2.3.0-alpha working without Native Assets first as well?

@Aniket-pd
Copy link
Contributor

Most of the large diff comes from the native source copy, so I focused on the functional parts. The build hook and pubspec changes look reasonable. I agree splitting uniffi 0.30 upgrade and Native Assets migration into separate PRs would make review much easier.

@kumulynja
Copy link
Contributor Author

kumulynja commented Nov 29, 2025

Most of the large diff comes from the native source copy, so I focused on the functional parts. The build hook and pubspec changes look reasonable. I agree splitting uniffi 0.30 upgrade and Native Assets migration into separate PRs would make review much easier.

@Aniket-pd As mentioned in previous comments:

  • The native source copy is needed for the build hook to be able to build the native library dynamically when pulled/run into a project, but yes, it's an exact copy of bdk-ffi, so nothing to review there indeed.
  • There is really nothing specifically done for migrating to uniffi v0.30 in this PR. The whole PR is about the setup to use the uniffi-dart version with Native Assets which requires uniffi v0.30 for the moment. And that's why bdk-ffi v2.3.0-alpha.0 was used. Other than changing the bdk-ffi version, there is nothing done for migration to uniffi v0.30 in this PR.

@Johnosezele
Copy link
Contributor

Thanks @kumulynja this native assets approach really makes things seamless to publish to pub.dev with just the build hook and less maintenance overhead in the future. I'll leave some of my observations.

@Johnosezele
Copy link
Contributor

The dart CLI example lives in /example, but we already have an /examples/ directory beside it. Could we rename /example to something specific like /bdk-dart-cli to avoid confusion?
On my m/c is it took up to 6 mins for the build hook to run completely on dart run for the first time. Not a blocker, just fyi in case we want to mention expected build time or look into caching....

@Johnosezele
Copy link
Contributor

Can we add native/ to .gitignore instead? To solve the publishing requirement, we can use a pre_publish script that copies the files over just before running pub publish.

@kumulynja
Copy link
Contributor Author

Can we add native/ to .gitignore instead? To solve the publishing requirement, we can use a pre_publish script that copies the files over just before running pub publish.

That would be a good idea, but with a different approach as mentioned above, I think we will not need it anymore as the native folder will not have anything copied anymore and be way leaner.

Thanks a lot for the thorough review and great remarks, all valid points.

I will work on this PR in the coming weekend again to get it right.

@kumulynja
Copy link
Contributor Author

kumulynja commented Dec 13, 2025

@reez @Johnosezele I resolved all issues. The native folder is now the place where bdk-ffi is "wrapped"/exposed to generate the Dart bindings from and it also has everything for the build hook as well. So copying from the root to the native folder isn't needed anymore, and neither is the submodule. It also makes the script to generate bindings simpler.
I also updated and cleaned up everything from the README to the example, demo, tests, ci and scripts.

The only thing that we should wait for before merging maybe is removing the patch to my fork of bdk-ffi in which "lib" is added as crate-type: bitcoindevkit/bdk-ffi#924
This change in bdk-ffi is needed to be able to expose bdk-ffi in lib.rs in the native folder. Once it is merged there, the patch to my fork can be removed here.

Let me know if you have any other remarks. Thanks!

@Johnosezele
Copy link
Contributor

uTACK! the /native folder looks cleaner now. I was going to ask why targets was removed intially but thankfully it was re-added in 0eae013. I shall wait for #924 so I can eventually test. Thanks!

@reez
Copy link
Collaborator

reez commented Dec 19, 2025

very cool, bdk-ffi pr will take some time to let reviewers think on it on it so I wouldn't expect that to get merged ASAP, but everything here is looking nice! good job @kumulynja and good review @Johnosezele @Aniket-pd , and we will just figure out timing wise what works best for merging this based on the bdk-ffi pr status

@reez
Copy link
Collaborator

reez commented Dec 29, 2025

very cool, bdk-ffi pr will take some time to let reviewers think on it on it so I wouldn't expect that to get merged ASAP, but everything here is looking nice! good job @kumulynja and good review @Johnosezele @Aniket-pd , and we will just figure out timing wise what works best for merging this based on the bdk-ffi pr status

(just added my review + ack on the bdk-ffi pr)

@kumulynja
Copy link
Contributor Author

kumulynja commented Jan 5, 2026

@reez @Johnosezele The bdk-ffi PR was merged so I removed the patch to my fork. I also made it more clear in the README.md that users of the package will need the Rust toolchain installed for the build hook to work when they build their app. Let me know if you see anything else to fix and thanks for the support.

@Johnosezele
Copy link
Contributor

tACK d6a2b64
I would suggest squashing commit history into a few commits.

Comment on lines +20 to +22
bdk-ffi = { package = "bdk-ffi", git = "https://github.com/bitcoindevkit/bdk-ffi.git", branch = "master" }
uniffi = { version = "=0.30.0", features = ["cli"] }
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we can pin to a tag/commit 'rev = ' here, so we always build against the same code. Does this work?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can address this in a follow up pr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#17 followed up here

Copy link
Collaborator

@reez reez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK d6a2b64

I'll squash to address the comment about the commits

@reez reez merged commit 34ad41c into bitcoindevkit:main Jan 12, 2026
2 checks passed
@reez reez mentioned this pull request Jan 12, 2026
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.

4 participants