示例#1
0
        private ScannedItems GetScannedItems(ScanUTXOWorkItem workItem, ScanUTXOProgress progress)
        {
            var items = new ScannedItems();
            var derivationStrategy = workItem.DerivationStrategy;

            foreach (var feature in workItem.Options.DerivationFeatures)
            {
                var path           = DerivationStrategyBase.GetKeyPath(feature);
                var lineDerivation = workItem.DerivationStrategy.DerivationStrategy.GetLineFor(feature);
                Enumerable.Range(progress.From, progress.Count)
                .Select(index =>
                {
                    var derivation = lineDerivation.Derive((uint)index);
                    var info       = new KeyPathInformation()
                    {
                        ScriptPubKey       = derivation.ScriptPubKey,
                        Redeem             = derivation.Redeem,
                        TrackedSource      = derivationStrategy,
                        DerivationStrategy = derivationStrategy.DerivationStrategy,
                        Feature            = feature,
                        KeyPath            = path.Derive(index, false)
                    };
                    items.Descriptors.Add(new ScanTxoutSetObject(ScanTxoutDescriptor.Raw(info.ScriptPubKey)));
                    items.KeyPathInformations.TryAdd(info.ScriptPubKey, info);
                    return(info);
                }).All(_ => true);
            }
            Logs.Explorer.LogInformation($"{workItem.Network.CryptoCode}: Start scanning batch {progress.BatchNumber} of {workItem.DerivationStrategy.ToPrettyString()} from index {progress.From}");
            return(items);
        }
示例#2
0
 internal static KeyPathInformation AddAddress(this KeyPathInformation keyPathInformation, Network network)
 {
     if (keyPathInformation.Address == null)
     {
         keyPathInformation.Address = keyPathInformation.ScriptPubKey.GetDestinationAddress(network).ToString();
     }
     return(keyPathInformation);
 }
示例#3
0
 public void CanSerializeKeyPathFast()
 {
     using (var tester = RepositoryTester.Create(true))
     {
         var seria   = new Serializer(Network.RegTest);
         var keyInfo = new KeyPathInformation()
         {
             DerivationStrategy = DummyPubKey, Feature = DerivationFeature.Change, KeyPath = new KeyPath("0/1"), Redeem = Script.Empty, ScriptPubKey = Script.Empty
         };
         var str = seria.ToString(keyInfo);
         for (int i = 0; i < 1500; i++)
         {
             seria.ToObject <KeyPathInformation>(str);
         }
     }
 }
示例#4
0
        private ScannedItems GetScannedItems(ScanUTXOWorkItem workItem, ScanUTXOProgress progress, NBXplorerNetwork network)
        {
            var items = new ScannedItems();
            var derivationStrategy = workItem.DerivationStrategy;

            foreach (var feature in keyPathTemplates.GetSupportedDerivationFeatures())
            {
                var keyPathTemplate = keyPathTemplates.GetKeyPathTemplate(feature);
                var lineDerivation  = workItem.DerivationStrategy.DerivationStrategy.GetLineFor(keyPathTemplate);
                Enumerable.Range(progress.From, progress.Count)
                .Select(index =>
                {
                    var derivation = lineDerivation.Derive((uint)index);
                    var info       = new KeyPathInformation(derivation, derivationStrategy, feature,
                                                            keyPathTemplate.GetKeyPath(index, false), network);
                    items.Descriptors.Add(new ScanTxoutSetObject(ScanTxoutDescriptor.Raw(info.ScriptPubKey)));
                    items.KeyPathInformations.TryAdd(info.ScriptPubKey, info);
                    return(info);
                }).All(_ => true);
            }
            Logs.Explorer.LogInformation($"{workItem.Network.CryptoCode}: Start scanning batch {progress.BatchNumber} of {workItem.DerivationStrategy.ToPrettyString()} from index {progress.From}");
            return(items);
        }
 private void Set(WalletId walletId, KeyPathInformation information)
 {
     _walletReceiveState.AddOrReplace(walletId, information);
 }
示例#6
0
 public static void MarkAsUsed(this Repository repo, KeyPathInformation info)
 {
     repo.MarkAsUsedAsync(new KeyPathInformation[] { info }).GetAwaiter().GetResult();
 }