Skip to content

Instantly share code, notes, and snippets.

@bumi
Created July 11, 2021 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bumi/08543c275fd18d29fe319efa86b7474e to your computer and use it in GitHub Desktop.
Save bumi/08543c275fd18d29fe319efa86b7474e to your computer and use it in GitHub Desktop.
ln me example
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>LnMe</title>
</head>
<link rel="stylesheet" href="/files/assets/lnme.css" id="lnme-style">
<body>
<script src="/files/assets/lnme.js"></script>
<script type="text/javascript">
function dropSomeSats(e) {
e.preventDefault();
// somehow get the amount of sats
var amount = prompt("How much?");
// init new LnMe object.
var lnme = new LnMe({
value: parseInt(amount),
memo: "Thanks!",
createInvoiceUrl: function() { return `https://yoururl.com/path/to/create/invoices`; },
watchPaymentUrl: function() { return `https://yoururl.com/path/to/${this.invoice.payment_hash}`; },
newAddressUrl: function() { return `https://yoururl.com/path/create/address`; }, // optional for on-chanin payments
});
// request a new invoice, show the QR code overlay and poll for payments
lnme.request();
return;
}
// register the event listeners. here whenever a user clicks on an element with the class .drop-some-sats
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.drop-some-sats').forEach(function(element) {
element.addEventListener('click', dropSomeSats);
});
});
</script>
<a href="#" class="drop-some-sats">
Send me some sats
</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment