binary wallet functions fix

This commit is contained in:
viraladmin 2026-06-02 18:09:46 -06:00
parent 7cd421e142
commit 9f3f53ca34
1 changed files with 28 additions and 28 deletions

View File

@ -74,16 +74,28 @@ pub fn require_canonical_registered_short_address(
Ok(canonical) Ok(canonical)
} }
pub fn resolve_local_input_short_address(address: &str) -> Result<String, String> { pub fn resolve_local_input_short_address(address: &str) -> Result<String, String> {
// CLI tools may receive long, short, or vanity addresses, so normalize the // CLI tools may receive long, short, or vanity addresses, so normalize the
// user input before opening the local registry. // user input before opening the local registry.
let normalized = Wallet::normalize_to_short_address(address) let normalized = Wallet::normalize_to_short_address(address)
.ok_or_else(|| "Invalid wallet address.".to_string())?; .ok_or_else(|| "Invalid wallet address.".to_string())?;
let ( let (payload, _) = normalized
_network_name, .rsplit_once('.')
_padded_base_coin, .ok_or_else(|| "Invalid wallet address.".to_string())?;
_suffix,
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, _torrent_path,
_wallet_path, _wallet_path,
_block_path, _block_path,
@ -97,24 +109,12 @@ pub fn resolve_local_input_short_address(address: &str) -> Result<String, String
if let Some(canonical) = resolve_canonical_registered_short_address(&db, &normalized) if let Some(canonical) = resolve_canonical_registered_short_address(&db, &normalized)
.map_err(|e| format!("Wallet registry lookup failed: {e}"))? .map_err(|e| format!("Wallet registry lookup failed: {e}"))?
{ {
// Registered vanity aliases are converted to the true owner short address. // Registered vanity aliases are converted to the true owner short address.
return Ok(canonical); return Ok(canonical);
} }
let (payload, _) = normalized Err("Vanity address could not be resolved to a canonical short address.".to_string())
.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 can be used even if the local wallet
// registry has not learned it yet.
return Ok(normalized);
}
Err("Vanity address could not be resolved to a canonical short address.".to_string())
}
pub fn list_registered_wallets(db: &Db) -> sled::Result<Vec<(Vec<u8>, Vec<u8>)>> { pub fn list_registered_wallets(db: &Db) -> sled::Result<Vec<(Vec<u8>, Vec<u8>)>> {
let tree = db.open_tree(WALLET_REGISTRY_TREE)?; let tree = db.open_tree(WALLET_REGISTRY_TREE)?;