binary wallet functions fix
This commit is contained in:
parent
7cd421e142
commit
9f3f53ca34
|
|
@ -74,16 +74,28 @@ pub fn require_canonical_registered_short_address(
|
|||
Ok(canonical)
|
||||
}
|
||||
|
||||
pub fn resolve_local_input_short_address(address: &str) -> Result<String, String> {
|
||||
// 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<String, String> {
|
||||
// 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<String, String
|
|||
if let Some(canonical) = resolve_canonical_registered_short_address(&db, &normalized)
|
||||
.map_err(|e| format!("Wallet registry lookup failed: {e}"))?
|
||||
{
|
||||
// Registered vanity aliases are converted to the true owner short address.
|
||||
return Ok(canonical);
|
||||
}
|
||||
|
||||
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 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())
|
||||
}
|
||||
// Registered vanity aliases are converted to the true owner short address.
|
||||
return Ok(canonical);
|
||||
}
|
||||
|
||||
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>)>> {
|
||||
let tree = db.open_tree(WALLET_REGISTRY_TREE)?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue