mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Refactor vault (#6678)
* Use Blazor for the Vault code * Put elements in different file * Controller abstraction * Break into VaultElement
This commit is contained in:
@@ -152,7 +152,7 @@ public partial class UIStoresController
|
||||
{
|
||||
try
|
||||
{
|
||||
strategy = handler.ParsePaymentMethodConfig(JToken.Parse(UnprotectString(vm.Config)));
|
||||
strategy = handler.ParsePaymentMethodConfig(JToken.Parse(_dataProtector.UnprotectString(vm.Config)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -167,7 +167,7 @@ public partial class UIStoresController
|
||||
return View(vm.ViewName, vm);
|
||||
}
|
||||
|
||||
vm.Config = ProtectString(JToken.FromObject(strategy, handler.Serializer).ToString());
|
||||
vm.Config = _dataProtector.ProtectString(JToken.FromObject(strategy, handler.Serializer).ToString());
|
||||
ModelState.Remove(nameof(vm.Config));
|
||||
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
@@ -197,15 +197,6 @@ public partial class UIStoresController
|
||||
return ConfirmAddresses(vm, strategy, network.NBXplorerNetwork);
|
||||
}
|
||||
|
||||
private string ProtectString(string str)
|
||||
{
|
||||
return Convert.ToBase64String(_dataProtector.Protect(Encoding.UTF8.GetBytes(str)));
|
||||
}
|
||||
private string UnprotectString(string str)
|
||||
{
|
||||
return Encoding.UTF8.GetString(_dataProtector.Unprotect(Convert.FromBase64String(str)));
|
||||
}
|
||||
|
||||
[HttpGet("{storeId}/onchain/{cryptoCode}/generate/{method?}")]
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
public async Task<IActionResult> GenerateWallet(WalletSetupViewModel vm)
|
||||
@@ -278,7 +269,6 @@ public partial class UIStoresController
|
||||
Network = network,
|
||||
Source = isImport ? "SeedImported" : "NBXplorerGenerated",
|
||||
IsHotWallet = isImport ? request.SavePrivateKeys : method == WalletSetupMethod.HotWallet,
|
||||
DerivationSchemeFormat = "BTCPay",
|
||||
SupportTaproot = network.NBitcoinNetwork.Consensus.SupportTaproot,
|
||||
SupportSegwit = network.NBitcoinNetwork.Consensus.SupportSegwit
|
||||
};
|
||||
@@ -329,7 +319,7 @@ public partial class UIStoresController
|
||||
vm.RootFingerprint = response.AccountKeyPath.MasterFingerprint.ToString();
|
||||
vm.AccountKey = response.AccountHDKey.Neuter().ToWif();
|
||||
vm.KeyPath = response.AccountKeyPath.KeyPath.ToString();
|
||||
vm.Config = ProtectString(JToken.FromObject(derivationSchemeSettings, handler.Serializer).ToString());
|
||||
vm.Config = _dataProtector.ProtectString(JToken.FromObject(derivationSchemeSettings, handler.Serializer).ToString());
|
||||
|
||||
var result = await UpdateWallet(vm);
|
||||
|
||||
@@ -434,7 +424,7 @@ public partial class UIStoresController
|
||||
MasterFingerprint = e.RootFingerprint is { } fp ? fp.ToString() : null,
|
||||
AccountKeyPath = e.AccountKeyPath == null ? "" : $"m/{e.AccountKeyPath}"
|
||||
}).ToList(),
|
||||
Config = ProtectString(JToken.FromObject(derivation, handler.Serializer).ToString()),
|
||||
Config = _dataProtector.ProtectString(JToken.FromObject(derivation, handler.Serializer).ToString()),
|
||||
PayJoinEnabled = storeBlob.PayJoinEnabled,
|
||||
CanUsePayJoin = perm.CanCreateHotWallet && network.SupportPayJoin && derivation.IsHotWallet,
|
||||
CanUseHotWallet = perm.CanCreateHotWallet,
|
||||
@@ -717,8 +707,8 @@ public partial class UIStoresController
|
||||
var derivation = line.Derive(i);
|
||||
var address = network.CreateAddress(strategy.AccountDerivation,
|
||||
line.KeyPathTemplate.GetKeyPath(i),
|
||||
derivation.ScriptPubKey).ToString();
|
||||
vm.AddressSamples.Add((keyPath.ToString(), address, rootedKeyPath));
|
||||
derivation.ScriptPubKey);
|
||||
vm.AddressSamples.Add((keyPath.ToString(), address.ToString(), rootedKeyPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user