Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions scripts/high_security_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# High Security Example Script
# This script demonstrates the high security features of the Quantus blockchain.
# It sets up a guardian for an account and demonstrates the reversible transfer functionality.
# It also demonstrates the recovery pallet functionality.

# set this to your binary
alias quantus="./target/release/quantus --node-url ws://127.0.0.1:9944"

# Alice sets charlie as her guardian with a 1 hour delay
quantus high-security set --from crystal_alice --interceptor crystal_charlie --delay-seconds 3600

# Check the status of the high security
quantus high-security status --account crystal_alice

# fail case 1 Alice sets bob as her interceptor - this should fail because alice already has a guardian
quantus high-security set --from crystal_alice --interceptor crystal_bob --delay-seconds 3600

# fail case 2 could also try to send a normal tx - should fail
quantus send --from crystal_alice --to crystal_bob --amount 9999

# fail case 3 also send a reversible with a different delay more or less - should fail
quantus reversible schedule-transfer-with-delay --from crystal_alice --to crystal_bob --amount 5556 --delay 90

# Check balances of Alice and Charlie
quantus balance --address crystal_alice
quantus balance --address crystal_charlie

# Alice sends a reversible transfer to bob over 500000 coins of quantus over 1 hour delay
quantus reversible schedule-transfer --from crystal_alice --to crystal_bob --amount 500000

quantus reversible list-pending --from crystal_alice

# Interceptor account charlie reverses transaction
quantus reversible cancel --tx-id 0xb8ee1f940e13fbc171481d1b06967760bf1d39f06dbcdb595c02c420aec6a45e --from crystal_charlie

# Check balances of Alice, Bob, and Charlie
quantus balance --address crystal_alice
quantus balance --address crystal_bob
quantus balance --address crystal_charlie

# activate the recovery first vouch then claim.
ququantus recovery initiate --rescuer crystal_charlie --lost crystal_alice
quantus recovery active --rescuer crystal_charlie --lost crystal_alice
quantus recovery vouch --rescuer crystal_charlie --lost crystal_alice --friend crystal_charlie
quantus recovery claim --rescuer crystal_charlie --lost crystal_alice
quantus recovery proxy-of --rescuer crystal_charlie

# Charlie pulls all money from Alice's account
quantus recovery recover-all --rescuer crystal_charlie --lost crystal_alice --dest crystal_charlie

# Check balances of Alice, Bob, and Charlie
quantus balance --address crystal_alice
quantus balance --address crystal_bob
quantus balance --address crystal_charlie
15 changes: 3 additions & 12 deletions src/chain/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ impl QuantusClient {
)));
}

// Provide helpful hints for common URL issues
if node_url.starts_with("ws://") &&
(node_url.contains("a.i.res.fm") || node_url.contains("a.t.res.fm"))
{
log_verbose!(
"💡 Hint: Remote nodes typically require secure WebSocket connections (wss://)"
);
}

// Create WS client with custom timeouts
let ws_client = WsClientBuilder::default()
// TODO: Make these configurable in a separate change
Expand All @@ -85,11 +76,11 @@ impl QuantusClient {
// Provide more helpful error messages for common issues
let error_str = format!("{e:?}");
let error_msg = if error_str.contains("TimedOut") || error_str.contains("timed out") {
if node_url.starts_with("ws://") && (node_url.contains("a.i.res.fm") || node_url.contains("a.t.res.fm")) {
if node_url.starts_with("ws://") {
format!(
"Connection timed out. This remote node requires secure WebSocket connections (wss://). Try using 'wss://{}' instead of 'ws://{}'",
"Connection timed out. Try using 'wss://{}' instead of '{}'",
node_url.strip_prefix("ws://").unwrap_or(node_url),
node_url.strip_prefix("ws://").unwrap_or(node_url)
node_url
)
} else {
format!("Connection timed out. Please check if the node is running and accessible at: {node_url}")
Expand Down
8 changes: 4 additions & 4 deletions src/cli/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum BatchCommands {
pub async fn handle_batch_command(
command: BatchCommands,
node_url: &str,
finalized: bool,
execution_mode: crate::cli::common::ExecutionMode,
) -> Result<()> {
match command {
BatchCommands::Send {
Expand All @@ -86,7 +86,7 @@ pub async fn handle_batch_command(
count,
to,
amount,
finalized,
execution_mode,
)
.await,
BatchCommands::Config { limits, info } =>
Expand All @@ -105,7 +105,7 @@ async fn handle_batch_send_command(
count: Option<u32>,
to: Option<String>,
amount: Option<String>,
finalized: bool,
execution_mode: crate::cli::common::ExecutionMode,
) -> Result<()> {
// Create quantus chain client
let quantus_client = QuantusClient::new(node_url).await?;
Expand Down Expand Up @@ -166,7 +166,7 @@ async fn handle_batch_send_command(

// Submit batch transaction
let tx_hash =
batch_transfer(&quantus_client, &keypair, transfers, tip_amount, finalized).await?;
batch_transfer(&quantus_client, &keypair, transfers, tip_amount, execution_mode).await?;

log_print!(
"✅ {} Batch transaction submitted! Hash: {:?}",
Expand Down
Loading