@@ -4,7 +4,7 @@ use crate::wallet::{Wallet, WalletKeysManager};
4
4
use lightning:: chain:: chainmonitor;
5
5
use lightning:: ln:: channelmanager:: ChannelDetails as LdkChannelDetails ;
6
6
use lightning:: ln:: msgs:: RoutingMessageHandler ;
7
- use lightning:: ln:: msgs:: SocketAddress as LdkSocketAddress ;
7
+ use lightning:: ln:: msgs:: SocketAddress ;
8
8
use lightning:: ln:: peer_handler:: IgnoringMessageHandler ;
9
9
use lightning:: ln:: ChannelId ;
10
10
use lightning:: routing:: gossip;
@@ -20,9 +20,6 @@ use lightning_transaction_sync::EsploraSyncClient;
20
20
use bitcoin:: secp256k1:: PublicKey ;
21
21
use bitcoin:: OutPoint ;
22
22
23
- use std:: fmt:: Display ;
24
- use std:: net:: { Ipv4Addr , Ipv6Addr , SocketAddr , SocketAddrV4 , SocketAddrV6 , ToSocketAddrs } ;
25
- use std:: str:: FromStr ;
26
23
use std:: sync:: { Arc , Mutex , RwLock } ;
27
24
28
25
pub ( crate ) type ChainMonitor < K > = chainmonitor:: ChainMonitor <
@@ -320,106 +317,6 @@ pub struct PeerDetails {
320
317
pub is_connected : bool ,
321
318
}
322
319
323
- /// The network address of a Lightning node.
324
- ///
325
- /// Currently only IPv4, IPv6, and DNS hostnames are supported.
326
- #[ derive( Debug , Clone , PartialEq , Eq ) ]
327
- pub struct SocketAddress ( pub LdkSocketAddress ) ;
328
-
329
- impl Display for SocketAddress {
330
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
331
- match self . 0 {
332
- LdkSocketAddress :: TcpIpV4 { addr, port } => {
333
- let ip_addr = Ipv4Addr :: from ( addr) ;
334
- write ! ( f, "{}:{}" , ip_addr, port)
335
- }
336
- LdkSocketAddress :: TcpIpV6 { addr, port } => {
337
- let ip_addr = Ipv6Addr :: from ( addr) ;
338
- write ! ( f, "[{}]:{}" , ip_addr, port)
339
- }
340
- LdkSocketAddress :: Hostname { ref hostname, port } => {
341
- write ! ( f, "{}:{}" , hostname. as_str( ) , port)
342
- }
343
- LdkSocketAddress :: OnionV2 ( o) => {
344
- write ! ( f, "OnionV2 (unsupported): {:?}" , o)
345
- }
346
- LdkSocketAddress :: OnionV3 { ed25519_pubkey, checksum, version, port } => write ! (
347
- f,
348
- "OnionV3 (unsupported): {:?}/{:?}/{:?}/{:?}" ,
349
- ed25519_pubkey, checksum, version, port
350
- ) ,
351
- }
352
- }
353
- }
354
-
355
- impl FromStr for SocketAddress {
356
- type Err = ( ) ;
357
-
358
- fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
359
- Ok ( Self ( LdkSocketAddress :: from_str ( s) . map_err ( |_| ( ) ) ?) )
360
- }
361
- }
362
-
363
- impl From < SocketAddr > for SocketAddress {
364
- fn from ( value : SocketAddr ) -> Self {
365
- match value {
366
- SocketAddr :: V4 ( v4addr) => SocketAddress :: from ( v4addr) ,
367
- SocketAddr :: V6 ( v6addr) => SocketAddress :: from ( v6addr) ,
368
- }
369
- }
370
- }
371
-
372
- impl From < SocketAddrV4 > for SocketAddress {
373
- fn from ( value : SocketAddrV4 ) -> Self {
374
- Self ( LdkSocketAddress :: TcpIpV4 { addr : value. ip ( ) . octets ( ) , port : value. port ( ) } )
375
- }
376
- }
377
-
378
- impl From < SocketAddrV6 > for SocketAddress {
379
- fn from ( value : SocketAddrV6 ) -> Self {
380
- Self ( LdkSocketAddress :: TcpIpV6 { addr : value. ip ( ) . octets ( ) , port : value. port ( ) } )
381
- }
382
- }
383
-
384
- impl ToSocketAddrs for SocketAddress {
385
- type Iter = std:: option:: IntoIter < SocketAddr > ;
386
-
387
- fn to_socket_addrs ( & self ) -> std:: io:: Result < Self :: Iter > {
388
- match self . 0 {
389
- LdkSocketAddress :: TcpIpV4 { addr, port } => {
390
- let ip_addr = Ipv4Addr :: from ( addr) ;
391
- ( ip_addr, port) . to_socket_addrs ( )
392
- }
393
- LdkSocketAddress :: TcpIpV6 { addr, port } => {
394
- let ip_addr = Ipv6Addr :: from ( addr) ;
395
- ( ip_addr, port) . to_socket_addrs ( )
396
- }
397
- LdkSocketAddress :: Hostname { ref hostname, port } => {
398
- Ok ( ( hostname. as_str ( ) , port) . to_socket_addrs ( ) ?. next ( ) . into_iter ( ) )
399
- }
400
- LdkSocketAddress :: OnionV2 ( ..) => {
401
- Err ( std:: io:: Error :: from ( std:: io:: ErrorKind :: Unsupported ) )
402
- }
403
- LdkSocketAddress :: OnionV3 { .. } => {
404
- Err ( std:: io:: Error :: from ( std:: io:: ErrorKind :: Unsupported ) )
405
- }
406
- }
407
- }
408
- }
409
-
410
- impl Writeable for SocketAddress {
411
- fn write < W : lightning:: util:: ser:: Writer > ( & self , writer : & mut W ) -> Result < ( ) , std:: io:: Error > {
412
- self . 0 . write ( writer)
413
- }
414
- }
415
-
416
- impl Readable for SocketAddress {
417
- fn read < R : std:: io:: Read > ( reader : & mut R ) -> Result < Self , lightning:: ln:: msgs:: DecodeError > {
418
- let addr: LdkSocketAddress = Readable :: read ( reader) ?;
419
- Ok ( Self ( addr) )
420
- }
421
- }
422
-
423
320
/// Options which apply on a per-channel basis.
424
321
///
425
322
/// See documentation of [`LdkChannelConfig`] for details.
0 commit comments