mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 10:40:29 +01:00
4176f3659b
* Add PSBT QR code scan/show This PR introduces support to show and read PSBTs in BC-UR format via animated QR codes. This allows you to use BTCPay with HW devices such as Cobo Vault and Blue wallet to sign transactions without ever exposing the keys outside of that device. Spec: https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-005-ur.md I've also bumped the QR code library we sue as it had a bug with large datasets. * Reuse same code for all and allow wallet import via QR code scan * remove unecessary js vendor files * Allow export wallet from settings via QR * formatting * bundle * fix wallet receive bundle
103 lines
4.7 KiB
Plaintext
103 lines
4.7 KiB
Plaintext
@model WalletPSBTViewModel
|
|
@addTagHelper *, BundlerMinifier.TagHelpers
|
|
@{
|
|
Layout = "../Shared/_NavLayout.cshtml";
|
|
ViewData["Title"] = "PSBT";
|
|
ViewData.SetActivePageAndTitle(WalletsNavPages.PSBT);
|
|
}
|
|
@if (TempData.HasStatusMessage())
|
|
{
|
|
<div class="row">
|
|
<div class="col-md-10 text-center">
|
|
<partial name="_StatusMessage"/>
|
|
</div>
|
|
</div>
|
|
}
|
|
<div class="row">
|
|
<div class="col-md-10">
|
|
@if (Model.Errors != null && Model.Errors.Count != 0)
|
|
{
|
|
<div class="alert alert-danger alert-dismissible" role="alert">
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
@foreach (var error in Model.Errors)
|
|
{
|
|
<span>@error</span>
|
|
<br/>
|
|
}
|
|
</div>
|
|
}
|
|
@if (!string.IsNullOrEmpty(Model.Decoded))
|
|
{
|
|
<h3>Decoded PSBT</h3>
|
|
<div class="form-group">
|
|
<form method="post" asp-action="WalletPSBT" asp-route-walletId="@this.Context.GetRouteValue("walletId")">
|
|
<input type="hidden" asp-for="CryptoCode"/>
|
|
<input type="hidden" asp-for="NBXSeedAvailable"/>
|
|
<input type="hidden" asp-for="PSBT"/>
|
|
<input type="hidden" asp-for="FileName"/>
|
|
<div class="d-flex">
|
|
<partial name="WalletSigningMenu" model="@((Model.CryptoCode, Model.NBXSeedAvailable))"/>
|
|
<div class="ml-2 dropdown">
|
|
<button class="btn btn-secondary dropdown-toggle" type="button" id="OtherActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
Other actions...
|
|
</button>
|
|
<div class="dropdown-menu" aria-labelledby="OtherActions">
|
|
<button name="command" type="submit" class="dropdown-item" value="broadcast">Review</button>
|
|
<button name="command" type="submit" class="dropdown-item" value="update">Update</button>
|
|
<button name="command" type="submit" class="dropdown-item" value="combine">Combine</button>
|
|
<button name="command" type="submit" class="dropdown-item" value="save-psbt">Download</button>
|
|
<button name="command" type="button" class="dropdown-item only-for-js" data-toggle="modal" data-target="#scan-qr-modal">Show QR</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<pre><code class="json">@Model.Decoded</code></pre>
|
|
}
|
|
<h4 class="mb-3">Decode PSBT</h4>
|
|
<p>You can decode a PSBT by either pasting its content or by uploading the file.</p>
|
|
<form class="form-group" method="post" asp-action="WalletPSBT" asp-route-walletId="@this.Context.GetRouteValue("walletId")" enctype="multipart/form-data">
|
|
<div class="form-group">
|
|
<label asp-for="PSBT"></label>
|
|
<textarea class="form-control" rows="5" asp-for="PSBT"></textarea>
|
|
<span asp-validation-for="PSBT" class="text-danger"></span>
|
|
|
|
</div>
|
|
<div class="form-group">
|
|
<label asp-for="UploadedPSBTFile"></label>
|
|
<input type="file" class="form-control-file" asp-for="UploadedPSBTFile">
|
|
</div>
|
|
|
|
<button type="button" id="scanqrcode" class="ml-2 btn btn-secondary only-for-js" data-toggle="modal" data-target="#scanModal" title="Scan with camera">
|
|
<i class="fa fa-camera"></i>
|
|
</button>
|
|
<button type="submit" name="command" value="decode" class="btn btn-primary" id="Decode">Decode</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<partial name="ShowQR"/>
|
|
<partial name="CameraScanner"/>
|
|
|
|
|
|
@section Scripts {
|
|
<link rel="stylesheet" href="~/vendor/highlightjs/default.min.css" asp-append-version="true">
|
|
<script src="~/vendor/highlightjs/highlight.min.js" asp-append-version="true"></script>
|
|
<bundle name="wwwroot/bundles/camera-bundle.min.js"></bundle>
|
|
<link href="~/vendor/vue-qrcode-reader/vue-qrcode-reader.css" rel="stylesheet" asp-append-version="true"/>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
|
|
<script>
|
|
|
|
$(function (){
|
|
initQRShow("Scan PSBT", @Json.Serialize(Model.PSBTHex), "scan-qr-modal");
|
|
|
|
initCameraScanningApp("Scan PSBT", function (data){
|
|
$("textarea[name=PSBT]").val(data);
|
|
$("#Decode").click();
|
|
}, "scanModal")
|
|
});
|
|
</script>
|
|
}
|