Skip to content

Commit

Permalink
Add button and js for buying inbound
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfarrow committed Nov 15, 2022
1 parent 0cc4816 commit ca25fc2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ <h2>PayJoin here to open these channels</h2>
<a href="" id="bip21"></a>
<p>Please use <a href="https://en.bitcoin.it/wiki/PayJoin_adoption" target="_blank">a wallet that supports</a> BIP 78 <a href="https://bitcoinmagazine.com/culture/blockchain-analysis-about-get-harder-p2ep-enters-testing-phase" target="blank">P2EP</a> PayJoins!</p>
</output>
<br>
<br>
</fieldset>
<fieldset id="getinbound-wrapper">
<legend>Buy Inbound Lighning Channel</legend>
<div id="getinbound-button-wrapper">
<button type="button" onclick="get_inbound_quote()">Send Refund Address and Get Quote</button>
</div>
<div id="getinbound-response" class="invisible">
<small>
A <span id="getinbound-capacity"></span> satoshi inbound lightning channel currently costs <span id="getinbound-price"></span> sats. (<span id="getinbound-duration"></span> month).
<br>
To open, send <span id="getinbound-price-2"></span> sats to:
</small>
<br>
<code><span id="getinbound-address"></span></code>
<br>
<br>
<small>Your lightning channel should open within a few hours.</small>
<small>If the channel fails to open you will be refunded using an address we received from your LND onchain wallet.</small>
</div>
</fieldset>
</form>

</main>
Expand All @@ -90,6 +112,24 @@ <h2>PayJoin here to open these channels</h2>
channels.appendChild(div.lastChild);
}

async function get_inbound_quote(){
try {
quote = await (await fetch('/getinbound', {
method: 'GET',
})).json()
document.getElementById("getinbound-button-wrapper").classList.add("invisible");
document.getElementById("getinbound-response").classList.remove("invisible");
document.getElementById("getinbound-price").innerHTML = quote.price;
document.getElementById("getinbound-price-2").innerHTML = quote.price;
document.getElementById("getinbound-capacity").innerHTML = quote.size;
document.getElementById("getinbound-duration").innerHTML = quote.duration;
document.getElementById("getinbound-address").innerHTML = quote.address;
} catch (error) {
console.error(error)
alert("Something went wrong. Please try again.")
}
}

function remove_channel() {
let channels = document.getElementById("channels");
let channelInputs = channels.getElementsByTagName("input");
Expand Down

0 comments on commit ca25fc2

Please sign in to comment.