I am currently working on a Bitcoin Cash related project with the goal of helping contribute to the ecosystem. I am getting to the point where I will soon be ready to start integrating with the protocol, but I am not quite sure how to proceed. The workflow I am looking for goes something like this:
- User visits my website
- User is presented a QR code that is for a specific payment amount (always $0.25 usd)
- User scans QR code and submits payment
- Website is listening for the broadcast of the payment (0-conf), and as soon as the network broadcasts the payment, a callback is executed therefore the user's session knows that their payment has been received.
I know the Bitcoin Cash Fund project is currently working on a bitcoincash.js library but it's not ready yet. Since that is the case, I assume I am going to have to fork the current bitcoin core js library and make it work with the cashaddr format to generate addresses for the QR codes.
The other piece that I am unclear about is how to go about listening for broadcasted txns. I see there is a blockchain.info websocket server, which I assume since they announced full support for BCH, that it will work with BCH: https://blockchain.info/api/api_websocket
But, from what I can tell, I don't think it's possible to use the testnet?
So that is making me wonder if relying on a 3rd party for this, especially with it being 0-conf, is a bad idea? If so, I assume the answer is to run my own node and somehow have my own websocket server query it at regular intervals. Is that correct?
Also, on the topic of pub/sub for this, what is the best way for the client know a payment was made for that specific user? Is it to just generate a new address with each visit to the site? Or is it to include some sort of uuid as metadata with the txn?