Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@prusnak
Copy link
Collaborator

@prusnak prusnak commented May 4, 2024

supersedes #2270 (this PR is just a rebase and squash of that PR)

ready for review
still in draft, because type checks (mypy and pyright) still need to be fixed

@prusnak prusnak force-pushed the blink-rebase branch 2 times, most recently from 96ccbf2 to 0ac3ce1 Compare May 4, 2024 10:37
@bitkarrot
Copy link
Contributor

@prusnak ok

@prusnak prusnak requested a review from dni May 20, 2024 09:02
@prusnak
Copy link
Collaborator Author

prusnak commented May 20, 2024

Maybe our typing guru @dni can help with the typing issues? :)

@bitkarrot
Copy link
Contributor

Hi -

I could use some feedback on the unit test which was written before @motorina0 came up with the current unit test structure, but afaik the rest of the PR should be in theory OK.

If @openoms could please confirm that this branch is working to satisfaction, including all the extensions, e.g. lnurlp, events, tipjar and any other commonly used extensions that would be most helpful

@bitkarrot
Copy link
Contributor

@openoms i confirmed this branch is working, i used this .env.example, not the one from previous

@prusnak @motorina0 unit test is for graphql not rest api, let me know if you need it to be adjusted to fit the others

@bitkarrot
Copy link
Contributor

Where are we with this current PR? i'm getting a little thin on free time here in the next few..., so would be good to let me know

@prusnak
Copy link
Collaborator Author

prusnak commented Jul 10, 2024

Where are we with this current PR? i

We still need to figure out the typing issues and fix them (mypy/pyright)

@motorina0
Copy link
Collaborator

Where are we with this current PR? i'm getting a little thin on free time here in the next few..., so would be good to let me know

I'm reviewing it now.

@openoms
Copy link
Contributor

openoms commented Jul 10, 2024

I've tested a good list of extensions using this branch using Zeus (connecting to LND) and with another Blink connected LNbits wallet mixed:

  • User Manager
  • LNURLw
  • LNURLp
  • TipJar
  • TPoS (receive + ATM)
  • Events
  • Invoices
  • SatsPayServer
  • Paywall
  • LNCalendar - Waiting for payment...

only has an issue with the LNcalendar - the incoming payment is not picked up - only getting Waiting for payment... despite successful payment from Zeus and from another lnbits wallet.
The problem with LNcalendar might be not related to the Blink integration at all, but it does work on a CLN backed LNbits v0.12.2.

Apart from the documentation change suggestion above I found this PR to be fully functional and working as expected.

@motorina0
Copy link
Collaborator

I have reviewed the code and made some refactoring.
The fine-grained commits can be found in this PR: #2575

@motorina0
Copy link
Collaborator

motorina0 commented Jul 10, 2024

@openoms regarding

the incoming payment is not picked up

This is expected, the websocket connection is not implemented, I will handle that next.

@codecov
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 25.52083% with 143 lines in your changes missing coverage. Please review.

Project coverage is 60.67%. Comparing base (eda7e35) to head (65e2611).

Files Patch % Lines
lnbits/wallets/blink.py 23.52% 143 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2477      +/-   ##
==========================================
- Coverage   61.35%   60.67%   -0.68%     
==========================================
  Files          69       70       +1     
  Lines        9925    10117     +192     
==========================================
+ Hits         6089     6138      +49     
- Misses       3836     3979     +143     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@prusnak
Copy link
Collaborator Author

prusnak commented Jul 10, 2024

The CI is green now, thanks @motorina0!

Can you please retest @openoms with the changes from Vlad? If you say it still works, we can merge 🎉

@prusnak
Copy link
Collaborator Author

prusnak commented Jul 10, 2024

Please wait with the testing until we merge PR #2577 into this PR so we can also test WebSockets

@motorina0
Copy link
Collaborator

@openoms regarding

the incoming payment is not picked up

This is expected, the websocket connection is not implemented, I will handle that next.

Done, payment notifications can be tested now.

@prusnak prusnak marked this pull request as ready for review July 10, 2024 14:59
@prusnak
Copy link
Collaborator Author

prusnak commented Jul 10, 2024

CI not failing anymore.

Marked as ready for review (turning off the draft status).

@openoms
Copy link
Contributor

openoms commented Jul 10, 2024

@motorina0 ran a quick test with the updates using the websocket.
the basic wallet functions and Tpos receive and send works.

Found the LNcalendar unreliable especially when paying the invoice with a Blink funded LNbits subaccount or with another Blink wallet.
Either having no receive confirmation on the LNcalendar page or getting this:
Screenshot from 2024-07-10 16-55-45

Comment on lines +453 to +456
settlementVia {
... on SettlementViaLn {
preImage
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The payments are not picked up when paying with Blink wallet or a Blink funded LNbits wallets which means that the intra-ledger payments are not picked up (not sure why only in LNcalendar).
The Blink backend does decide to settle depending on the invoice. It does return the preimage in this case also since it is known when creating the invoice.

.... on SettlementViaIntraLedger needs to be added to the query to cover for this case:

Suggested change
settlementVia {
... on SettlementViaLn {
preImage
}
settlementVia {
... on SettlementViaLn {
preImage
}
... on SettlementViaIntraLedger {
preImage
}

Copy link
Contributor

Choose a reason for hiding this comment

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

this change does not seem to be necessary as Blink intraledger payments are being picked up in most extensions

@openoms
Copy link
Contributor

openoms commented Jul 11, 2024

@motorina0 ran a quick test with the updates using the websocket. the basic wallet functions and Tpos receive and send works.
Found the LNcalendar unreliable especially when paying the invoice with a Blink funded LNbits subaccount or with another Blink wallet. Either having no receive confirmation on the LNcalendar page or getting this: Screenshot from 2024-07-10 16-55-45

This is most likely an issue with the LNCalendar extension and not with the Blink funding source. You can try with an LNbits funding source (https://demo.lnbits.com), I would expect the same error.

Just curious, are you using LNCalendar in any particular way, or was it a random choice for testing.

I did test LNcalendar with a CLN backed LNbits instance where it had no problems. It is a useful extension I would plan to use myself and testing it particularly beacuse it was the only one not working. Hope to have a solution here: #2477 (comment)

@motorina0
Copy link
Collaborator

I am not able to reproduce the issue. Payment was successful, no errors in the console (LNbits v0.12.8, LNCalendar v0.1.2).
I have the Blink funding source configured.
image

Is there a special scenario on how I can reproduce this?

image

@openoms
Copy link
Contributor

openoms commented Jul 15, 2024

I am not able to reproduce the issue. Payment was successful, no errors in the console (LNbits v0.12.8, LNCalendar v0.1.2). I have the Blink funding source configured. image

Is there a special scenario on how I can reproduce this?

image

Yes, the payments in LNcalendar are still not picked up for transactions where the invoice is paid with an LNbits wallet on the same instance (which is connected to Blink). The accounting does happen - sats are spent from the wallet and arrive in the LNcalendar wallet, but the appoinment booking is not successful.

I had no problems now paying from Zeus (LND) and with a Blink wallet of another user.

@arcbtc
Copy link
Member

arcbtc commented Jul 16, 2024

Sounds like an issue with lncalendar and self payments, rather than blink

@talvasconcelos
Copy link
Collaborator

Possible fixed with lnbits/lncalendar#8

@prusnak
Copy link
Collaborator Author

prusnak commented Jul 17, 2024

@dni @talvasconcelos can you please review so we can finally merge?

@arcbtc
Copy link
Member

arcbtc commented Jul 19, 2024

image
Blink missing from the server UI

@prusnak
Copy link
Collaborator Author

prusnak commented Jul 19, 2024

Blink missing from the server UI

Weird - I see it in both lnbits-funding-sources.js and bundle.min.js 🤷

@openoms
Copy link
Contributor

openoms commented Jul 19, 2024

image
Blink missing from the server UI

Got it on my instance (updated to latest and restarted):
IMG_20240719_154653.jpg

@arcbtc
Copy link
Member

arcbtc commented Jul 19, 2024

Weird, i must have some bundle issue. My mistake, will try again 👍

@arcbtc
Copy link
Member

arcbtc commented Jul 19, 2024

Its outside of the scope of this pr, but the issue was LNBITS_ALLOWED_FUNDING_SOURCES in env needing Blinkwallet, even though LNBITS_ADMIN_UI=true was set.

bitkarrot and others added 9 commits July 19, 2024 21:25
* refactor: mark `graphql_query` as private (`_` prefix)

* feat: set default value for `blink_api_endpoint`

* fix: raise if HTTP call failed

* refactor: move private method to the bottom

* refactor: make `wallet_id` a property

* fix: key mapping for attribute

* chore: fix `mypy`

* chore: fix `make check`

* refactor: extract query strings

* refactor: extract `BlinkGrafqlQueries` class

* chore: code clean-up

* chore: add `try-catch`

* refactor: extract `tx_query`

* chore: format grapfhql queries

* fix: set funding source class

* chore: `make format`

* fix: test by following the other patterns
* feat: add websocket connection to blink

* feat: close websocket on shutdown
@arcbtc arcbtc merged commit 7298c46 into dev Jul 19, 2024
@arcbtc arcbtc deleted the blink-rebase branch July 19, 2024 20:32
@openoms
Copy link
Contributor

openoms commented Jul 24, 2024

Thank you all who have worked on improving and reviewing this PR. As you might know there is a 1M sats bounty offered for this feature which is now completed and ready to be paid.

The original initiative and the bulk of the work was taken up by @bitkarrot who would be entitled to receive the bounty, but given the additional work done (especially by @motorina0 and all the reviewers) I’d like to make sure that we offer to share the bounty if wanted.

So please comment if you have an opinion about how it would be best to deal with the payout. Planning to finalize it by the end of this week.

@motorina0
Copy link
Collaborator

As far as I'm concerned the bounty belongs entirely to @bitkarrot

@prusnak
Copy link
Collaborator Author

prusnak commented Jul 24, 2024

As far as I'm concerned the bounty belongs entirely to @bitkarrot

Same 👍

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.

7 participants