@@ -125,9 +125,14 @@ pub unsafe extern "C" fn dash_spv_ffi_config_set_max_peers(
125125
126126/// Adds a peer address to the configuration
127127///
128- /// Accepts either a full socket address (e.g., `192.168.1.1:9999` or `[::1]:19999`)
129- /// or an IP-only string (e.g., "127.0.0.1" or "2001:db8::1"). When an IP-only
130- /// string is given, the default P2P port for the configured network is used.
128+ /// Accepts socket addresses with or without port. When no port is specified,
129+ /// the default P2P port for the configured network is used.
130+ ///
131+ /// Supported formats:
132+ /// - IP with port: `192.168.1.1:9999`, `[::1]:19999`
133+ /// - IP without port: `127.0.0.1`, `2001:db8::1`
134+ /// - Hostname with port: `node.example.com:9999`
135+ /// - Hostname without port: `node.example.com`
131136///
132137/// # Safety
133138/// - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
@@ -171,24 +176,14 @@ pub unsafe extern "C" fn dash_spv_ffi_config_add_peer(
171176 return FFIErrorCode :: Success as i32 ;
172177 }
173178
174- // 3) Attempt DNS resolution for hostnames with explicit port
175- match addr_str. split_once ( ':' ) {
176- None => {
177- set_last_error ( "Invalid hostname. Use 'host:port' or IP address" ) ;
178- return FFIErrorCode :: InvalidArgument as i32 ;
179- }
180- Some ( ( "" , _) ) => {
181- set_last_error ( "Missing hostname. Use 'host:port' or IP address" ) ;
182- return FFIErrorCode :: InvalidArgument as i32 ;
183- }
184- Some ( ( _, "" ) ) => {
185- set_last_error ( "Missing port. Use 'host:port' or IP address" ) ;
186- return FFIErrorCode :: InvalidArgument as i32 ;
187- }
188- Some ( _) => { }
189- }
179+ // 3) Must be a hostname - reject empty, append default port if not specified
180+ let addr_with_port = if addr_str. contains ( ':' ) {
181+ addr_str. to_string ( )
182+ } else {
183+ format ! ( "{}:{}" , addr_str, default_port)
184+ } ;
190185
191- match addr_str . to_socket_addrs ( ) {
186+ match addr_with_port . to_socket_addrs ( ) {
192187 Ok ( mut iter) => match iter. next ( ) {
193188 Some ( sock) => {
194189 cfg. peers . push ( sock) ;
0 commit comments