This commit is contained in:
Kukks 2019-12-04 14:17:22 +01:00
parent 2da9434571
commit 80790bd9b0
2 changed files with 53 additions and 19 deletions

View file

@ -327,6 +327,8 @@ namespace BTCPayServer.Controllers
var network = _NetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode); var network = _NetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
var client = _ExplorerProvider.GetExplorerClient(cryptoCode); var client = _ExplorerProvider.GetExplorerClient(cryptoCode);
var response = await client.GenerateWalletAsync(request); var response = await client.GenerateWalletAsync(request);
var store = HttpContext.GetStoreData();
var result = await AddDerivationScheme(storeId, new DerivationSchemeViewModel() var result = await AddDerivationScheme(storeId, new DerivationSchemeViewModel()
{ {
Confirmation = false, Confirmation = false,
@ -336,11 +338,16 @@ namespace BTCPayServer.Controllers
CryptoCode = cryptoCode, CryptoCode = cryptoCode,
DerivationScheme = response.DerivationScheme.ToString(), DerivationScheme = response.DerivationScheme.ToString(),
Source = "NBXplorer", Source = "NBXplorer",
AccountKey = response.AccountHDKey.ToWif(), AccountKey = response.AccountHDKey.Neuter().ToWif(),
DerivationSchemeFormat = "BTCPay", DerivationSchemeFormat = "BTCPay",
KeyPath = response.AccountKeyPath.KeyPath.ToString(), KeyPath = response.AccountKeyPath.KeyPath.ToString(),
Enabled = true Enabled = !store.GetStoreBlob().IsExcluded(new PaymentMethodId(cryptoCode, PaymentTypes.BTCLike))
}, cryptoCode); }, cryptoCode);
TempData.SetStatusMessageModel(new StatusMessageModel()
{
Severity = StatusMessageModel.StatusSeverity.Success,
Html = !string.IsNullOrEmpty(request.ExistingMnemonic)? "Your wallet has been imported.": $"Your wallet has been generated. Please store your seed securely! <br/><code>{response.Mnemonic}</code>"
});
((ViewResult)result).ViewName = nameof(AddDerivationScheme); ((ViewResult)result).ViewName = nameof(AddDerivationScheme);
return result; return result;
} }

View file

@ -10,25 +10,52 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>You may generate a wallet with a seed and import the xpub it into BTCPay. You can optionally also tell NBX to import the keys to the node wallet to be able to spend received funds from it.</p> <p>You may generate a wallet with a seed and import the xpub it into BTCPay. You can optionally also tell NBX to import the keys to the node wallet to be able to view & spend received funds from it.</p>
<div class="form-group">
<label asp-for="ExistingMnemonic">Existing Seed</label>
<input type="text" asp-for="ExistingMnemonic" class="form-control"/>
<span asp-validation-for="ExistingMnemonic" class="text-danger"></span>
<p class="text-black-50">You can choose to import an existing mnemonic seed phrase. If you leave blank, we will generate one for you.</p>
</div>
<div class="form-group">
<label asp-for="ScriptPubKeyType">Address type</label>
<select class="form-control" asp-for="ScriptPubKeyType">
<option value="@ScriptPubKeyType.Segwit">Segwit (Recommended, cheapest transaction fee)</option>
<option value="@ScriptPubKeyType.SegwitP2SH">Segwit wrapped (less cheap but compatible with old wallets)</option>
<option value="@ScriptPubKeyType.Legacy">Legacy (Not recommended)</option>
</select>
<span asp-validation-for="ScriptPubKeyType" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="AccountNumber">Account</label>
<select asp-for="AccountNumber" class="form-control">
@for (int i = 0; i < 20; i++)
{
<option value="@i">@i</option>
}
</select>
<span asp-validation-for="AccountNumber" class="text-danger"></span>
</div>
<div class="form-group">
<input type="checkbox" class="form-check-inline" asp-for="SavePrivateKeys"/>
<label asp-for="SavePrivateKeys">Save private keys</label>
<span asp-validation-for="SavePrivateKeys" class="text-danger"></span>
<p class="text-black-50">If checked, each private key associated with an address generated will be stored as metadata in NBXplorer.</p>
</div>
<div class="form-group">
<input type="checkbox" class="form-check-inline" asp-for="ImportKeysToRPC"/>
<label asp-for="ImportKeysToRPC">Import keys to RPC</label>
<span asp-validation-for="ImportKeysToRPC" class="text-danger"></span>
<p class="text-black-50">If checked, each address generated will be imported into the node wallet so that you can view your balance through your node. When this is enabled alongside <code>Save private keys</code>, you're also able to use the node wallet to spend (this works pretty well in conjunction with apps such as FullyNoded).</p>
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" >Generate</button>
<div id="vault-dropdown" style="display:none;" class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Select the type of address you want
</button>
<div class="dropdown-menu overflow-auto" style="max-height: 200px;">
<button type="submit" class="dropdown-item" asp-for="ScriptPubKeyType" value="@ScriptPubKeyType.Segwit">Segwit (Recommended, cheapest transaction fee)</button>
<a class="dropdown-item" href="#" asp-for="ScriptPubKeyType" value="@ScriptPubKeyType.SegwitP2SH">Segwit wrapped (less cheap but compatible with old wallets)</a>
<a class="dropdown-item" href="#" asp-for="ScriptPubKeyType" value="@ScriptPubKeyType.Legacy">Legacy (Not recommended)</a>
</div>
</div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>