Improve error handling for export psbt

This commit is contained in:
nicolas.dorier
2019-05-08 23:58:25 +09:00
parent aa23222339
commit 3bf4eea1fe

View File

@@ -244,8 +244,21 @@ namespace BTCPayServer.Controllers
{ {
var storeData = (await Repository.FindStore(walletId.StoreId, GetUserId())); var storeData = (await Repository.FindStore(walletId.StoreId, GetUserId()));
var derivationScheme = GetPaymentMethod(walletId, storeData); var derivationScheme = GetPaymentMethod(walletId, storeData);
var psbt = await CreatePSBT(network, derivationScheme, sendModel, cancellation); try
return File(psbt.PSBT.ToBytes(), "application/octet-stream", $"Send-{vm.Amount.Value}-{network.CryptoCode}-to-{destination[0].ToString()}.psbt"); {
var psbt = await CreatePSBT(network, derivationScheme, sendModel, cancellation);
return File(psbt.PSBT.ToBytes(), "application/octet-stream", $"Send-{vm.Amount.Value}-{network.CryptoCode}-to-{destination[0].ToString()}.psbt");
}
catch (NBXplorerException ex)
{
ModelState.AddModelError(nameof(vm.Amount), ex.Error.Message);
return View(vm);
}
catch (NotSupportedException)
{
ModelState.AddModelError(nameof(vm.Destination), "You need to update your version of NBXplorer");
return View(vm);
}
} }
} }
@@ -283,7 +296,6 @@ namespace BTCPayServer.Controllers
} }
} }
if (derivationSettings.AccountKeyPath != null && derivationSettings.AccountKeyPath.Indexes.Length != 0) if (derivationSettings.AccountKeyPath != null && derivationSettings.AccountKeyPath.Indexes.Length != 0)
{ {
// NBX only know the path relative to the account xpub. // NBX only know the path relative to the account xpub.