From d393cee7326dc499655c16ceaa34ea70cb6939d5 Mon Sep 17 00:00:00 2001 From: Kukks Date: Tue, 14 Jul 2020 09:18:40 +0200 Subject: [PATCH 1/2] streamline decode of uploaded psbt file + fix action button alginment --- .../WalletViewModels/WalletPSBTViewModel.cs | 17 ++++----------- BTCPayServer/Views/Wallets/WalletPSBT.cshtml | 21 ++++++++++--------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs b/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs index 111b1e0a2..04f70c7bf 100644 --- a/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs +++ b/BTCPayServer/Models/WalletViewModels/WalletPSBTViewModel.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using NBitcoin; @@ -36,19 +37,9 @@ 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 - { - return NBitcoin.PSBT.Load(bytes, network); - } - catch - { - 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..6898bbba6 100644 --- a/BTCPayServer/Views/Wallets/WalletPSBT.cshtml +++ b/BTCPayServer/Views/Wallets/WalletPSBT.cshtml @@ -33,16 +33,17 @@ - - -