Last active
May 2, 2024 05:54
-
-
Save dhjw/d1656b56d3a99f9062514dd12661899d to your computer and use it in GitHub Desktop.
Accept BCH donations and display message instantly
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
<?php | |
// address used throughout page and script. could also just be hardcoded without PHP. | |
$addr = 'qqvppp5pe4sce8qyvyncdrhekgkxcyw2hczvervmp8'; | |
?> | |
<html> | |
<head> | |
<title>Donate BCH</title> | |
<style> | |
body { font:16pt arial; } | |
#address { font:18pt arial; } | |
#address a, #address a:visited { color:black; text-decoration:none; } | |
#address a:hover { text-decoration:underline; } | |
#receivedText { font:18pt arial; color:green; } | |
</style> | |
</head> | |
<body> | |
<center> | |
Send your donation to:<br> | |
<br> | |
<div id="address"><a target="_blank" href="https://blockchair.com/bitcoin-cash/address/<?=$addr?>"><?=$addr?></a></div> | |
<br> | |
<img src="https://chart.googleapis.com/chart?cht=qr&chs=240x240&chld=L|0&chl=<?=$addr?>"><br> | |
<br> | |
<div id="receivedText"></div> | |
<script> | |
var query = {v:3,q:{find:{"out.e.a":"<?=$addr?>"}}}; | |
var sse = new EventSource("https://bitsocket.fountainhead.cash/s/" + btoa(JSON.stringify(query))); | |
sse.onmessage = (e) => { | |
var d=JSON.parse(e.data); | |
// console.log('onmessage data=',d); | |
if(d.type == "mempool"){ | |
document.querySelector('#receivedText').innerHTML = 'Thank you for your donation!'; | |
setTimeout(()=>{ document.querySelector('#receivedText').innerHTML = ''; }, 10000); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment