Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target
!example.config.toml
*.sqlite
Cargo.lock

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

? why include this commit

.vscode
mutants.out*
*.ikm
Expand Down
4 changes: 4 additions & 0 deletions payjoin-ffi/dart/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ doc/api/
# Auto-generated bindings
lib/payjoin.dart
lib/bitcoin.dart

# Auto-generated precompiled binaries
precompiled_build/
precompiled_upload/
44 changes: 44 additions & 0 deletions payjoin-ffi/dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,48 @@

Welcome to the Dart language bindings for the [Payjoin Dev Kit](https://payjoindevkit.org/)!

## Using the bindings in your app

Declare the package as a dependency just like any other Dart package. When developing against the repo directly, point at the local path and let `flutter pub get` (or `dart pub get`) run the build hook:

```yaml
dependencies:
payjoin:
path: ../rust-payjoin/payjoin-ffi/dart
```
Comment on lines +10 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't the SOP be to get this from pub.dev? Why mention path?


The `hook/build.dart` script drives `native_toolchain_rust` (plus the precompiled-binaries helper) so that `flutter pub get` downloads the verified binaries when available or builds the native crate locally on demand.

If you prefer to inspect or regenerate `payjoin.dart` manually, run the binder script from the `payjoin-ffi/dart` directory:

```bash
bash ./scripts/generate_bindings.sh
```

This produces `lib/payjoin.dart` and the native artifacts under `target/`. These files are not tracked in the repository, so you should regenerate them locally whenever the Rust API changes.

## Precompiled binaries

This package supports downloading signed precompiled binaries or building locally via Dart's Native Assets hook.
If precompiled binaries are attempted but unavailable or verification fails, it falls back to building from source.

### pubspec.yaml configuration

In your app's `pubspec.yaml`, add the `payjoin` section at the top level (next to `dependencies`), like:

```yaml
payjoin:
precompiled_binaries:
mode: auto # auto | always | never
```

`mode` controls when the precompiled path is used:
- `auto` prefers local builds if Rust toolchain is detected, otherwise uses precompiled binaries
- `always` requires precompiled binaries and skips local builds
- `never` always builds from source via the build hook

If your tooling must rely on the signed GitHub releases, set `mode: always` and configure `artifact_host`/`public_key` to point at the published assets so `PrecompiledBuilder` can download the `precompiled_<crateHash>` bundles (macOS/iOS + Android builds are published via `.github/workflows/payjoin-dart-precompile-binaries.yml`).

## Running Tests

Follow these steps to clone the repository and run the tests.
Expand All @@ -16,3 +58,5 @@ bash ./scripts/generate_bindings.sh
# Run all tests
dart test
```

Maintainers: see `docs/precompiled_binaries.md` for CI details, manual release steps, and configuration.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this file exists as of commit 1e57740 where this is introduced

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes, adding it now.

1 change: 1 addition & 0 deletions payjoin-ffi/dart/native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!Cargo.lock
Loading