Skip to content
Closed
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
85 changes: 83 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions examples/exex/stealth-addresses/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "example-exex-stealth-addresses"
version = "0.0.0"
publish = false
edition.workspace = true
license.workspace = true

[dependencies]
reth.workspace = true
reth-chainspec.workspace = true
reth-cli-commands.workspace = true
reth-cli-runner.workspace = true
reth-db.workspace = true
reth-exex.workspace = true
reth-node-api.workspace = true
reth-node-builder.workspace = true
reth-node-ethereum.workspace = true
reth-tracing.workspace = true
reth-execution-types.workspace = true

alloy-primitives.workspace = true
alloy-sol-types = { workspace = true, features = ["json"] }

k256 = { version = "0.13", default-features = false, features = ["ecdsa"] }
chacha20poly1305 = "0.10.1"

eyre.workspace = true
futures.workspace = true
clap.workspace = true

[[bin]]
name = "stealthy"
path = "src/main.rs"
37 changes: 37 additions & 0 deletions examples/exex/stealth-addresses/solidity/send_stealth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "forge-std/Script.sol";

interface IERC5564Announcer {
function announce(
uint256 schemeId,
address stealthAddress,
bytes memory ephemeralPubKey,
bytes memory metadata
) external;
}

contract Stealthy is Script {

function run(address stealthAddress, bytes memory ephemeralPubKey, bytes memory metadata) external payable {
require(ephemeralPubKey.length == 33, "Public key must be 33 bytes");

uint256 spender = vm.envUint("SPEND");
IERC5564Announcer announcer = IERC5564Announcer(0x55649E01B5Df198D18D95b5cc5051630cfD45564);

vm.startBroadcast(spender);

payable(stealthAddress).transfer(0.5 ether);

announcer.announce(
1, // secp256k1
stealthAddress,
ephemeralPubKey,
abi.encodePacked(metadata)
);

vm.stopBroadcast();

}
}
73 changes: 73 additions & 0 deletions examples/exex/stealth-addresses/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//! CLI definition and entrypoint to executable

use clap::{Parser, Subcommand};
use reth::{
args::{
utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS},
LogArgs,
},
version::{LONG_VERSION, SHORT_VERSION},
};
use reth_chainspec::ChainSpec;
use reth_cli_commands::node::{self, NoArgs};
use reth_cli_runner::CliRunner;
use reth_db::DatabaseEnv;
use reth_node_builder::{NodeBuilder, WithLaunchContext};
use std::{future::Future, sync::Arc};

/// Entrypoint.
#[derive(Debug, Parser)]
#[command(author, version = SHORT_VERSION, long_version = LONG_VERSION, about = "Reth", long_about = None)]
pub struct Cli {
/// The command to run
#[command(subcommand)]
command: Commands,

/// The chain this node is running.
///
/// Possible values are either a built-in chain or the path to a chain specification file.
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
default_value = SUPPORTED_CHAINS[0],
value_parser = chain_value_parser,
global = true,
)]
chain: Arc<ChainSpec>,

#[command(flatten)]
logs: LogArgs,
}

impl Cli {
pub fn run<L, Fut>(mut self, launcher: L) -> eyre::Result<()>
where
L: FnOnce(WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>>>, NoArgs) -> Fut,
Fut: Future<Output = eyre::Result<()>>,
{
// add network name to logs dir
self.logs.log_file_directory =
self.logs.log_file_directory.join(self.chain.chain.to_string());

let _guard = self.logs.init_tracing()?;
let runner = CliRunner::default();
match self.command {
Commands::Node(command) => {
runner.run_command_until_exit(|ctx| command.execute(ctx, launcher))
}
Commands::Generator(command) => runner.run_command_until_exit(|_| command.execute()),
}
}
}

/// Commands to be executed
#[derive(Debug, Subcommand)]
pub enum Commands {
/// Start the node
#[command(name = "node")]
Node(node::NodeCommand<NoArgs>),
/// Generate stealth addresses, meta addresses and stealth address private keys.
#[command(name = "gen")]
Generator(Box<crate::generator::Command>),
}
Loading