Improve error message for create store wallet transaction (Fix #3256)

This commit is contained in:
nicolas.dorier 2022-01-10 11:59:13 +09:00
parent e957180618
commit 03af471f65
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
3 changed files with 12 additions and 9 deletions

View File

@ -23,7 +23,7 @@ namespace BTCPayServer.Controllers.GreenField
if (!_walletProvider.IsAvailable(network))
{
return this.CreateAPIError("not-available",
return this.CreateAPIError(503, "not-available",
$"{cryptoCode} services are not currently available");
}
@ -59,13 +59,13 @@ namespace BTCPayServer.Controllers.GreenField
response = await client.GenerateWalletAsync(request);
if (response == null)
{
return this.CreateAPIError("not-available",
return this.CreateAPIError(503, "not-available",
$"{cryptoCode} services are not currently available");
}
}
catch (Exception e)
{
return this.CreateAPIError("not-available",
return this.CreateAPIError(503, "not-available",
$"{cryptoCode} error: {e.Message}");
}

View File

@ -271,14 +271,14 @@ namespace BTCPayServer.Controllers.GreenField
return actionResult;
if (network.ReadonlyWallet)
{
return this.CreateAPIError("not-available",
return this.CreateAPIError(503, "not-available",
$"{cryptoCode} sending services are not currently available");
}
//This API is only meant for hot wallet usage for now. We can expand later when we allow PSBT manipulation.
if (!(await CanUseHotWallet()).HotWallet)
{
return Unauthorized();
return this.CreateAPIError(503, "not-available", $"You need to allow non-admins to use hotwallets for their stores (in /server/policies)");
}
var explorerClient = _explorerClientProvider.GetExplorerClient(cryptoCode);
@ -425,7 +425,7 @@ namespace BTCPayServer.Controllers.GreenField
}
catch (NotSupportedException)
{
return this.CreateAPIError("not-available", "You need to update your version of NBXplorer");
return this.CreateAPIError(503, "not-available", "You need to update your version of NBXplorer");
}
derivationScheme.RebaseKeyPaths(psbt.PSBT);
@ -445,7 +445,7 @@ namespace BTCPayServer.Controllers.GreenField
WellknownMetadataKeys.MasterHDKey);
if (!derivationScheme.IsHotWallet || signingKeyStr is null)
{
return this.CreateAPIError("not-available",
return this.CreateAPIError(503, "not-available",
$"{cryptoCode} sending services are not currently available");
}
@ -538,7 +538,7 @@ namespace BTCPayServer.Controllers.GreenField
if (!network.WalletSupported || !_btcPayWalletProvider.IsAvailable(network))
{
actionResult = this.CreateAPIError("not-available",
actionResult = this.CreateAPIError(503, "not-available",
$"{cryptoCode} services are not currently available");
return true;
}
@ -546,7 +546,7 @@ namespace BTCPayServer.Controllers.GreenField
derivationScheme = GetDerivationSchemeSettings(cryptoCode);
if (derivationScheme?.AccountDerivation is null)
{
actionResult = this.CreateAPIError("not-available",
actionResult = this.CreateAPIError(503, "not-available",
$"{cryptoCode} doesn't have any derivation scheme set");
return true;
}

View File

@ -317,6 +317,9 @@
},
"404": {
"description": "The key is not found for this store/wallet"
},
"503": {
"description": "You need to allow non-admins to use hotwallets for their stores (in /server/policies)"
}
},
"security": [