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 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); }
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; }
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); }
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); } }