Show proper error message if the keypath in wallet settings is not good (Fix #1209)

This commit is contained in:
nicolas.dorier
2019-12-03 14:26:52 +09:00
parent 71a8166027
commit a3fc75ea3b
3 changed files with 24 additions and 16 deletions

View File

@@ -387,9 +387,16 @@ namespace BTCPayServer.Controllers
{
subtractFeesOutputsCount.Add(i);
}
var destination = ParseDestination(transactionOutput.DestinationAddress, network.NBitcoinNetwork);
if (destination == null)
transactionOutput.DestinationAddress = transactionOutput.DestinationAddress.Trim();
try
{
BitcoinAddress.Create(transactionOutput.DestinationAddress, network.NBitcoinNetwork);
}
catch
{
ModelState.AddModelError(nameof(transactionOutput.DestinationAddress), "Invalid address");
}
if (transactionOutput.Amount.HasValue)
{
@@ -600,19 +607,6 @@ namespace BTCPayServer.Controllers
return v.ToString() + " " + network.CryptoCode;
}
private IDestination[] ParseDestination(string destination, Network network)
{
try
{
destination = destination?.Trim();
return new IDestination[] { BitcoinAddress.Create(destination, network) };
}
catch
{
return null;
}
}
private IActionResult RedirectToWalletTransaction(WalletId walletId, Transaction transaction)
{
var network = NetworkProvider.GetNetwork<BTCPayNetwork>(walletId.CryptoCode);