public void ParseDefaultPortTest() { NodeAddress address = NodeAddress.Parse("0242a4ae0c5bef18048fbecf995094b74bfb0f7391418d71ed394784373f41e4f3@18.184.237.59"); Assert.Equal("18.184.237.59", address.IpAddress); Assert.Equal(9735, address.Port); Assert.Equal("0242a4ae0c5bef18048fbecf995094b74bfb0f7391418d71ed394784373f41e4f3", address.PublicKey.PublicKeyCompressed.ToHex()); }
public Mocks() { PeerService = new Mock <IPeerService>(); FundingService = new Mock <IFundingService>(); ChannelLoggingService = new Mock <IChannelLoggingService>(); CommTxService = new Mock <ICommitmentTransactionService>(); ChannelService = new Mock <IChannelService>(); BlockchainClientService = new Mock <IBlockchainClientService>(); KeyDerivationService = new Mock <IKeyDerivationService>(); BlockchainMonitorService = new Mock <IBlockchainMonitorService>(); WalletService = new Mock <IWalletService>(); LocalNodeKey = new ECKeyPair("DD06232AE9A50384A72D85CED6351DCB35C798231D4985615C77D6847F83FC65", true); NodeAddress = NodeAddress.Parse("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991@1.0.0.1:1111"); LoggerFactory = new LoggerFactory(); Configuration = new ConfigurationBuilder().Build(); Peer = new Mock <IPeer>(); MessagingClient = new Mock <IMessagingClient>(); }
public void ParseInvalidAddressTest1() { Assert.Throws <ArgumentException>(() => NodeAddress.Parse("0242a4ae0c5bef18048fbecf995094b74bfb0f7391418d71ed394784373f41e4f3@[email protected]:9735")); }
public void ParseInvalidPubKeyTest() { Assert.Throws <ArgumentException>(() => NodeAddress.Parse("[email protected]:9735")); }
static void Main(string[] args) { string localPrivateKey = "<node private key>"; ECKeyPair localLightningKey = new ECKeyPair(localPrivateKey, true); string walletSeed = "<wallet private key>"; ECKeyPair walletKey = new ECKeyPair(walletSeed, true); LightningNode node = new LightningNode(localLightningKey, walletKey, NetworkParameters.BitcoinTestnet); node.ConfigureServices(services => { services.AddSingleton <IBlockchainClientService, BitcoindClientService>(); services.AddLogging(logging => logging.SetMinimumLevel(LogLevel.Debug) .AddConsole(options => options.IncludeScopes = false) .AddDebug() .AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning)); services.AddDbContext <NetworkPersistenceContext>(options => options.UseSqlite("Data Source=network.db")); services.AddDbContext <LocalPersistenceContext>(options => options.UseSqlite("Data Source=local.db")); }); node.Initialize(); // Peer Service: var peerService = node.Services.GetService <IPeerService>(); // Channel Service: var channels = node.Services.GetService <IChannelService>(); // Channel Establishment Service: var channelEstablishmentService = node.Services.GetService <IChannelEstablishmentService>(); // Channel State Service: var channelStateService = node.Services.GetService <IChannelStateService>(); // Channel Close Service var closeService = node.Services.GetService <IChannelCloseService>(); channelEstablishmentService.FailureProvider.Subscribe(peerAndPendingChannel => { // Failed to open a channel }); channelEstablishmentService.SuccessProvider.Subscribe(peerAndPendingChannel => { // Opened a channel }); channelStateService.ChannelActiveStateChangedProvider .Where(c => c.Active) .Subscribe(channel => { // Channel is active }); NodeAddress nodeAddress = NodeAddress.Parse("<pubkey@ip:port>"); // Connect to node: IPeer peer = peerService.AddPeer(nodeAddress, persist: false, reconnect: true); // Open a channel with 25000 satoshis capacity channelEstablishmentService.OpenChannel(peer, 25000); System.Console.ReadKey(); }