mirror of
https://github.com/bumi/lntip
synced 2025-06-16 09:45:35 +00:00
Add support to get an onchain Address
This commit is contained in:
parent
456ae2eb50
commit
e1882b8fcf
@ -155,6 +155,19 @@ class LnMe {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newAddress() {
|
||||||
|
let args = {
|
||||||
|
method: 'POST',
|
||||||
|
mode: 'cors',
|
||||||
|
header: { 'Content-Type': 'application/json' }
|
||||||
|
};
|
||||||
|
return this._fetch(`${this.baseURL}/v1/newaddress`, args)
|
||||||
|
.then(address => {
|
||||||
|
this.address = address;
|
||||||
|
return address;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
requestPayment() {
|
requestPayment() {
|
||||||
return this.addInvoice().then((invoice) => {
|
return this.addInvoice().then((invoice) => {
|
||||||
if (typeof webln !== 'undefined') {
|
if (typeof webln !== 'undefined') {
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
margin: 1em auto;
|
margin: 1em auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
.note {
|
||||||
|
font-size: 0.2em;
|
||||||
|
}
|
||||||
.wrapper h1 {
|
.wrapper h1 {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
@ -107,6 +110,10 @@
|
|||||||
<button id="send-button">
|
<button id="send-button">
|
||||||
Send
|
Send
|
||||||
</button>
|
</button>
|
||||||
|
<p id="onchain" class="note">
|
||||||
|
<a href="#" id="get-new-address" class="onchain">Prefer onchain Bitcoin? Click here!</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
<div id="lnme-wrapper" class="lnme-wrapper" style="display:none">
|
<div id="lnme-wrapper" class="lnme-wrapper" style="display:none">
|
||||||
<div class="lnme-qrcode"></div>
|
<div class="lnme-qrcode"></div>
|
||||||
<div class="lnme-details">
|
<div class="lnme-details">
|
||||||
@ -128,6 +135,15 @@
|
|||||||
|
|
||||||
<script src="/lnme/lnme.js" id="lnme-script"></script>
|
<script src="/lnme/lnme.js" id="lnme-script"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
document.getElementById("get-new-address").addEventListener('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var lnme = new LnMe({});
|
||||||
|
lnme.newAddress().then(address => {
|
||||||
|
document.getElementById("onchain").innerHTML = address;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var urlParams = new URLSearchParams(window.location.search);
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
if (urlParams.get('amount')) {
|
if (urlParams.get('amount')) {
|
||||||
document.getElementById('amount').value = urlParams.get('amount');
|
document.getElementById('amount').value = urlParams.get('amount');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user