예제 #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);
        }
예제 #2
0
 public KeyPathInformation(Derivation derivation, DerivationSchemeTrackedSource derivationStrategy, DerivationFeature feature, KeyPath keyPath, NBXplorerNetwork network)
 {
     ScriptPubKey       = derivation.ScriptPubKey;
     Redeem             = derivation.Redeem;
     TrackedSource      = derivationStrategy;
     DerivationStrategy = derivationStrategy.DerivationStrategy;
     Feature            = feature;
     KeyPath            = keyPath;
     Address            = network.CreateAddress(derivationStrategy.DerivationStrategy, keyPath, ScriptPubKey);
 }
예제 #3
0
        public KeyPathInformation(KeyPathTemplates keyPathTemplates, KeyPath keyPath, DerivationStrategyBase derivationStrategy)
        {
            var derivation = derivationStrategy.GetDerivation(keyPath);

            ScriptPubKey       = derivation.ScriptPubKey;
            Redeem             = derivation.Redeem;
            TrackedSource      = new DerivationSchemeTrackedSource(derivationStrategy);
            DerivationStrategy = derivationStrategy;
            Feature            = keyPathTemplates.GetDerivationFeature(keyPath);
            KeyPath            = keyPath;
        }
예제 #4
0
        public KeyPathInformation(KeyPathTemplates keyPathTemplates, KeyPath keyPath, DerivationStrategyBase derivationStrategy, NBXplorerNetwork network)
        {
            var derivation = derivationStrategy.GetDerivation(keyPath);

            ScriptPubKey       = derivation.ScriptPubKey;
            Redeem             = derivation.Redeem;
            TrackedSource      = new DerivationSchemeTrackedSource(derivationStrategy);
            DerivationStrategy = derivationStrategy;
            Feature            = keyPathTemplates.GetDerivationFeature(keyPath);
            KeyPath            = keyPath;
            Address            = network.CreateAddress(derivationStrategy, keyPath, ScriptPubKey);
        }
예제 #5
0
 public static bool TryParse(ReadOnlySpan <char> strSpan, out DerivationSchemeTrackedSource derivationSchemeTrackedSource, NBXplorerNetwork network)
 {
     if (strSpan == null)
     {
         throw new ArgumentNullException(nameof(strSpan));
     }
     if (network == null)
     {
         throw new ArgumentNullException(nameof(network));
     }
     derivationSchemeTrackedSource = null;
     if (!strSpan.StartsWith("DERIVATIONSCHEME:".AsSpan(), StringComparison.Ordinal))
     {
         return(false);
     }
     try
     {
         var factory          = network.DerivationStrategyFactory;
         var derivationScheme = factory.Parse(strSpan.Slice("DERIVATIONSCHEME:".Length).ToString());
         derivationSchemeTrackedSource = new DerivationSchemeTrackedSource(derivationScheme);
         return(true);
     }
     catch { return(false); }
 }