コード例 #1
0
        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);
        }