Merge pull request #1740 from btcpayserver/psbt-decode

streamline decode of uploaded psbt file + fix action button alginment
This commit is contained in:
Nicolas Dorier
2020-07-14 16:43:19 +09:00
committed by GitHub
2 changed files with 23 additions and 17 deletions

View File

@@ -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))

View File

@@ -33,16 +33,18 @@
<input type="hidden" asp-for="NBXSeedAvailable" />
<input type="hidden" asp-for="PSBT" />
<input type="hidden" asp-for="FileName" />
<partial name="WalletSigningMenu" model="@((Model.CryptoCode, Model.NBXSeedAvailable))" />
<div class="dropdown d-inline-block">
<button class="btn btn-secondary dropdown-toggle" type="button" id="OtherActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Other actions...
</button>
<div class="dropdown-menu" aria-labelledby="OtherActions">
<button name="command" type="submit" class="dropdown-item" value="broadcast">Review</button>
<button name="command" type="submit" class="dropdown-item" value="update">Update</button>
<button name="command" type="submit" class="dropdown-item" value="combine">Combine</button>
<div class="d-flex">
<partial name="WalletSigningMenu" model="@((Model.CryptoCode, Model.NBXSeedAvailable))"/>
<div class="ml-2 dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="OtherActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Other actions...
</button>
<div class="dropdown-menu" aria-labelledby="OtherActions">
<button name="command" type="submit" class="dropdown-item" value="broadcast">Review</button>
<button name="command" type="submit" class="dropdown-item" value="update">Update</button>
<button name="command" type="submit" class="dropdown-item" value="combine">Combine</button>
<button name="command" type="submit" class="dropdown-item" value="save-psbt">Download</button>
</div>
</div>
</div>
</form>