Rewrite the CanUseHotWallet, check if the derivationscheme is actually a hotwallet, before retrieving the seed

This commit is contained in:
nicolas.dorier
2021-03-11 21:46:32 +09:00
parent cdfdad3e3d
commit c2b85779c3
2 changed files with 17 additions and 15 deletions

View File

@@ -388,7 +388,7 @@ namespace BTCPayServer.Controllers.GreenField
var signingKeyStr = await explorerClient
.GetMetadataAsync<string>(derivationScheme.AccountDerivation,
WellknownMetadataKeys.MasterHDKey);
if (signingKeyStr is null)
if (!derivationScheme.IsHotWallet || signingKeyStr is null)
{
return this.CreateAPIError("not-available",
$"{cryptoCode} sending services are not currently available");
@@ -403,7 +403,7 @@ namespace BTCPayServer.Controllers.GreenField
var accountKey = signingKey.Derive(rootedKeyPath.KeyPath);
var changed = psbt.PSBT.PSBTChanged(() => psbt.PSBT.SignAll(derivationScheme.AccountDerivation, accountKey,
rootedKeyPath, new SigningOptions() {EnforceLowR = !(signingContext?.EnforceLowR is false)}));
rootedKeyPath, new SigningOptions() {EnforceLowR = signingContext?.EnforceLowR is bool v ? v : psbt.Suggestions.ShouldEnforceLowR }));
if (!changed)
{
@@ -465,17 +465,6 @@ namespace BTCPayServer.Controllers.GreenField
return await _authorizationService.CanUseHotWallet(_cssThemeManager.Policies, User);
}
private async Task<ExtKey> GetWallet(DerivationSchemeSettings derivationScheme)
{
if (!derivationScheme.IsHotWallet)
return null;
var result = await _explorerClientProvider.GetExplorerClient(derivationScheme.Network.CryptoCode)
.GetMetadataAsync<string>(derivationScheme.AccountDerivation,
WellknownMetadataKeys.MasterHDKey);
return string.IsNullOrEmpty(result) ? null : ExtKey.Parse(result, derivationScheme.Network.NBitcoinNetwork);
}
private bool IsInvalidWalletRequest(string cryptoCode, out BTCPayNetwork network,
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)
{