mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-31 20:54:31 +01:00
23 lines
881 B
C#
23 lines
881 B
C#
#nullable enable
|
|
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using BTCPayServer;
|
|
namespace BTCPayServer.Services.WalletFileParsing;
|
|
public class OutputDescriptorWalletFileParser : IWalletFileParser
|
|
{
|
|
public bool TryParse(BTCPayNetwork network, string data, [MaybeNullWhen(false)] out DerivationSchemeSettings derivationSchemeSettings)
|
|
{
|
|
derivationSchemeSettings = null;
|
|
var maybeOutputDesc = !data.Trim().StartsWith("{", StringComparison.OrdinalIgnoreCase);
|
|
if (!maybeOutputDesc)
|
|
return false;
|
|
if (!DerivationSchemeParser.MaybeOD(data))
|
|
return false;
|
|
var derivationSchemeParser = network.GetDerivationSchemeParser();
|
|
derivationSchemeSettings = derivationSchemeParser.ParseOD(data);
|
|
derivationSchemeSettings.Source = "OutputDescriptor";
|
|
return true;
|
|
}
|
|
}
|