add download psbt action

This commit is contained in:
Kukks 2020-07-14 09:23:28 +02:00
parent d393cee732
commit 016bf1d671
2 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
@ -38,8 +39,20 @@ namespace BTCPayServer.Models.WalletViewModels
if (UploadedPSBTFile.Length > 500 * 1024)
return null;
using var stream = new StreamReader(UploadedPSBTFile.OpenReadStream());
PSBT = await stream.ReadToEndAsync();
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 (Exception)
{
using var stream = new StreamReader(UploadedPSBTFile.OpenReadStream());
PSBT = await stream.ReadToEndAsync();
}
}
if (!string.IsNullOrEmpty(PSBT))
{

View file

@ -43,6 +43,7 @@
<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>