-
Notifications
You must be signed in to change notification settings - Fork 79
feat: Add Bitcoin Cashu support #20
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
base: main
Are you sure you want to change the base?
feat: Add Bitcoin Cashu support #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @yashbhutwala, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request integrates Cashu payment support into the x402 A2A library. It introduces enhanced functionality for defining Cashu payment requirements, including pre-configured mint URLs, and refines the payment processing workflow to explicitly manage Cashu payloads. These changes aim to provide a clear and robust mechanism for handling Cashu-based transactions within the system.
Highlights
- Cashu Payment Requirements: Added support for creating Cashu payment requirements, including default mint URLs for Bitcoin testnet and mainnet, and validation for numeric price inputs.
- Explicit Cashu Payload Handling: Modified wallet helper functions to explicitly process Cashu payment payloads, requiring direct submission of Cashu proofs and preventing implicit handling of Cashu tokens in general payment processing.
- Unit Test Coverage: New unit tests have been added to validate the correct creation of Cashu payment requirements and the proper processing of Cashu payments.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for Bitcoin Cashu payments by updating the core merchant and wallet logic. The changes are well-structured, adding a new 'cashu-token' payment scheme and handling its specific requirements, such as mint URLs and proofs. The inclusion of unit tests for the new functionality is a great practice. My review includes a couple of suggestions to improve code clarity and provide more helpful error messages, but overall, this is a solid implementation.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for Bitcoin Cashu payments. The changes include updating create_payment_requirements in merchant.py to handle the cashu-token scheme and modifying process_payment in wallet.py to process Cashu payloads. New unit tests have been added to cover the basic flow. My review focuses on improving code structure, enhancing error reporting for better debugging, and expanding test coverage to ensure the new functionality is robust. Overall, the implementation is solid, and the suggested changes are aimed at improving maintainability and reliability.
|
/gemini summary |
Summary of ChangesThis pull request significantly enhances the x402 library by integrating support for Bitcoin Cashu payments. It introduces a new payment scheme, Highlights
Changelog
Activity
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for Cashu payments by extending create_payment_requirements and process_payment to handle the cashu-token scheme. The changes include logic for creating payment requirements with Cashu-specific details like mint URLs and processing payments with provided Cashu proofs. Unit tests for the new happy path flows are also included.
My review focuses on improving the robustness and maintainability of the new logic. I've suggested improvements to price validation to prevent silent data loss, refactoring opportunities to reduce code duplication, performance enhancements for payload validation, and an expansion of the test suite to cover important failure scenarios. Overall, the changes are well-structured, and addressing these points will further strengthen the implementation.
e0d06b8 to
4d9e1d2
Compare
jorellis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. We're glad to see you're using the extra field for the Cashu-specific data—that's the right approach.
We have an architectural concern about adding this logic directly into the core create_payment_requirements function. Adding Cashu-specific arguments and if...then logic there will bloat the core library and make it hard to maintain as we add more payment methods.
We'd like to propose a more scalable "plugin" approach. We're thinking the new file structure would look like this:
python/
x402_a2a/
...
core/
(our existing core files)
partners/
__init__.py
cashu/
__init__.py
helpers.py <-- Your new code would go here
README.md
In this new partners/cashu/helpers.py, you would add your new functions (like create_cashu_payment_requirements and process_cashu_payment). The core functions would remain untouched.
This keeps our core library clean, stable, and scalable. It correctly separates the "partner implementation" from the "core logic" and lets each partner's code live in one isolated place.
Let us know your thoughts and if you would you be open to refactoring this PR to follow this structure? Thanks again for your contribution!
4d9e1d2 to
4deee86
Compare
Summary of ChangesThis pull request significantly extends the x402 library by introducing robust support for Bitcoin Cashu payments. It achieves this through a strategic refactoring that isolates Cashu-specific functionalities into a new 'partners.cashu' module. This design ensures that the core 'merchant' and 'wallet' components remain clean and adaptable to future payment schemes, while providing specialized helpers for Cashu payment requirement creation and processing. The changes include detailed validation for Cashu payments, comprehensive testing, and clear documentation to guide integration. Highlights
Changelog
Activity
|
|
@jorellis Thanks for the feedback! I've split the Cashu-specific handling out of the shared merchant/wallet flows into a partner plugin so the core surfaces stay scheme-agnostic. |
|
@jorellis what's next to get this PR merged? 🙏 |
|
Hi @yashbhutwala, it looks like there are a few merge conflicts with the current main branch. Once these are resolved, the PR may require another approval, but then should be ready to be merged. Thanks! |
9c97465 to
cb7b0f5
Compare
cb7b0f5 to
8d49099
Compare
@jorellis I have rebased and resolved merge conflicts. This should be good to go, please reapprove. 🙏 |
Summary
x402_a2a.partners.cashucore.merchantandcore.walletgeneric by rejecting Cashu schemes and delegating to the partner helpers