-
Notifications
You must be signed in to change notification settings - Fork 9
feat: wallet improvements #724
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
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d489697
bip321 support
frnandu 0c09ee7
Merge branch 'master' into feat/bip321
frnandu ac5fd08
Merge remote-tracking branch 'origin/master' into feat/bip321
frnandu 1d19078
feat(nwc): add optional maxFeeMsat to pay (NWC-321 max_fee)
frnandu fe41c63
0.9.2
frnandu ece5cf5
bolt12 wallet
frnandu 5b90677
no wallet compatible
frnandu 809a755
Merge branch 'master' into feat/bip321
frnandu 3416e63
add timeout to nwc makeHoldInvoice
frnandu 484f931
fix: not add lnurl wallet if invalid
frnandu 06b4acc
perf: improve rust verifier memory usage
frnandu 6478115
remove deps
frnandu 9da87fd
Merge branch 'master' into feat/bip321
frnandu 4e293e9
fix case insensitive
frnandu 9f03416
fix i18n and enum
frnandu ee54edf
fix removal of offerId
frnandu 64b3d20
format
frnandu 0d340ba
fix: add tbs
frnandu 5147eba
fix: missing amount in bip321
frnandu aabf7dc
Merge master into feat/bip321
frnandu 1311be7
Merge Rust verifier memory fix into feat/bip321
frnandu 0289ce5
better wallet add UI/UX + cashu mint recommendations / nip-87
frnandu 4979ac5
test(cashu): cover recommendation edge cases
frnandu d4a3ee8
feat(wallets): add LNbits provider
frnandu ade5401
feat(sample): support desktop QR scanning
frnandu cc77b01
lnbits wallet provider
frnandu 1db0a4c
cashu logo grey background 2
frnandu fb82b6a
improve wallet connection detection
frnandu 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
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // ignore_for_file: avoid_print | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:ndk/ndk.dart'; | ||
|
|
||
| void main() async { | ||
| final ndk = Ndk.emptyBootstrapRelaysConfig(); | ||
|
|
||
| // Provide an NWC connection URI and the BOLT11 invoice to pay. | ||
| final nwcUri = Platform.environment['NWC_URI']!; | ||
| final invoice = Platform.environment['INVOICE']!; | ||
| final amountMsat = int.tryParse( | ||
| Platform.environment['AMOUNT_MSAT'] ?? '', | ||
| ); | ||
|
|
||
| final connection = await ndk.nwc.connect(nwcUri); | ||
|
|
||
| // NWC-321 expects a BIP-321 URI. This example contains only a BOLT11 | ||
| // `lightning` instruction. | ||
| final payment = Bip321.fromBolt11(invoice); | ||
|
|
||
| final response = await ndk.nwc.pay( | ||
| connection, | ||
| payment: payment, | ||
| // Required only when the BOLT11 invoice has no amount. | ||
| amountMsat: amountMsat, | ||
| payerNote: Platform.environment['PAYER_NOTE'], | ||
| ); | ||
|
|
||
| print('transaction id: ${response.transactionId}'); | ||
| print('state: ${response.state}'); | ||
| print('instruction type: ${response.instructionType}'); | ||
| print('amount: ${response.amountMsat} msats'); | ||
| print('fees paid: ${response.feesPaid} msats'); | ||
| print('preimage: ${response.preimage}'); | ||
|
|
||
| await ndk.destroy(); | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // ignore_for_file: avoid_print | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:ndk/ndk.dart'; | ||
|
|
||
| void main() async { | ||
| final ndk = Ndk.emptyBootstrapRelaysConfig(); | ||
|
|
||
| // Provide an NWC connection URI. Omit AMOUNT_MSAT for a variable amount. | ||
| final nwcUri = Platform.environment['NWC_URI']!; | ||
| final amountMsat = int.tryParse( | ||
| Platform.environment['AMOUNT_MSAT'] ?? '', | ||
| ); | ||
|
|
||
| final connection = await ndk.nwc.connect(nwcUri); | ||
| final response = await ndk.nwc.receive( | ||
| connection, | ||
| amountMsat: amountMsat, | ||
| description: Platform.environment['DESCRIPTION'], | ||
| ); | ||
|
|
||
| // For now, use a wallet whose `receive` implementation returns a BOLT11 | ||
| // `lightning` instruction in this BIP-321 URI. | ||
| print('BIP-321 URI: ${response.bip321}'); | ||
| print('transaction id: ${response.transactionId}'); | ||
|
|
||
| await ndk.destroy(); | ||
| } |
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.
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.
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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Wrap the NWC example workflows in
try/finallyand callawait ndk.destroy()from thefinallyblock. If connection or payment/receive processing fails, cleanup must still run so subscriptions and other NDK resources are not left active.📍 Affects 2 files
packages/ndk/example/nwc/pay.dart#L17-L38(this comment)packages/ndk/example/nwc/receive.dart#L16-L28🤖 Prompt for AI Agents