Skip to content

Commit

Permalink
Show quote information if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfarrow authored and DanGould committed Nov 18, 2022
1 parent 16766d1 commit b23e800
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
31 changes: 27 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2>Queue batches of lightning channels to open in a single transaction</h2>
<div span="1"></div>
<div span="1">
<label for="wantsInbound">Get inbound channel quote (~30,000 sats)</label>
<input type="hidden" id="hiddenWantsInbound" value="false" name="wants_inbound_quote">
<input type="checkbox" id="wantsInbound" name="wants_inbound_quote" value="true" checked>
</div>
</x-grid>
Expand Down Expand Up @@ -68,13 +69,15 @@ <h2>Queue batches of lightning channels to open in a single transaction</h2>
</div>
<output id="queued" class="invisible">
<h2>PayJoin here to open these channels</h2>
<p class="warning">⚠ This software is still extremely experimental and has not been vetted, use at your own risk ⚠</code>
<p class="warning">⚠ This software is still extremely experimental and has not been vetted, use at your own risk ⚠</p>
<div id="qrcode" class="center-axyz"></div>
<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>
<p>Please pay using <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>
<br>
<div id="lsp-response" class="invisible">
<!-- populated on POST /schedule response -->
</div>
</output>
<br>
<br>
</form>
</main>
<script type="text/javascript">
Expand Down Expand Up @@ -104,6 +107,12 @@ <h2>PayJoin here to open these channels</h2>

document.querySelector("form").addEventListener("submit", async (event) => {
event.preventDefault();

// Disable hiddens if checkboxes are checked
if(document.getElementById("wantsInbound").checked) {
document.getElementById('hiddenWantsInbound').disabled = true;
}

let form = event.currentTarget;
let resource = form.action;
let options = {
Expand All @@ -127,6 +136,20 @@ <h2>PayJoin here to open these channels</h2>
document.getElementById("qrcode").innerHTML = `<img src="/qr_codes/${r_json.address}.png" width="256px" />`;
document.getElementById("queue").classList.add("invisible");
document.getElementById("queued").classList.remove("invisible");
let lspResponse = document.getElementById("lsp-response")

if (r_json.quote) {
lspResponse.classList.remove("invisible");
let quoteTemplate =`
<h3>Inbound Channel Quote:</h3>
<p>
This request includes a ${r_json.quote.price} sats transfer to lease ${r_json.quote.size} sats of inbound capacity for ${r_json.quote.duration} ${r_json.quote.duration == 1 ? "month": "months"}.
<br>
A refund address from your lightning node's on-chain wallet is already registered in case of failure.
</p>
`
lspResponse.innerHTML = quoteTemplate;
}
})
.catch((err) => {
alert(err);
Expand Down
1 change: 0 additions & 1 deletion public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ h3 {
}

p {
font-size: 1.5em;
font-weight: 400;
background-image: conic-gradient(
from 0deg at 0% 0%,
Expand Down

0 comments on commit b23e800

Please sign in to comment.