Make sure fingerprint/hdpath are passed down to AddDerivationScheme.

Close ledger popup on account selection.

Add additional info after pairing
This commit is contained in:
nicolas.dorier 2019-05-25 12:53:03 +09:00
parent 5571413a78
commit 429170520e
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
5 changed files with 54 additions and 40 deletions

View file

@ -341,6 +341,7 @@ namespace BTCPayServer.Controllers
} }
} }
vm.Confirmation = true; vm.Confirmation = true;
ModelState.Remove(nameof(vm.Config)); // Remove the cached value
return View(vm); return View(vm);
} }
} }

View file

@ -39,6 +39,7 @@ namespace BTCPayServer.Models.StoreViewModels
public IFormFile ColdcardPublicFile{ get; set; } public IFormFile ColdcardPublicFile{ get; set; }
public string Config { get; set; } public string Config { get; set; }
public string Source { get; set; } public string Source { get; set; }
public string DerivationSchemeFormat { get; set; }
public string AccountKey { get; set; } public string AccountKey { get; set; }
public BTCPayNetwork Network { get; set; } public BTCPayNetwork Network { get; set; }
} }

View file

@ -4,9 +4,16 @@
ViewData.SetActivePageAndTitle(StoreNavPages.Index, $"{Model.CryptoCode} Derivation scheme"); ViewData.SetActivePageAndTitle(StoreNavPages.Index, $"{Model.CryptoCode} Derivation scheme");
} }
@section HeadScripts {
<style type="text/css">
.hw-fields {
display: none;
}
</style>
}
<partial name="_StatusMessage" for="StatusMessage" /> <partial name="_StatusMessage" for="StatusMessage" />
<h4>@ViewData["Title"]</h4> <h4>@ViewData["Title"]</h4>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div asp-validation-summary="All" class="text-danger"></div> <div asp-validation-summary="All" class="text-danger"></div>
@ -14,37 +21,39 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<partial name="AddDerivationSchemes_HardwareWalletDialogs" model="@Model"/> @if (!Model.Confirmation)
{
<partial name="AddDerivationSchemes_HardwareWalletDialogs" model="@Model" />
}
<form method="post"> <form method="post">
<input id="Config" asp-for="Config" type="hidden" />
@if (!Model.Confirmation) @if (!Model.Confirmation)
{ {
<input id="CryptoCurrency" asp-for="CryptoCode" type="hidden" />
<input id="DerivationSchemeFormat" asp-for="DerivationSchemeFormat" type="hidden" />
<input id="AccountKey" asp-for="AccountKey" type="hidden" />
<div class="form-group"> <div class="form-group">
<h5>Derivation Scheme</h5> <h5>Derivation Scheme</h5>
<span>The DerivationScheme represents the destination of the funds received by your invoice. It is generated by your wallet software. Please, verify that you are generating the right addresses by clicking on 'Check ExtPubKey'</span> <span>The DerivationScheme represents the destination of the funds received by your invoice. It is generated by your wallet software. Please, verify that you are generating the right addresses by clicking on 'Check ExtPubKey'</span>
</div> </div>
<input id="CryptoCurrency" asp-for="CryptoCode" type="hidden" />
<input id="KeyPath" asp-for="KeyPath" type="hidden" />
<input id="Source" asp-for="Source" type="hidden" />
<input id="RootFingerprint" asp-for="RootFingerprint" type="hidden" />
<input id="AccountKey" asp-for="AccountKey" type="hidden" />
<input id="Config" asp-for="Config" type="hidden" />
<div class="form-group"> <div class="form-group">
<label asp-for="DerivationScheme"></label> <label asp-for="DerivationScheme"></label>
<input asp-for="DerivationScheme" class="form-control store-derivation-scheme" /> <input asp-for="DerivationScheme" class="form-control store-derivation-scheme" />
<span asp-validation-for="DerivationScheme" class="text-danger"></span> <span asp-validation-for="DerivationScheme" class="text-danger"></span>
<div class="dropdown mt-2 text-right"> <div class="dropdown mt-2 text-right">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-link dropdown-toggle" type="button" id="hardwarewlletimportdropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button class="btn btn-link dropdown-toggle" type="button" id="hardwarewlletimportdropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Import from hardware device Import from hardware device
</button> </button>
<div class="dropdown-menu dropdown-menu-right w-100" aria-labelledby="hardwarewlletimportdropdown"> <div class="dropdown-menu dropdown-menu-right w-100" aria-labelledby="hardwarewlletimportdropdown">
<button class="dropdown-item" type="button" data-toggle="modal" data-target="#coldcardimport">Coldcard</button> <button class="dropdown-item" type="button" data-toggle="modal" data-target="#coldcardimport">Coldcard</button>
<button class="dropdown-item check-for-ledger" data-toggle="modal" data-target="#ledgerimport" type="button">Ledger</button> <button class="dropdown-item check-for-ledger" data-toggle="modal" data-target="#ledgerimport" type="button">Ledger Wallet</button>
@* <button class="dropdown-item check-for-trezor" type="button" data-toggle="modal" data-target="#trezorimport">Trezor</button> *@ @* <button class="dropdown-item check-for-trezor" type="button" data-toggle="modal" data-target="#trezorimport">Trezor</button> *@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -84,6 +93,22 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="form-group hw-fields">
<h5>Additional pairing information</h5>
</div>
<div class="form-group hw-fields">
<label asp-for="Source"></label>
<input asp-for="Source" class="form-control" readonly />
</div>
<div class="form-group hw-fields">
<label asp-for="RootFingerprint"></label>
<input asp-for="RootFingerprint" class="form-control" readonly />
</div>
<div class="form-group hw-fields">
<label asp-for="KeyPath"></label>
<input asp-for="KeyPath" class="form-control" readonly />
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="Enabled"></label> <label asp-for="Enabled"></label>
<input asp-for="Enabled" type="checkbox" class="form-check" /> <input asp-for="Enabled" type="checkbox" class="form-check" />
@ -96,14 +121,9 @@
<h5>Confirm the addresses (@Model.CryptoCode)</h5> <h5>Confirm the addresses (@Model.CryptoCode)</h5>
<span>Please check that your @Model.CryptoCode wallet is generating the same addresses as below.</span> <span>Please check that your @Model.CryptoCode wallet is generating the same addresses as below.</span>
</div> </div>
<input type="hidden" asp-for="Confirmation" /> <input asp-for="Confirmation" type="hidden" />
<input id="KeyPath" asp-for="KeyPath" type="hidden" />
<input id="Source" asp-for="Source" type="hidden" />
<input id="RootFingerprint" asp-for="RootFingerprint" type="hidden" />
<input id="AccountKey" asp-for="AccountKey" type="hidden" />
<input type="hidden" asp-for="DerivationScheme" /> <input type="hidden" asp-for="DerivationScheme" />
<input type="hidden" asp-for="Enabled" /> <input type="hidden" asp-for="Enabled" />
<input id="Config" asp-for="Config" type="hidden" />
<div class="form-group"> <div class="form-group">
<table class="table table-sm table-responsive-md"> <table class="table table-sm table-responsive-md">
<thead> <thead>
@ -138,15 +158,13 @@
</form> </form>
</div> </div>
</div> </div>
@section Scripts { @section Scripts {
@await Html.PartialAsync("_ValidationScriptsPartial") @await Html.PartialAsync("_ValidationScriptsPartial")
<script src="~/js/ledgerwebsocket.js" type="text/javascript" defer="defer"></script> <script src="~/js/ledgerwebsocket.js" type="text/javascript" defer="defer"></script>
<script src="~/js/StoreAddDerivationScheme.js" type="text/javascript" defer="defer"></script> <script src="~/js/StoreAddDerivationScheme.js" type="text/javascript" defer="defer"></script>
<script src="~/vendor/trezor/trezor.js-umd.min.js" defer="defer"></script>
<script src="~/vendor/trezor/trezor.js-umd.min.js" defer="defer"></script> <script src="~/js/trezor/trezor-client.js" type="text/javascript" defer="defer"></script>
<script src="~/js/trezor/trezor-client.js" type="text/javascript" defer="defer"></script> <script src="~/js/trezor/trezor-add-derivation-scheme.js" type="text/javascript" defer="defer"></script>
<script src="~/js/trezor/trezor-add-derivation-scheme.js" type="text/javascript" defer="defer"></script>
<script> <script>
window.coinName = "@Model.Network.DisplayName.ToLowerInvariant()"; window.coinName = "@Model.Network.DisplayName.ToLowerInvariant()";
</script> </script>

View file

@ -14,7 +14,7 @@
Checking if a ledger wallet is connected... Checking if a ledger wallet is connected...
</div> </div>
<div id="ledger-validate" style="display: none;"> <div id="ledger-validate" style="display: none;">
Please validate access on your screen... Retrieving, wallet information... you may need to confirm access on your screen.
</div> </div>
<p id="no-ledger-info" style="display: none;"> <p id="no-ledger-info" style="display: none;">
No ledger wallet detected. If you own one, use chrome, open the app, and refresh this page. No ledger wallet detected. If you own one, use chrome, open the app, and refresh this page.
@ -93,13 +93,6 @@
<p id="trezor-success" style="display: none;"> <p id="trezor-success" style="display: none;">
<span class="fa fa-check-circle" style="color: green;"></span> <span class="hw-label">Trezor wallet detected! Name: <kbd id="trezor-devicename"></kbd></span> <span class="fa fa-check-circle" style="color: green;"></span> <span class="hw-label">Trezor wallet detected! Name: <kbd id="trezor-devicename"></kbd></span>
</p> </p>
<input id="KeyPath" asp-for="KeyPath" type="hidden"/>
<input id="RootFingerprint" asp-for="RootFingerprint" type="hidden"/>
<input id="AccountKey" asp-for="AccountKey" type="hidden"/>
<input id="Source" asp-for="Source" type="hidden" value="Trezor"/>
<input type="hidden" asp-for="DerivationScheme"/>
<input type="hidden" asp-for="Enabled"/>
<div class="form-group display-when-trezor-connected" style="display: none"> <div class="form-group display-when-trezor-connected" style="display: none">
@ -127,7 +120,7 @@
<option <option
data-derivation-suffix="-[p2sh]" data-derivation-suffix="-[p2sh]"
data-trezorkeypath="@Model.Network.GetRootKeyPath(DerivationType.SegwitP2SH).Derive(i, true)" data-trezorkeypath="@Model.Network.GetRootKeyPath(DerivationType.SegwitP2SH).Derive(i, true)"
>Account @i (<span>@Model.Network.GetRootKeyPath(DerivationType.SegwitP2SH).Derive(i, true)</span>)</option> >Account @i (@Model.Network.GetRootKeyPath(DerivationType.SegwitP2SH).Derive(i, true))</option>
} }
</select> </select>
</div> </div>
@ -140,7 +133,7 @@
{ {
<option <option
data-derivation-suffix="" data-derivation-suffix=""
data-trezorkeypath="@Model.Network.GetRootKeyPath(DerivationType.Segwit).Derive(i, true)" href="#">Account @i (<span>@Model.Network.GetRootKeyPath(DerivationType.Segwit).Derive(i, true)</span>)</option> data-trezorkeypath="@Model.Network.GetRootKeyPath(DerivationType.Segwit).Derive(i, true)" href="#">Account @i (@Model.Network.GetRootKeyPath(DerivationType.Segwit).Derive(i, true))</option>
} }
</select> </select>
</div> </div>
@ -154,7 +147,7 @@
{ {
<option <option
data-derivation-suffix="-[legacy]" data-derivation-suffix="-[legacy]"
data-trezorkeypath="@Model.Network.GetRootKeyPath(DerivationType.Legacy).Derive(i, true)">Account @i (<span>@Model.Network.GetRootKeyPath(DerivationType.Legacy).Derive(i, true)</span>)</option> data-trezorkeypath="@Model.Network.GetRootKeyPath(DerivationType.Legacy).Derive(i, true)">Account @i (@Model.Network.GetRootKeyPath(DerivationType.Legacy).Derive(i, true))</option>
} }
</select> </select>
</div> </div>

View file

@ -48,13 +48,14 @@
return; return;
showFeedback("ledger-info"); showFeedback("ledger-info");
$("#DerivationScheme").val(result.derivationScheme); $("#DerivationScheme").val(result.derivationScheme);
$("#RootFingerprint").val(result.rootFingerprint); $("#RootFingerprint").val(result.rootFingerprint);
$("#AccountKey").val(result.extPubKey); $("#AccountKey").val(result.extPubKey);
$("#Source").val(result.source); $("#Source").val(result.source);
$("#DerivationSchemeFormat").val("BTCPay"); $("#DerivationSchemeFormat").val("BTCPay");
$("#KeyPath").val(keypath); $("#KeyPath").val(keypath);
$(".modal").modal('hide');
$(".hw-fields").show();
}) })
.catch(function (reason) { Write('check', 'error', reason); }); .catch(function (reason) { Write('check', 'error', reason); });
return false; return false;