mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Add generate wallet e2e test
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
|||||||
@@ -109,6 +109,23 @@ namespace BTCPayServer.Tests
|
|||||||
return (usr, Driver.FindElement(By.Id("Id")).GetAttribute("value"));
|
return (usr, Driver.FindElement(By.Id("Id")).GetAttribute("value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GenerateWallet(string cryptoCode = "BTC", string seed = "")
|
||||||
|
{
|
||||||
|
Driver.FindElement(By.Id($"Modify{cryptoCode}")).ForceClick();
|
||||||
|
Driver.FindElement(By.Id("import-from-btn")).ForceClick();
|
||||||
|
Driver.FindElement(By.Id("nbxplorergeneratewalletbtn")).ForceClick();
|
||||||
|
Driver.FindElement(By.Id("ExistingMnemonic")).SendKeys(seed);
|
||||||
|
Driver.FindElement(By.Id("btn-generate")).ForceClick();
|
||||||
|
AssertHappyMessage();
|
||||||
|
if (string.IsNullOrEmpty(seed))
|
||||||
|
{
|
||||||
|
seed = Driver.FindElements(By.ClassName("alert-success")).First().FindElement(By.TagName("code")).Text;
|
||||||
|
}
|
||||||
|
Driver.FindElement(By.Id("Confirm")).ForceClick();
|
||||||
|
AssertHappyMessage();
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
public void AddDerivationScheme(string cryptoCode = "BTC", string derivationScheme = "xpub661MyMwAqRbcGABgHMUXDzPzH1tU7eZaAaJQXhDXsSxsqyQzQeU6kznNfSuAyqAK9UaWSaZaMFdNiY5BCF4zBPAzSnwfUAwUhwttuAKwfRX-[legacy]")
|
public void AddDerivationScheme(string cryptoCode = "BTC", string derivationScheme = "xpub661MyMwAqRbcGABgHMUXDzPzH1tU7eZaAaJQXhDXsSxsqyQzQeU6kznNfSuAyqAK9UaWSaZaMFdNiY5BCF4zBPAzSnwfUAwUhwttuAKwfRX-[legacy]")
|
||||||
{
|
{
|
||||||
Driver.FindElement(By.Id($"Modify{cryptoCode}")).ForceClick();
|
Driver.FindElement(By.Id($"Modify{cryptoCode}")).ForceClick();
|
||||||
|
|||||||
@@ -408,14 +408,18 @@ namespace BTCPayServer.Tests
|
|||||||
{
|
{
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
s.CreateNewStore();
|
var storeId = s.CreateNewStore();
|
||||||
|
|
||||||
// In this test, we try to spend from a manual seed. We import the xpub 49'/0'/0', then try to use the seed
|
// In this test, we try to spend from a manual seed. We import the xpub 49'/0'/0', then try to use the seed
|
||||||
// to sign the transaction
|
// to sign the transaction
|
||||||
var mnemonic = "usage fever hen zero slide mammal silent heavy donate budget pulse say brain thank sausage brand craft about save attract muffin advance illegal cabbage";
|
var mnemonic = s.GenerateWallet("BTC", "");
|
||||||
|
|
||||||
var root = new Mnemonic(mnemonic).DeriveExtKey();
|
var root = new Mnemonic(mnemonic).DeriveExtKey();
|
||||||
s.AddDerivationScheme("BTC", "ypub6WWc2gWwHbdnAAyJDnR4SPL1phRh7REqrPBfZeizaQ1EmTshieRXJC3Z5YoU4wkcdKHEjQGkh6AYEzCQC1Kz3DNaWSwdc1pc8416hAjzqyD");
|
var invoiceId = s.CreateInvoice(storeId.storeId);
|
||||||
var tx = s.Server.ExplorerNode.SendToAddress(BitcoinAddress.Create("bcrt1qmxg8fgnmkp354vhe78j6sr4ut64tyz2xyejel4", Network.RegTest), Money.Coins(3.0m));
|
var invoice = await s.Server.PayTester.InvoiceRepository.GetInvoice( invoiceId);
|
||||||
|
var address = invoice.EntityToDTO().Addresses["BTC"];
|
||||||
|
|
||||||
|
var tx = s.Server.ExplorerNode.SendToAddress(BitcoinAddress.Create(address, Network.RegTest), Money.Coins(3.0m));
|
||||||
s.Server.ExplorerNode.Generate(1);
|
s.Server.ExplorerNode.Generate(1);
|
||||||
|
|
||||||
s.Driver.FindElement(By.Id("Wallets")).Click();
|
s.Driver.FindElement(By.Id("Wallets")).Click();
|
||||||
@@ -429,8 +433,8 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
// We setup the fingerprint and the account key path
|
// We setup the fingerprint and the account key path
|
||||||
s.Driver.FindElement(By.Id("WalletSettings")).ForceClick();
|
s.Driver.FindElement(By.Id("WalletSettings")).ForceClick();
|
||||||
s.Driver.FindElement(By.Id("AccountKeys_0__MasterFingerprint")).SendKeys("8bafd160");
|
// s.Driver.FindElement(By.Id("AccountKeys_0__MasterFingerprint")).SendKeys("8bafd160");
|
||||||
s.Driver.FindElement(By.Id("AccountKeys_0__AccountKeyPath")).SendKeys("m/49'/0'/0'" + Keys.Enter);
|
// s.Driver.FindElement(By.Id("AccountKeys_0__AccountKeyPath")).SendKeys("m/49'/0'/0'" + Keys.Enter);
|
||||||
|
|
||||||
// Check the tx sent earlier arrived
|
// Check the tx sent earlier arrived
|
||||||
s.Driver.FindElement(By.Id("WalletTransactions")).ForceClick();
|
s.Driver.FindElement(By.Id("WalletTransactions")).ForceClick();
|
||||||
@@ -471,7 +475,7 @@ namespace BTCPayServer.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SignWith(mnemonic);
|
SignWith(mnemonic);
|
||||||
var accountKey = root.Derive(new KeyPath("m/49'/0'/0'")).GetWif(Network.RegTest).ToString();
|
var accountKey = root.Derive(new KeyPath("m/84'/1'/0'")).GetWif(Network.RegTest).ToString();
|
||||||
SignWith(accountKey);
|
SignWith(accountKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ namespace BTCPayServer.Controllers
|
|||||||
Confirmation = false,
|
Confirmation = false,
|
||||||
Network = network,
|
Network = network,
|
||||||
RootFingerprint = response.AccountKeyPath.MasterFingerprint.ToString(),
|
RootFingerprint = response.AccountKeyPath.MasterFingerprint.ToString(),
|
||||||
RootKeyPath = response.AccountKeyPath.KeyPath,
|
RootKeyPath = network.GetRootKeyPath(),
|
||||||
CryptoCode = cryptoCode,
|
CryptoCode = cryptoCode,
|
||||||
DerivationScheme = response.DerivationScheme.ToString(),
|
DerivationScheme = response.DerivationScheme.ToString(),
|
||||||
Source = "NBXplorer",
|
Source = "NBXplorer",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
{
|
{
|
||||||
<template id="btcpayservervault_template">
|
<template id="btcpayservervault_template">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<form class="modal-content" form method="post" enctype="multipart/form-data">
|
<form class="modal-content" form method="post" asp-action="AddDerivationScheme" asp-route-cryptoCode="@Model.CryptoCode" enctype="multipart/form-data">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="exampleModalLabel">Address verification</h5>
|
<h5 class="modal-title" id="exampleModalLabel">Address verification</h5>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
<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" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="import-from-btn">
|
||||||
Import from...
|
Import from...
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
{
|
{
|
||||||
<button class="dropdown-item check-for-vault" type="button">... the vault (preview)</button>
|
<button class="dropdown-item check-for-vault" type="button">... the vault (preview)</button>
|
||||||
}
|
}
|
||||||
<button class="dropdown-item" data-toggle="modal" data-target="#nbxplorergeneratewallet" type="button">... a new/existing seed.</button>
|
<button class="dropdown-item" data-toggle="modal" data-target="#nbxplorergeneratewallet" type="button" id="nbxplorergeneratewalletbtn">... a new/existing seed.</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
</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>
|
<button type="submit" class="btn btn-primary" id="btn-generate">Generate</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user