diff --git a/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs b/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs
index 111b1e0a2..2d21a1534 100644
--- a/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs
+++ b/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs
@@ -1,5 +1,7 @@
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using NBitcoin;
@@ -36,18 +38,20 @@ namespace BTCPayServer.Models.WalletViewModels
{
if (UploadedPSBTFile.Length > 500 * 1024)
return null;
- byte[] bytes = new byte[UploadedPSBTFile.Length];
- using (var stream = UploadedPSBTFile.OpenReadStream())
- {
- await stream.ReadAsync(bytes, 0, (int)UploadedPSBTFile.Length);
- }
+
try
{
+ byte[] bytes = new byte[UploadedPSBTFile.Length];
+ await using (var stream = UploadedPSBTFile.OpenReadStream())
+ {
+ await stream.ReadAsync(bytes, 0, (int)UploadedPSBTFile.Length);
+ }
return NBitcoin.PSBT.Load(bytes, network);
}
- catch
+ catch (Exception)
{
- return null;
+ using var stream = new StreamReader(UploadedPSBTFile.OpenReadStream());
+ PSBT = await stream.ReadToEndAsync();
}
}
if (!string.IsNullOrEmpty(PSBT))
diff --git a/BTCPayServer/Views/Wallets/WalletPSBT.cshtml b/BTCPayServer/Views/Wallets/WalletPSBT.cshtml
index 2c13a9b17..2711986c3 100644
--- a/BTCPayServer/Views/Wallets/WalletPSBT.cshtml
+++ b/BTCPayServer/Views/Wallets/WalletPSBT.cshtml
@@ -33,16 +33,18 @@
-
-