예제 #1
0
 public PeerManagerProvider(
     INBXplorerClientProvider nbXplorerClientProvider,
     NRustLightningNetworkProvider networkProvider,
     IKeysRepository keysRepository,
     ILoggerFactory loggerFactory,
     ChannelProvider channelProvider,
     IOptions <Config> config
     )
 {
     foreach (var n in networkProvider.GetAll())
     {
         var nbx = nbXplorerClientProvider.TryGetClient(n);
         if (nbx != null)
         {
             var b      = new NbXplorerBroadcaster(nbx, loggerFactory.CreateLogger <NbXplorerBroadcaster>());
             var feeEst = new NbXplorerFeeEstimator(loggerFactory.CreateLogger <NbXplorerFeeEstimator>(),
                                                    channelProvider.GetFeeRateChannel(n).Reader);
             var chainWatchInterface =
                 new NbxChainWatchInterface(nbx, loggerFactory.CreateLogger <NbxChainWatchInterface>(), n);
             var peerManSeed = new byte[32];
             RandomUtils.GetBytes(peerManSeed);
             var logger          = new NativeLogger(loggerFactory.CreateLogger <NativeLogger>());
             var nbitcoinNetwork = n.NBitcoinNetwork;
             var conf            = config.Value.RustLightningConfig;
             var peerMan         = PeerManager.Create(peerManSeed.AsSpan(), nbitcoinNetwork, conf, chainWatchInterface, keysRepository, b,
                                                      logger, feeEst, 400000);
             _peerManagers.Add(n.CryptoCode, peerMan);
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Service for handling on-chain balance
 /// </summary>
 /// <param name="keysRepository"></param>
 /// <param name="nbXplorerClientProvider"></param>
 public WalletService(IKeysRepository keysRepository, INBXplorerClientProvider nbXplorerClientProvider, ILogger <WalletService> logger, RepositoryProvider repositoryProvider)
 {
     _keysRepository          = keysRepository;
     _nbXplorerClientProvider = nbXplorerClientProvider;
     _logger             = logger;
     _repositoryProvider = repositoryProvider;
 }
예제 #3
0
 public ChannelProvider(INBXplorerClientProvider clientProvider, NRustLightningNetworkProvider networkProvider)
 {
     foreach (var n in networkProvider.GetAll())
     {
         var maybeClient = clientProvider.TryGetClient(n.CryptoCode);
         if (maybeClient != null)
         {
             _feeRateChannels.Add(n.CryptoCode, Channel.CreateBounded <FeeRateSet>(50));
         }
     }
 }
예제 #4
0
 public DataFlowProvider(INBXplorerClientProvider clientProvider, NRustLightningNetworkProvider networkProvider)
 {
     foreach (var n in networkProvider.GetAll())
     {
         var maybeClient = clientProvider.TryGetClient(n.CryptoCode);
         if (maybeClient != null)
         {
             var inputBuffer = new BufferBlock <FeeRateSet>();
             _feeRateSourceBlock.Add(n.CryptoCode, inputBuffer);
             throw new NotImplementedException();
         }
     }
 }
예제 #5
0
 public ChannelProvider(INBXplorerClientProvider clientProvider, NRustLightningNetworkProvider networkProvider)
 {
     foreach (var n in networkProvider.GetAll())
     {
         var maybeClient = clientProvider.TryGetClient(n.CryptoCode);
         if (maybeClient != null)
         {
             _feeRateChannels.Add(n.CryptoCode, Channel.CreateBounded <FeeRateSet>(50));
             _outboundConnectionRequestChannel.Add(n.CryptoCode, Channel.CreateBounded <PeerConnectionString>(1000));
             _spendableOutputDescriptorChannel.Add(n.CryptoCode, Channel.CreateBounded <SpendableOutputDescriptor>(100000));
         }
     }
 }
 public WalletController(NRustLightningNetworkProvider networkProvider,
                         IWalletService walletService,
                         PeerManagerProvider peerManagerProvider,
                         RepositoryProvider repositoryProvider,
                         INBXplorerClientProvider clientProvider)
 {
     _networkProvider     = networkProvider;
     _walletService       = walletService;
     _peerManagerProvider = peerManagerProvider;
     _repositoryProvider  = repositoryProvider;
     _clientProvider      = clientProvider;
     _pool = MemoryPool <byte> .Shared;
 }
 public NBXplorerListeners(NRustLightningNetworkProvider networkProvider, INBXplorerClientProvider clientProvider, PeerManagerProvider peerManagerProvider, ILoggerFactory loggerFactory,
                           ChannelProvider channelProvider)
 {
     foreach (var n in networkProvider.GetAll())
     {
         var cli = clientProvider.TryGetClient(n);
         if (cli != null)
         {
             var listener = new NBXplorerListener(cli, peerManagerProvider, loggerFactory.CreateLogger <NBXplorerListener>(), channelProvider.GetFeeRateChannel(n).Writer, n);
             _listeners.TryAdd(n.CryptoCode, listener);
         }
     }
 }
 public PeerManagerProvider(
     INBXplorerClientProvider nbXplorerClientProvider,
     NRustLightningNetworkProvider networkProvider,
     IKeysRepository keysRepository,
     ILoggerFactory loggerFactory,
     ChannelProvider channelProvider,
     IOptions <Config> config,
     RepositoryProvider repositoryProvider,
     EventAggregator eventAggregator
     )
 {
     _nbXplorerClientProvider = nbXplorerClientProvider;
     _networkProvider         = networkProvider;
     _keysRepository          = keysRepository;
     _loggerFactory           = loggerFactory;
     _logger             = loggerFactory.CreateLogger <PeerManagerProvider>();
     _channelProvider    = channelProvider;
     _config             = config;
     _repositoryProvider = repositoryProvider;
     _eventAggregator    = eventAggregator;
 }
 public RustLightningEventReactors(NRustLightningNetworkProvider networkProvider, INBXplorerClientProvider clientProvider, IServiceProvider serviceProvider, ILoggerFactory loggerFactory)
 {
     foreach (var n in networkProvider.GetAll())
     {
         var cli = clientProvider.TryGetClient(n);
         if (cli != null) // it means we want  to support that chain.
         {
             var reactor = new RustLightningEventReactor(
                 serviceProvider.GetRequiredService <P2PConnectionHandler>(),
                 serviceProvider.GetRequiredService <PeerManagerProvider>(),
                 serviceProvider.GetRequiredService <IWalletService>(),
                 n,
                 serviceProvider.GetRequiredService <EventAggregator>(),
                 loggerFactory.CreateLogger(nameof(RustLightningEventReactor) + $":{n.CryptoCode}"),
                 serviceProvider.GetRequiredService <InvoiceService>(),
                 serviceProvider.GetRequiredService <ChannelProvider>(),
                 serviceProvider.GetRequiredService <IRepository>()
                 );
             Reactors.Add(n.CryptoCode, reactor);
         }
     }
 }