Because I received a coupe of DMs pointing out a bug in this code: in JavaScript βthisβ is implicitly defined in every function scope. If there is no object attached (function is not a method) it points to the global object (window or globalThis).
There is no bug in this code. ecash fixes it globally.
View quoted note β
Egge
egge@npub.cash
npub1mhcr...c226
Building https://npub.cash π₯ Working on awesome nostr, cashu and Lightning stuff πβ‘οΈ
Wanna use cashu-ts in your browser?
π
View quoted note β
I have spent several weeks trying to replace the Blink API wrapper of npub.cash with a Cashu native alternative and its been a wild ride.
While Cashu mints do support WebSockets for realtime updates, it turned out that WebSockets are pretty difficult to work with, when you are trying to keep them and the subscriptions alive for long periods (in my case days).
But there is a second issue: You see Cashu mints enfore rather strict rate limits on their users. This is important as Cashu is account-less and preventing spam attacks is difficult. Usually this is no issue, as regular users interacting with a mint do not hit these limits. But npub.cash is a funnel. Instead of every user using their own IP to hit the mint, with npub.cash every user "proxies" through the services server.
Turns out this second issue is much bigger than the first one and WebSockets do not solve this. So I decided to build a scheduler that make sure that all mint communication happens as frequent as possible, but never to frequent. This module also solves the first issue, as it allows to queue polling tasks in a lower priority making sure the service stays up to date about payment activity.
If the server restarts it wont hit the mint with a gazillion subs at once, it will make sure they are evenly spread out through low priority calls, while always making sure there is "rate" left for calls that need to be instant.
I built this module externally, so theoretically I could publish it as npm package for structured and timed mint communication. Please let me know if you could use something like this (because as of right now I don't think most Cashu applications would benefit from this, npub.cash is not your usual Cashu application).
After doing some testing I think it is ready to put into an experimental version of npub.cash. I hope to release this on reckless-npub.cash by the end of the week.


ecash fixes it
I think I finally got it working π₯
mood rn. I think I just embarked on my villain arc. 

πIs there something that you always wanted to change about cashu-ts? Now is the time. I started drafting what a possible version 3 could look like. If you want to break stuff, let me know: 
GitHub
cashubtc/cashu-ts
A TypeScript library for building Cashu wallets. Contribute to cashubtc/cashu-ts development by creating an account on GitHub.
cashu-ts v2.3 will support NUT22 auth π


My new gym has no racks o0
Does anyone use the static methods exposed by CashuWallet and CashuMint in cashu-ts?
NUT21 & NUT22 are the best approach to authentication that I have ever seen. 

And we are already prepping the next RC π₯ View quoted note β
Cashu-ts contributors are just built differently! Just released 2.2 stable version (blog post coming tomorrow), meanwhile so much great new stuff came in that we can release a 2.3 RC almost immediately π₯
You guys are killing it ππ₯
nostr is the glue
GM βοΈ
Good night nostr π 

Now and then I get some BCH posts in my Reddit Feedβ¦ the cope is reeeeal π₯
Do Browsers implement ping/pong on WebSockets according to the WebSocket RFC?
Hey ChatGPT, please put this in code. Thanks! 

Cashu should be fun, WebSocket boilerplate is not. Lets fix this. π

