mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
* Editorconfig: Add space_before_self_closing setting This was a difference between the way dotnet-format and Rider format code. See https://www.jetbrains.com/help/rider/EditorConfig_Index.html * Editorconfig: Keep 4 spaces indentation for Swagger JSON files They are all formatted that way, let's keep it like that. * Apply dotnet-format, mostly white-space related changes
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using NBitcoin;
|
|
|
|
namespace BTCPayServer.Models.WalletViewModels
|
|
{
|
|
public class WalletPSBTCombineViewModel
|
|
{
|
|
public string OtherPSBT { get; set; }
|
|
[Display(Name = "PSBT to combine with...")]
|
|
public string PSBT { get; set; }
|
|
[Display(Name = "Upload PSBT from file...")]
|
|
public IFormFile UploadedPSBTFile { get; set; }
|
|
|
|
public string BackUrl { get; set; }
|
|
public string ReturnUrl { get; set; }
|
|
|
|
public PSBT GetSourcePSBT(Network network)
|
|
{
|
|
if (!string.IsNullOrEmpty(OtherPSBT))
|
|
{
|
|
try
|
|
{
|
|
return NBitcoin.PSBT.Parse(OtherPSBT, network);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return null;
|
|
}
|
|
public async Task<PSBT> GetPSBT(Network network)
|
|
{
|
|
if (UploadedPSBTFile != null)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(PSBT))
|
|
{
|
|
try
|
|
{
|
|
return NBitcoin.PSBT.Parse(PSBT, network);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|