mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Fix lnurl withdraw modal (#3955)
* Fix lnurl withdraw modal fixes #3949 * Fix test
This commit is contained in:
@@ -1577,7 +1577,9 @@ namespace BTCPayServer.Tests
|
||||
s.Driver.FindElement(By.Id("Currency")).SendKeys("BTC" + Keys.Enter);
|
||||
s.FindAlertMessage(StatusMessageModel.StatusSeverity.Success);
|
||||
s.Driver.FindElement(By.LinkText("View")).Click();
|
||||
var lnurl = new Uri(LNURL.LNURL.Parse(s.Driver.FindElement(By.CssSelector("button[data-lnurl]")).GetAttribute("data-lnurl-uri"), out _).ToString().Replace("https", "http"));
|
||||
s.Driver.FindElement(By.CssSelector("#lnurlwithdraw-button")).Click();
|
||||
var lnurl = new Uri(LNURL.LNURL.Parse(s.Driver.FindElement(By.Id("qr-code-data-input")).GetAttribute("value"), out _).ToString().Replace("https", "http"));
|
||||
s.Driver.FindElement(By.CssSelector("button[data-bs-dismiss='modal']")).Click();
|
||||
var info = Assert.IsType<LNURLWithdrawRequest>(await LNURL.LNURL.FetchInformation(lnurl, s.Server.PayTester.HttpClient));
|
||||
Assert.Equal(info.MaxWithdrawable, new LightMoney(0.0000001m, LightMoneyUnit.BTC));
|
||||
Assert.Equal(info.CurrentBalance, new LightMoney(0.0000001m, LightMoneyUnit.BTC));
|
||||
@@ -1609,7 +1611,10 @@ namespace BTCPayServer.Tests
|
||||
s.Driver.FindElement(By.Id("Currency")).SendKeys("BTC" + Keys.Enter);
|
||||
s.FindAlertMessage(StatusMessageModel.StatusSeverity.Success);
|
||||
s.Driver.FindElement(By.LinkText("View")).Click();
|
||||
lnurl = new Uri(LNURL.LNURL.Parse(s.Driver.FindElement(By.CssSelector("button[data-lnurl]")).GetAttribute("data-lnurl-uri"), out _).ToString().Replace("https", "http"));
|
||||
s.Driver.FindElement(By.CssSelector("#lnurlwithdraw-button")).Click();
|
||||
lnurl = new Uri(LNURL.LNURL.Parse(s.Driver.FindElement(By.Id("qr-code-data-input")).GetAttribute("value"), out _).ToString().Replace("https", "http"));
|
||||
|
||||
s.Driver.FindElement(By.CssSelector("button[data-bs-dismiss='modal']")).Click();
|
||||
info = Assert.IsType<LNURLWithdrawRequest>(await LNURL.LNURL.FetchInformation(lnurl, s.Server.PayTester.HttpClient));
|
||||
Assert.Equal(info.MaxWithdrawable, new LightMoney(0.0000001m, LightMoneyUnit.BTC));
|
||||
Assert.Equal(info.CurrentBalance, new LightMoney(0.0000001m, LightMoneyUnit.BTC));
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-if="showData && data">
|
||||
<div class="input-group input-group-sm" :data-clipboard="data">
|
||||
<input type="text" class="form-control" style="cursor:copy" readonly="readonly" :value="data" id="qr-code-data-input">
|
||||
<button type="button" class="btn btn-outline-secondary" data-clipboard-confirm="">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="note" v-html="note" class="text-muted mt-3"></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
@@ -50,7 +57,9 @@
|
||||
fragments: [],
|
||||
active: false,
|
||||
modalId: modalId,
|
||||
note: "",
|
||||
currentMode: "bcur",
|
||||
showData: false,
|
||||
allowedModes: ["static","bcur"]
|
||||
},
|
||||
computed:
|
||||
@@ -77,7 +86,7 @@
|
||||
watch:
|
||||
{
|
||||
currentMode: function(){
|
||||
if (this.dataPerMode && this.dataPerMode[this.currentMode]){
|
||||
if (this.dataPerMode && this.currentMode in this.dataPerMode){
|
||||
this.data = this.dataPerMode[this.currentMode];
|
||||
}
|
||||
this.setFragments();
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<div class="input-group">
|
||||
@if (lnurl is not null)
|
||||
{
|
||||
<button type="button" class="input-group-prepend btn btn-outline-secondary" data-lnurl data-lnurl-bech32="@lnurl" data-lnurl-uri="@lnurlUri">
|
||||
<button type="button" class="input-group-prepend btn btn-outline-secondary" id="lnurlwithdraw-button" data-bs-toggle="modal" data-bs-target="#scan-qr-modal">
|
||||
<span class="fa fa-qrcode fa-2x" title="LNURL-Withdraw"></span>
|
||||
</button>
|
||||
}
|
||||
@@ -236,27 +236,37 @@
|
||||
</div>
|
||||
<partial name="LayoutFoot" />
|
||||
@if (lnurl is not null)
|
||||
{
|
||||
<script src="~/vendor/vue-qrcode/vue-qrcode.min.js" asp-append-version="true"></script>
|
||||
<script src="~/vendor/vuejs/vue.min.js" asp-append-version="true"></script>
|
||||
<partial name="ShowQR"/>
|
||||
}
|
||||
{
|
||||
var note = "You can scan or open this link with a <a href='https://github.com/fiatjaf/lnurl-rfc#lnurl-documents' target='_blank' rel='noreferrer noopener'>LNURL-Withdraw</a> enabled wallet.";
|
||||
if (!Model.AutoApprove)
|
||||
{
|
||||
note += "<br/><span class='fw-bold'>Please note that this pull payment does not automatically send out funds, and so will process payment after LNURL-withdraw flow is completed.</span>";
|
||||
}
|
||||
<script src="~/vendor/vue-qrcode/vue-qrcode.min.js" asp-append-version="true"></script>
|
||||
<script src="~/vendor/vuejs/vue.min.js" asp-append-version="true"></script>
|
||||
<partial name="ShowQR"/>
|
||||
|
||||
<script>
|
||||
document.getElementById("copyLink").addEventListener("click", window.copyUrlToClipboard);
|
||||
const qrApp = initQRShow("LNURL Withdraw", "", "scan-qr-modal")
|
||||
delegate('click', 'button[data-lnurl]', event => {
|
||||
const { lnurlBech32,lnurlUri } = event.target.dataset
|
||||
qrApp.data = null;
|
||||
qrApp.dataPerMode = {
|
||||
Bech32: lnurlBech32,
|
||||
URI: lnurlUri
|
||||
};
|
||||
qrApp.clickable = true;
|
||||
qrApp.allowedModes = ["Bech32", "URI"];
|
||||
qrApp.currentMode = "URI";
|
||||
$("#scan-qr-modal").modal("show")
|
||||
})
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const qrApp = initQRShow("LNURL Withdraw", "", "scan-qr-modal")
|
||||
qrApp.data = null;
|
||||
qrApp.showData = true;
|
||||
qrApp.dataPerMode = {
|
||||
Bech32: @Safe.Json(lnurl),
|
||||
URI: @Safe.Json(lnurlUri)
|
||||
};
|
||||
qrApp.clickable = true;
|
||||
qrApp.allowedModes = ["Bech32", "URI"];
|
||||
qrApp.currentMode = "URI";
|
||||
qrApp.note = @Safe.Json(note);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("copyLink").addEventListener("click", window.copyUrlToClipboard);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user