diff --git a/src/records/wallet_registry/mappings.rs b/src/records/wallet_registry/mappings.rs index 5db1995..c4b3c19 100644 --- a/src/records/wallet_registry/mappings.rs +++ b/src/records/wallet_registry/mappings.rs @@ -74,16 +74,28 @@ pub fn require_canonical_registered_short_address( Ok(canonical) } -pub fn resolve_local_input_short_address(address: &str) -> Result { - // CLI tools may receive long, short, or vanity addresses, so normalize the - // user input before opening the local registry. - let normalized = Wallet::normalize_to_short_address(address) - .ok_or_else(|| "Invalid wallet address.".to_string())?; - - let ( - _network_name, - _padded_base_coin, - _suffix, +pub fn resolve_local_input_short_address(address: &str) -> Result { + // CLI tools may receive long, short, or vanity addresses, so normalize the + // user input before opening the local registry. + let normalized = Wallet::normalize_to_short_address(address) + .ok_or_else(|| "Invalid wallet address.".to_string())?; + + let (payload, _) = normalized + .rsplit_once('.') + .ok_or_else(|| "Invalid wallet address.".to_string())?; + + if payload.len() == Wallet::SHORT_ADDRESS_HASH_BYTES_LENGTH * 2 + && payload.chars().all(|ch| ch.is_ascii_hexdigit()) + { + // A normal hex short address does not need local registry access. The + // receiving node will enforce registration when the tx is submitted. + return Ok(normalized); + } + + let ( + _network_name, + _padded_base_coin, + _suffix, _torrent_path, _wallet_path, _block_path, @@ -97,24 +109,12 @@ pub fn resolve_local_input_short_address(address: &str) -> Result sled::Result, Vec)>> { let tree = db.open_tree(WALLET_REGISTRY_TREE)?;