Skip to content

Commit 75b7c7f

Browse files
committed
Fix: Replace emoji symbols with plain text for Windows PowerShell compatibility
- Replace all emoji symbols (🔍, ✅, 🚀, etc.) with plain text labels [DEBUG], [SUCCESS], [SETUP] - Fix Windows PowerShell hanging issues caused by Unicode emoji rendering - Improve console output readability across different terminal environments - Maintain all functionality while ensuring cross-platform compatibility - Fix compilation errors in interactive_node_setup function - Ensure proper function signatures and return types
1 parent dcab923 commit 75b7c7f

1 file changed

Lines changed: 74 additions & 78 deletions

File tree

development/qnet-integration/src/bin/qnet-node.rs

Lines changed: 74 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -484,87 +484,82 @@ async fn verify_activation_burn(code: &str, node_type: &NodeType) -> Result<(),
484484

485485
// Interactive node setup functions
486486
async fn interactive_node_setup() -> Result<(NodeType, String), Box<dyn std::error::Error>> {
487-
println!("🔍 DEBUG: Entering interactive_node_setup()...");
488-
489-
println!("\n🚀 === QNet Production Node Setup === 🚀");
490-
println!("🖥️ SERVER DEPLOYMENT MODE");
487+
println!("[DEBUG] Entering interactive_node_setup()...");
488+
489+
println!("\n[SETUP] === QNet Production Node Setup ===");
490+
println!("[SERVER] SERVER DEPLOYMENT MODE");
491491
println!("Welcome to QNet Blockchain Network!");
492-
493-
// Detect current economic phase
494-
println!("🔍 DEBUG: Calling detect_current_phase()...");
492+
493+
println!("[DEBUG] Calling detect_current_phase()...");
495494
let (current_phase, pricing_info) = detect_current_phase().await;
496-
println!("🔍 DEBUG: detect_current_phase() completed, phase = {}", current_phase);
497-
495+
println!("[DEBUG] detect_current_phase() completed, phase = {}", current_phase);
496+
498497
// Display phase information
499498
display_phase_info(current_phase, &pricing_info);
500-
501-
// Node type selection (server-only: full/super)
502-
println!("🔍 DEBUG: Calling select_node_type()...");
499+
500+
println!("[DEBUG] Calling select_node_type()...");
503501
let node_type = select_node_type(current_phase, &pricing_info)?;
504-
println!("🔍 DEBUG: select_node_type() completed, type = {:?}", node_type);
505-
506-
// Validate server node type compatibility
507-
if let Err(e) = validate_server_node_type(node_type) {
508-
return Err(e.into());
509-
}
510-
511-
// Show pricing for selected type
512-
let price = calculate_node_price(current_phase, node_type, &pricing_info);
513-
display_activation_cost(current_phase, node_type, price);
514-
515-
// Important notice about activation code requirements
516-
println!("\n🔐 === Activation Code Requirements ===");
517-
match current_phase {
518-
1 => {
519-
println!(" 📊 Phase 1: Universal activation cost");
520-
println!(" 💡 Any activation code will work (same price for all types)");
521-
println!(" 🔥 Activation codes from 1DEV burn transactions");
522-
},
523-
2 => {
524-
println!(" 📊 Phase 2: Tiered activation costs");
525-
println!(" ⚠️ CRITICAL: Activation code MUST match node type");
526-
println!(" �� {:?} node requires {:?} QNC activation code", node_type, price as u64);
527-
println!(" ❌ Wrong activation code type will be rejected");
502+
println!("[DEBUG] select_node_type() completed, type = {:?}", node_type);
503+
504+
// Calculate activation price
505+
let price = match current_phase {
506+
1 => 10.0, // Phase 1: Universal pricing
507+
2 => match node_type {
508+
NodeType::Light => 5.0,
509+
NodeType::Full => 10.0,
510+
NodeType::Super => 20.0,
528511
},
529-
_ => {}
512+
_ => 10.0,
513+
};
514+
515+
println!("\n[SECURITY] === Activation Code Requirements ===");
516+
517+
if current_phase == 1 {
518+
println!(" [INFO] Phase 1: Universal activation cost");
519+
println!(" [BURN] {} 1DEV tokens required", price as u64);
520+
println!(" [INFO] Activation codes from 1DEV burn transactions");
521+
} else {
522+
println!(" [INFO] Phase 2: Tiered activation costs");
523+
println!(" [CRITICAL] CRITICAL: Activation code MUST match node type");
524+
println!(" [COST] {:?} node requires {} tokens", node_type, price as u64);
525+
println!(" [ERROR] Wrong activation code type will be rejected");
530526
}
527+
528+
// Request activation code input
529+
use std::io::Write;
530+
print!("\n[INPUT] === Enter Activation Code ===\nCode: ");
531+
std::io::stdout().flush().unwrap();
531532

532-
// FIXED: Comprehensive validation in retry loop
533-
let activation_code = loop {
534-
println!("\n🔐 === Enter Activation Code ===");
535-
536-
// Request activation code (no validation here, just input)
537-
let code = match request_activation_code(current_phase) {
538-
Ok(code) => code,
539-
Err(e) => {
540-
println!("❌ Error requesting activation code: {}", e);
541-
continue;
542-
}
543-
};
544-
545-
// Comprehensive validation BEFORE accepting code
546-
match validate_activation_code_comprehensive(&code, node_type, current_phase, &pricing_info).await {
547-
Ok(()) => {
548-
println!("✅ Activation code validation successful!");
549-
break code; // Exit loop with valid code
550-
}
551-
Err(e) => {
552-
println!("❌ Activation code validation failed: {}", e);
553-
println!(" Please try again or press Ctrl+C to exit.");
554-
continue; // Continue loop for retry
533+
let mut input = String::new();
534+
let activation_code = match io::stdin().read_line(&mut input) {
535+
Ok(_) => {
536+
let code = input.trim().to_string();
537+
538+
// Handle empty input for genesis bootstrap
539+
if code.is_empty() && is_genesis_bootstrap_node() {
540+
println!("[SUCCESS] Generating genesis bootstrap code...");
541+
match generate_genesis_activation_code() {
542+
Ok(genesis_code) => genesis_code,
543+
Err(e) => {
544+
return Err(format!("Failed to generate genesis code: {}", e).into());
545+
}
546+
}
547+
} else if code.is_empty() {
548+
return Err("Empty activation code not allowed for regular nodes".into());
549+
} else {
550+
code
555551
}
556552
}
553+
Err(e) => return Err(format!("Error reading input: {}", e).into()),
557554
};
558-
559-
println!("\n✅ Server node setup complete!");
560-
println!(" 🖥️ Device Type: Dedicated Server");
561-
println!(" 🔧 Node Type: {:?}", node_type);
562-
println!(" 📊 Phase: {}", current_phase);
563-
println!(" 💰 Cost: {}", format_price(current_phase, price));
564-
println!(" 🔑 Activation Code: {}", mask_code(&activation_code));
565-
println!(" 💾 Activation will be saved with cryptographic binding");
566-
println!(" 🛡️ Universal: Works on VPS, VDS, PC, laptop, server");
567-
println!(" 🚀 Starting node...\n");
555+
556+
println!("\n[SUCCESS] Server node setup complete!");
557+
println!(" [SERVER] Device Type: Dedicated Server");
558+
println!(" [TYPE] Node Type: {:?}", node_type);
559+
println!(" [PHASE] Phase: {}", current_phase);
560+
println!(" [COST] Cost: {} tokens", price as u64);
561+
println!(" [CODE] Activation Code: {}", mask_code(&activation_code));
562+
println!(" [STARTING] Starting node...\n");
568563

569564
Ok((node_type, activation_code))
570565
}
@@ -1444,26 +1439,26 @@ fn extract_ip_from_response(response: &str) -> Option<String> {
14441439
#[tokio::main]
14451440
async fn main() -> Result<(), Box<dyn std::error::Error>> {
14461441
// Critical: This must be the FIRST line to catch any issues
1447-
println!("🔍 DEBUG: QNet node binary started - checking basic functionality...");
1442+
println!("[DEBUG] QNet node binary started - checking basic functionality...");
14481443

14491444
// Test basic functionality before doing anything else
1450-
println!("🔍 DEBUG: Testing std::env...");
1445+
println!("[DEBUG] Testing std::env...");
14511446
if std::env::var("RUST_LOG").is_err() {
14521447
std::env::set_var("RUST_LOG", "info");
14531448
}
1454-
println!("🔍 DEBUG: std::env working");
1449+
println!("[DEBUG] std::env working");
14551450

14561451
// Initialize logging
1457-
println!("🔍 DEBUG: Initializing logger...");
1452+
println!("[DEBUG] Initializing logger...");
14581453
env_logger::init();
1459-
println!("🔍 DEBUG: Logger initialized");
1454+
println!("[DEBUG] Logger initialized");
14601455

14611456
// Auto-configure everything
1462-
println!("🔍 DEBUG: Auto-configuring QNet node...");
1457+
println!("[DEBUG] Auto-configuring QNet node...");
14631458
let config = AutoConfig::new().await?;
14641459

14651460
// Choose setup mode - interactive or auto
1466-
println!("🔍 DEBUG: Starting setup mode selection...");
1461+
println!("[DEBUG] Starting setup mode selection...");
14671462

14681463
// PRODUCTION: Check for existing activation or run interactive setup
14691464
let (node_type, activation_code) = check_existing_activation_or_setup().await?;
@@ -2172,4 +2167,5 @@ fn parse_bootstrap_peers(peers_str: &Option<String>) -> Vec<String> {
21722167
.as_ref()
21732168
.map(|s| s.split(',').map(|p| p.trim().to_string()).collect())
21742169
.unwrap_or_default()
2175-
}
2170+
}
2171+

0 commit comments

Comments
 (0)