Updated use of base58 encoding with proper error handling.