2021-02-11 11:48:54 +01:00
@using NBitcoin
2021-06-18 03:25:17 +02:00
@model WalletSetupRequest
2021-02-11 11:48:54 +01:00
@{
var method = ViewData["Method"];
var isImport = method is WalletSetupMethod.Seed;
var isHotWallet = method is WalletSetupMethod.HotWallet;
var canUseHotWallet = ViewData["CanUseHotWallet"] is true;
var canUseRpcImport = ViewData["CanUseRPCImport"] is true;
}
@if (!User.IsInRole(Roles.ServerAdmin))
{
<div class="alert alert-warning">
You are not an admin on this server. While you are able to import or generate a wallet via seed with
your account, please understand that you are trusting the server admins not just with your
2021-10-01 18:18:54 +02:00
<a href="https://docs.btcpayserver.org/Deployment/ThirdPartyHosting/#privacy-concerns" target="_blank" class="alert-link" rel="noreferrer noopener">privacy</a>
but also with <a href="https://docs.btcpayserver.org/Deployment/ThirdPartyHosting/#trust-concerns" target="_blank" class="alert-link" rel="noreferrer noopener">trivial access to your funds.</a>
2021-02-11 11:48:54 +01:00
</div>
}
<form id="generate-wallet-form" method="post" asp-action="GenerateWallet" asp-route-storeId="@Context.GetRouteValue("storeId")" asp-route-cryptoCode="@Context.GetRouteValue("cryptoCode")" asp-route-method="@method">
@if (isImport)
{
<div class="form-group">
2021-05-19 04:39:27 +02:00
<label asp-for="ExistingMnemonic" class="form-label">Wallet Recovery Seed</label>
<textarea asp-for="ExistingMnemonic" class="form-control font-monospace py-2" rows="2" autocomplete="off" autocorrect="off" autocapitalize="off"></textarea>
2021-02-11 11:48:54 +01:00
<span asp-validation-for="ExistingMnemonic" class="text-danger"></span>
</div>
}
<div class="form-group">
2021-05-19 04:39:27 +02:00
<label asp-for="ScriptPubKeyType" class="form-label">Address type</label>
<select class="form-select w-auto" asp-for="ScriptPubKeyType">
2021-09-04 22:07:09 +09:00
@if (ViewData["SupportSegwit"] is true)
2021-09-03 12:07:12 +05:30
{
2021-09-04 22:07:09 +09:00
<option value="@ScriptPubKeyType.Segwit">Segwit (Recommended)</option>
<option value="@ScriptPubKeyType.SegwitP2SH">Segwit wrapped (Compatible with old wallets)</option>
<option value="@ScriptPubKeyType.Legacy">Legacy (Not recommended)</option>
}
else
{
<option value="@ScriptPubKeyType.Legacy">Legacy</option>
}
@if (ViewData["SupportTaproot"] is true)
{
2021-11-15 23:03:10 +09:00
<option value="@ScriptPubKeyType.TaprootBIP86">Taproot (For advanced users)</option>
2021-09-03 12:07:12 +05:30
}
2021-02-11 11:48:54 +01:00
</select>
<span asp-validation-for="ScriptPubKeyType" class="text-danger"></span>
</div>
@if (isImport && canUseHotWallet)
{
2022-09-19 12:56:16 -07:00
<div class="form-group mt-4">
<label class="d-flex align-items-center">
<input type="checkbox" asp-for="SavePrivateKeys" class="btcpay-toggle me-3" />
<div>
<label asp-for="SavePrivateKeys">Is hot wallet</label>
<span asp-validation-for="SavePrivateKeys" class="text-danger"></span>
<p class="text-muted pt-2 mb-0">
If checked, each private key associated with an address generated will be stored as metadata
and would be accessible to anyone with admin access to your server. Enable at your own risk!
</p>
</div>
</label>
2021-02-11 11:48:54 +01:00
</div>
}
else
{
<input asp-for="SavePrivateKeys" type="hidden" value="@isHotWallet" />
2021-06-18 03:25:17 +02:00
@if (Model.CanUsePayJoin)
{
2022-09-19 12:56:16 -07:00
<div class="form-group mt-3">
<label class="d-flex align-items-center">
<input type="checkbox" asp-for="PayJoinEnabled" class="btcpay-toggle me-3" />
<div>
<span>Enable PayJoin</span>
<span asp-validation-for="PayJoinEnabled" class="text-danger"></span>
<p class="text-muted pt-2 mb-0">
PayJoin enhances the privacy for you and your customers.
Enabling it gives your customers the option to use PayJoin during checkout.
<a href="https://docs.btcpayserver.org/Payjoin/" target="_blank" rel="noreferrer noopener">
2023-02-13 00:25:24 -08:00
<vc:icon symbol="info" />
2022-09-19 12:56:16 -07:00
</a>
</p>
</div>
</label>
2021-06-18 03:25:17 +02:00
</div>
}
2021-02-11 11:48:54 +01:00
}
2022-09-19 12:56:16 -07:00
2021-02-11 11:48:54 +01:00
<div class="mb-4">
2022-09-20 09:50:59 +02:00
<button class="d-inline-flex align-items-center btn btn-link text-primary fw-semibold p-0" type="button" id="AdvancedSettingsButton" data-bs-toggle="collapse" data-bs-target="#AdvancedSettings" aria-expanded="false" aria-controls="AdvancedSettings">
<vc:icon symbol="caret-down"/>
<span class="ms-1">Advanced settings</span>
2021-02-11 11:48:54 +01:00
</button>
2021-02-17 15:50:04 +01:00
<div id="AdvancedSettings" class="collapse @(string.IsNullOrEmpty(Model.Passphrase) && !Model.ImportKeysToRPC ? "" : "show")">
2022-09-19 12:56:16 -07:00
<div class="pt-3">
2021-02-11 11:48:54 +01:00
@if (isImport) // hide account option when creating a wallet
{
2022-09-19 12:56:16 -07:00
<div class="form-group">
2021-06-06 13:44:54 +02:00
<label asp-for="AccountNumber" class="form-label">Account</label>
2021-10-26 11:00:01 +02:00
<input asp-for="AccountNumber" class="form-control" style="max-width:10ch" min="0" step="1">
2021-02-11 11:48:54 +01:00
<span asp-validation-for="AccountNumber" class="text-danger"></span>
</div>
}
<div class="form-group">
2021-06-06 13:44:54 +02:00
<label asp-for="Passphrase" class="form-label">Optional passphrase (BIP39)</label>
2022-09-20 09:50:59 +02:00
<input type="text" asp-for="Passphrase" class="form-control" autocomplete="off"/>
2021-02-11 11:48:54 +01:00
<span asp-validation-for="Passphrase" class="text-danger"></span>
</div>
<div class="form-group">
2021-06-06 13:44:54 +02:00
<label for="passphrase_conf" class="form-label">Confirm passphrase</label>
2022-09-20 09:50:59 +02:00
<input type="text" name="passphrase_conf" id="passphrase_conf" class="form-control"/>
2021-02-11 11:48:54 +01:00
<span class="text-danger field-validation-valid" id="passphrase_conf_validation"></span>
</div>
@if (canUseRpcImport)
{
2022-09-19 12:56:16 -07:00
<div class="form-group mt-4">
<label class="d-flex align-items-center">
2022-09-20 09:50:59 +02:00
<input type="checkbox" asp-for="ImportKeysToRPC" class="btcpay-toggle me-3"/>
2022-09-19 12:56:16 -07:00
<div>
<label asp-for="ImportKeysToRPC">Import keys to RPC</label>
<span asp-validation-for="ImportKeysToRPC" class="text-danger"></span>
<p class="text-muted pt-2 mb-0">
Each address generated will be imported into the node wallet and you can view your balance through the node.
@if (isImport || isHotWallet)
{
<span>When this is enabled for a hot wallet, you are also able to use the node wallet to spend.</span>
}
</p>
</div>
</label>
2021-02-11 11:48:54 +01:00
</div>
}
</div>
</div>
</div>
2022-09-19 12:56:16 -07:00
<button type="submit" class="btn btn-primary" id="Continue">@(isImport ? "Continue" : "Create")</button>
2021-02-11 11:48:54 +01:00
</form>
2021-05-19 04:39:27 +02:00
<script>
2021-02-11 11:48:54 +01:00
document.getElementById("generate-wallet-form").addEventListener("submit", event => {
const $form = event.currentTarget;
if ($form.elements["passphrase_conf"].value !== $form.elements["Passphrase"].value) {
const $validation = document.getElementById("passphrase_conf_validation");
$validation.classList.remove("field-validation-valid");
$validation.innerText = "Invalid passphrase confirmation";
event.preventDefault();
}
});
</script>