public static bool TryParse(string str, out TrackedSource trackedSource, NBXplorerNetwork network) { if (str == null) { throw new ArgumentNullException(nameof(str)); } if (network == null) { throw new ArgumentNullException(nameof(network)); } trackedSource = null; var strSpan = str.AsSpan(); if (strSpan.StartsWith("DERIVATIONSCHEME:".AsSpan(), StringComparison.Ordinal)) { if (!DerivationSchemeTrackedSource.TryParse(strSpan, out var derivationSchemeTrackedSource, network)) { return(false); } trackedSource = derivationSchemeTrackedSource; } else if (strSpan.StartsWith("ADDRESS:".AsSpan(), StringComparison.Ordinal)) { if (!AddressTrackedSource.TryParse(strSpan, out var addressTrackedSource, network.NBitcoinNetwork)) { return(false); } trackedSource = addressTrackedSource; } else { return(false); } return(true); }
public static bool TryParse(ReadOnlySpan <char> strSpan, out TrackedSource addressTrackedSource, Network network) { if (strSpan == null) { throw new ArgumentNullException(nameof(strSpan)); } if (network == null) { throw new ArgumentNullException(nameof(network)); } addressTrackedSource = null; if (!strSpan.StartsWith("ADDRESS:".AsSpan(), StringComparison.Ordinal)) { return(false); } try { addressTrackedSource = new AddressTrackedSource(BitcoinAddress.Create(strSpan.Slice("ADDRESS:".Length).ToString(), network)); return(true); } catch { return(false); } }