-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add QR code generation tool #119
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| from .assets import MAINNET_ASSETS, TESTNET_ASSETS, resolve_asset_name, resolve_liquid_asset_id | ||
| from .bitcoin import BitcoinWalletManager | ||
| from .bolt11 import decode_bolt11_fields | ||
| from .qr import decode_qr, generate_qr | ||
| from .qr import decode_qr, generate_qr, render_qr_terminal | ||
| from .wallet import WalletManager | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
@@ -1980,6 +1980,21 @@ def sideswap_swap_status(order_id: str) -> dict[str, Any]: | |
| return manager.status(order_id) | ||
|
|
||
|
|
||
| def qr_generate( | ||
| data: str, | ||
| output_dir: str | None = None, | ||
| filename: str | None = None, | ||
| terminal: bool = False, | ||
| ) -> dict[str, Any]: | ||
| """Generate a QR PNG for arbitrary content, optionally with terminal art.""" | ||
| qr_dir = output_dir or str(get_manager().storage.qr_dir) | ||
| path = generate_qr(data, qr_dir, filename=filename) | ||
|
Comment on lines
+1990
to
+1991
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function does not have any type of restriction on data's length. It may generate data overflow errors or similars. |
||
| result: dict[str, Any] = {"content": data, "qr_code_path": path} | ||
| if terminal: | ||
| result["terminal_qr"] = render_qr_terminal(data) | ||
| return result | ||
|
|
||
|
|
||
| def qr_decode(image_path: str) -> dict[str, Any]: | ||
| """Decode a QR code from an image file and return the raw string content.""" | ||
| content = decode_qr(image_path) | ||
|
|
@@ -2301,5 +2316,6 @@ def jan3_purchase_ln_username( | |
| "jan3_rebind_wallet": jan3_rebind_wallet, | ||
| "jan3_ln_check_username": jan3_ln_check_username, | ||
| "jan3_purchase_ln_username": jan3_purchase_ln_username, | ||
| "qr_generate": qr_generate, | ||
| "qr_decode": qr_decode, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.