Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade v0.20.0 #33

Merged
merged 20 commits into from
Aug 21, 2024
Merged

Upgrade v0.20.0 #33

merged 20 commits into from
Aug 21, 2024

Conversation

BitcoinZavior
Copy link
Contributor

[0.20.0]

APIs added

  • Make backwards-compatible v2 to v1 sends possible.

APIs changed

  • Removed contribute_non_nitness_input from v1 & v2.
  • Allow receivers to make payjoins out of sweep transactions (#259).
  • Encode &ohttp= and &exp= parameters in the &pj= URL as a fragment instead of as URI params (#298)

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

My big concern is why there is a uniffi feature separate from what integration tests appear to be using. If the feature is to distinguish between the uniffi bindings here and the flutter (and other language bindings?) Then I wonder why they live in this crate rather than where they're consumed. Perhaps this is the well reasoned best design and some repetition is ok. I don't know, it just smelled to me on first blush.

Other than this this looks ok to me. I can't believe how complete these bindings seem to be 🔥

@@ -0,0 +1,46 @@
## [0.18.0]
Copy link
Contributor

Choose a reason for hiding this comment

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

will this include an [0.20.0] at the top? or am I confusing payjoin-ffi version with payjoin crate version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the changelog has been updated to include 0.20.0

Cargo.toml Outdated
Comment on lines 30 to 31
payjoin = {version = "=0.20.0", features = ["send", "receive", "base64", "v2", "io"] }
#payjoin={ git = "https://github.com/payjoin/rust-payjoin", rev = "941a6798f52f60d72061fc0a02b5b42146321453", features = ["send", "receive", "base64", "v2", "io"]}
Copy link
Contributor

Choose a reason for hiding this comment

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

if we follow semver faithfully, you could put "0.20.0" here and it would automatically upgrade to patch versions. This would be helpful in the case a security patch was released. Then, you can use payjoin-ffi patch versions for your own patches separate from the underlying dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good 👍

bitcoincore-rpc = "0.19.0"
http = "1"
payjoin-directory = { git = "https://github.com/payjoin/rust-payjoin", features = ["danger-local-https"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose you deserve a release from us if you're using payjoin-directory in tests

@@ -0,0 +1,36 @@
## [0.18.0]
This release updates the python library to `payjoin` version `0.18.0`.
Copy link
Contributor

Choose a reason for hiding this comment

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

0.20.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

0.20.0 has been added now 👍

- `V2PayjoinProposal` exposes `process_res`, `extract_v1_req`, `extract_v2_req`, `is_output_substitution_disabled`, `owned_vouts`, `psbt` &
`utxos_to_be_locked`.
#### io module
- Exposed `fetch_ohttp_keys()` to fetch the `ohttp` keys from the specified `payjoin` directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

fetch_ohttp_keys includes a whole http client. I might consider releasing this io stuff as a separate payjoin-ffi feature and downstream as a separate package (e.g. payjoin and payjoin-io pypy packages) since if I were a downstream user it'd be a lot of bloat to bring in a whole foreign http and tls stack just to make a single request instead of writing it in my target language. Just an optimization for later. Maybe this comment turns into its own issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fetch_ohttp_keys function is particularly valuable when working with v2, especially for those who prefer not to implement it from scratch. If we proceed with moving it into payjoin-io, we may consider creating a dedicated uniffi crate for it as well and then importing it in this uniffi package.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure you want to commit and not ignore compiled binaries (I think that's what these and the .so and .dll files are)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far, we've only released a Python pre-release using uniffi and have been using the bindings and binaries for testing Payjoin in Python. For the stable release, we plan to ignore the compiled binaries and bindings. Instead, we'll bundle it similarly tobdk-ffiand provide instructions for users to generate the bindings themselves if they need to.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like bdk-ffi does not commit the generated bindings. Assuming that's what this is, why do you choose to commit them in this repo rather than leave instructions to generate bindings? Is this part of the release process to show the completed, released source code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in the above comment.

Comment on lines -327 to +329
generate_script: impl Fn() -> Result<Vec<u8>, PayjoinError>,
generate_script: Box<dyn GenerateScript>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume making the trait is necessary to produce bindings, but I'm not sure because this change is only happening now. Do I understand correctly? Was this just a stub before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you’ve understood correctly. The trait is essential for uniffi. Initially, the function was only implemented for Flutter. With this commit, I've separated the function to accommodate both use cases.

@@ -18,7 +18,7 @@ jobs:
override: true
profile: minimal
- name: Build on Rust ${{ matrix.toolchain }}
run: cargo build --color always --all-targets
run: cargo build --color always --all-targets --features enable-danger-local-https
Copy link
Contributor

Choose a reason for hiding this comment

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

If this isn't testing the code path used with the uniffi feature, what is it testing? Why have a second implementation for many functions like pj_uri_builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially, we weren’t planning to test the code in Rust itself but rather in the platform code. However, we encountered an issue with signing using v2 in Flutter recently, which prompted us to create this integration test code as part of the debugging process.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for having a second implementation for functions like pj_uri_builder is that we encountered a cannot move out of Arc error when using the uniffi version of the code on the Flutter side.

Comment on lines 540 to 541
#[cfg(feature = "uniffi")]
#[cfg(feature = "uniffi")]
Copy link
Contributor

Choose a reason for hiding this comment

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

dup

@BitcoinZavior
Copy link
Contributor Author

My big concern is why there is a uniffi feature separate from what integration tests appear to be using. If the feature is to distinguish between the uniffi bindings here and the flutter (and other language bindings?) Then I wonder why they live in this crate rather than where they're consumed. Perhaps this is the well reasoned best design and some repetition is ok. I don't know, it just smelled to me on first blush.

Other than this this looks ok to me. I can't believe how complete these bindings seem to be 🔥

The separation of the uniffi feature is deliberate, addressing its unique requirements—like wrapping complex structs with Arc for shared parameters and working around the lack of direct callback support. While this approach introduces some redundancy, it isolates these limitations from the core codebase, preventing them from affecting testing or Flutter integration. I plan to further reduce code duplication in future upgrades.

@BitcoinZavior
Copy link
Contributor Author

BitcoinZavior commented Aug 18, 2024

Other than this this looks ok to me. I can't believe how complete these bindings seem to be 🔥

Thanks! 🧡

@BitcoinZavior BitcoinZavior merged commit 9e79770 into main Aug 21, 2024
4 checks passed
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