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

Periodically check if we have inflight payments #635

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benthecarman
Copy link
Collaborator

@benthecarman benthecarman commented Oct 27, 2023

This will only work on chrome android but it should help with stuck htlc force closures. Every hour it'll check our storage and if we have an inflight payment, it'll give a push notification.

Service worker is entirely written by chatgpt, so please review. When testing it did work though!

To test you can change if (payment && payment.status === "InFlight") to instead check for Succeeded and that'll give you the notification if you have any successful payments in your storage.

https://developer.mozilla.org/en-US/docs/Web/API/Web_Periodic_Background_Synchronization_API

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 27, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: bbd8920
Status:🚫  Build failed.

View logs

@benthecarman
Copy link
Collaborator Author

hmm do we need to update nodejs version or something, not sure why it says periodic sync doesn't exist

@futurepaul
Copy link
Collaborator

really smart solution for android. we could also probably do something similar to breeze on ios where the notification server just lets them know they need to check on their wallet at a regular interval if they haven't loaded it in over a week

some stuff to figure out that I would like to be helpful with:

  1. we need to make sure this will get updated when we want to update it (browsers love to cache service workers)
  2. need to make sure this doesn't get cached and make dev hell (basically the same as above, but for dev mode)
  3. need to work this into vite build steps to get typescript right (which will also be important for when we want to use wasm in a service worker). I had that working in my test repo, but when I tried to do the same thing in https://github.com/MutinyWallet/mutiny-web/tree/service-worker-tmp-paul/src/service-worker I was getting typescript errors ... but for starters putting a .ts file in public doesn't make sense because it's not a static file it needs to be transformed to .js before it ships to browser

@benthecarman
Copy link
Collaborator Author

We can also do this with the android app, that might be an easier first approach

https://capacitorjs.com/docs/apis/background-runner

@futurepaul futurepaul marked this pull request as draft November 14, 2023 17:32
@futurepaul futurepaul added the experiment No plans to merge yet, just having fun label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment No plans to merge yet, just having fun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants