This commit is contained in:
victor 2025-09-08 15:17:03 +02:00
parent 1e002897c5
commit ffeb300e9e
12 changed files with 6573 additions and 302 deletions

5476
native_client/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

8
native_client/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "native_client"
version = "0.1.0"
edition = "2024"
[dependencies]
tauri = "=2.0.0-alpha.4"
tauri-egui = "0.3.0"

View File

@ -0,0 +1,5 @@
use tauri_egui;
fn main() {
println!("Hello, world!");
}

1035
node/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -30,4 +30,5 @@ futures = "0.3.31"
secp256k1 = { version = "0.31.1", features = ["hashes", "rand", "recovery", "serde"] } secp256k1 = { version = "0.31.1", features = ["hashes", "rand", "recovery", "serde"] }
ring = "0.17.14" ring = "0.17.14"
shared = { path = "../shared", features = ["node"] } shared = { path = "../shared", features = ["node"] }
wallet = { path = "../wallet" }
cli-renderer = { path = "../cli-renderer" } cli-renderer = { path = "../cli-renderer" }

View File

@ -9,7 +9,7 @@ use crate::{
log, log,
}; };
use shared::core::print_error_chain; use shared::print_error_chain;
static BINCODE_CONFIG: Configuration = bincode::config::standard(); static BINCODE_CONFIG: Configuration = bincode::config::standard();
@ -17,57 +17,29 @@ const DB_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/database");
const DB_TREE: &str = "blocks"; const DB_TREE: &str = "blocks";
const BLOCK_PREFIX: &str = "blocks"; const BLOCK_PREFIX: [u8; 7] = *b"blocks:";
const CHAIN_DATA_PREFIX: &str = "chain_data"; const CHAIN_DATA_PREFIX: [u8; 11] = *b"chain_data:";
const DATA_TO_BLOCK_PREFIX: &str = "data_to_block"; const DATA_TO_BLOCK_PREFIX: [u8; 14] = *b"data_to_block:";
const METADATA_PREFIX: &str = "metadata"; const METADATA_PREFIX: [u8; 9] = *b"metadata:";
const BALANCE_PREFIX: &str = "balance"; const BALANCE_PREFIX: [u8; 8] = *b"balance:";
const NONCE_PREFIX: [u8; 6] = *b"nonce:";
const MEMPOOL_PREFIX: &str = "mempool"; const MEMPOOL_PREFIX: [u8; 8] = *b"mempool:";
const TIP_KEY: &str = "chain_tip"; const TIP_KEY: [u8; 10] = *b"chain_tip:";
const HEIGHT_KEY: &str = "chain_height"; const HEIGHT_KEY: [u8; 13] = *b"chain_height:";
const HEIGHT_TO_HASH_PREFIX: &str = "height_to_hash"; const HEIGHT_TO_HASH_PREFIX: [u8; 15] = *b"height_to_hash:";
#[derive(Debug)] #[derive(Debug)]
pub struct ChainDb { pub struct ChainDb {
db: sled::Tree, db: sled::Tree,
} }
fn data_prefix(key: &str) -> String { fn prefix(prefix: &[u8], key: &[u8]) -> Vec<u8> {
format!("{}:{}", CHAIN_DATA_PREFIX, key) let mut bytes = Vec::with_capacity(prefix.len() + key.len());
} bytes.extend_from_slice(prefix);
bytes.extend_from_slice(key);
fn data_to_block_prefix(key: &str) -> String { bytes
format!("{}:{}", DATA_TO_BLOCK_PREFIX, key)
}
fn block_prefix(key: &str) -> String {
format!("{}:{}", BLOCK_PREFIX, key)
}
fn metadata_prefix(key: &str) -> String {
format!("{}:{}", METADATA_PREFIX, key)
}
fn height_to_hash_prefix(height: u64) -> String {
format!("{}:{:020}", HEIGHT_TO_HASH_PREFIX, height)
}
fn balances_prefix(address: &str) -> String {
format!("{}:{}", BALANCE_PREFIX, address)
}
fn nonce_prefix(address: &str) -> String {
format!("{}:{}", ACCOUNT_PREFIX, address)
}
fn mempool_prefix(tx_hash: &str) -> String {
format!("{}:{}", MEMPOOL_PREFIX, tx_hash)
}
fn account_prefix(addr: &str) -> String {
format!("{}:{}", ACCOUNT_PREFIX, addr)
} }
impl ChainDb { impl ChainDb {
@ -103,29 +75,6 @@ impl ChainDb {
} }
} }
pub fn get_account(&self, addr: &Address) -> Result<Option<Account>, DatabaseError> {
if let Some(bin_acc) = self.db.get(account_prefix(addr))? {
let (acc, _) = bincode::decode_from_slice::<Account, _>(&bin_acc, BINCODE_CONFIG)?;
Ok(Some(acc))
} else {
Ok(None)
}
}
fn insert_account(&self, acc: &Account) -> Result<(), DatabaseError> {
let mut batch = Batch::default();
if let Some(_) = self.get_account(acc.address())? {
return Err(DatabaseError::AccountExists(acc.address().to_string()));
}
let bin_acc = bincode::encode_to_vec(acc, BINCODE_CONFIG)?;
let bin_nonce = bincode::encode_to_vec(&acc.nonce(), BINCODE_CONFIG)?;
let bin_balance = bincode::encode_to_vec(&acc.balance(), BINCODE_CONFIG)?;
batch.insert(account_prefix(acc.address()).as_str(), bin_acc);
batch.insert(nonce_prefix(acc.address()).as_str(), bin_nonce);
batch.insert(balances_prefix(acc.address()).as_str(), bin_balance);
Ok(self.db.apply_batch(batch)?)
}
pub fn recover_mempool(&self) -> Result<Vec<ChainData>, DatabaseError> { pub fn recover_mempool(&self) -> Result<Vec<ChainData>, DatabaseError> {
let mem_tree = self.db.scan_prefix(MEMPOOL_PREFIX); let mem_tree = self.db.scan_prefix(MEMPOOL_PREFIX);
let mut mem_vec = vec![]; let mut mem_vec = vec![];
@ -145,8 +94,8 @@ impl ChainDb {
for mem in mempool { for mem in mempool {
let data_hash = Hasher::hash_chain_data(&mem); let data_hash = Hasher::hash_chain_data(&mem);
let bin_data = bincode::encode_to_vec(&mem, BINCODE_CONFIG)?; let bin_data = bincode::encode_to_vec(&mem, BINCODE_CONFIG)?;
let key = mempool_prefix(&data_hash); let key = prefix(&MEMPOOL_PREFIX, &data_hash);
batch.insert(key.as_str(), bin_data); batch.insert(key, bin_data);
} }
self.db.apply_batch(batch)?; self.db.apply_batch(batch)?;
Ok(()) Ok(())
@ -156,40 +105,26 @@ impl ChainDb {
Ok(self.db.flush_async().await?) Ok(self.db.flush_async().await?)
} }
pub fn add_balance(&self, address: &Address, new_balance: u64) -> Result<(), DatabaseError> {
let new_balance = if let Some(old_balance) = self.get_balance(address)? {
old_balance + new_balance
} else {
new_balance
};
Ok(self.set_balance(address, new_balance)?)
}
pub fn set_balance(&self, address: &Address, new_balance: u64) -> Result<(), DatabaseError> { pub fn set_balance(&self, address: &Address, new_balance: u64) -> Result<(), DatabaseError> {
let mut batch = Batch::default();
let account_nonce = self.get_nonce(address)?;
let account_nonce = account_nonce + 1;
let bin_balance = bincode::encode_to_vec(new_balance, BINCODE_CONFIG)?; let bin_balance = bincode::encode_to_vec(new_balance, BINCODE_CONFIG)?;
let bin_nonce = bincode::encode_to_vec(account_nonce, BINCODE_CONFIG)?; self.db.insert(prefix(&BALANCE_PREFIX, address), bin_balance)?;
batch.insert(balances_prefix(address).as_str(), bin_balance); Ok(())
batch.insert(nonce_prefix(address).as_str(), bin_nonce);
Ok(self.db.apply_batch(batch)?)
} }
fn set_nonce(&self, address: &Address, nonce: u64) -> Result<(), DatabaseError> { fn set_nonce(&self, address: &Address, nonce: u64) -> Result<(), DatabaseError> {
let bin_nonce = bincode::encode_to_vec(&nonce, BINCODE_CONFIG)?; let bin_nonce = bincode::encode_to_vec(&nonce, BINCODE_CONFIG)?;
let address = nonce_prefix(address); let address = prefix(&NONCE_PREFIX, address);
self.db.insert(address, bin_nonce)?; self.db.insert(address, bin_nonce)?;
Ok(()) Ok(())
} }
fn get_nonce(&self, address: &Address) -> Result<u64, DatabaseError> { fn get_nonce(&self, address: &Address) -> Result<Option<u64>, DatabaseError> {
match self.db.get(nonce_prefix(address))? { match self.db.get(prefix(&NONCE_PREFIX, address))? {
Some(n) => { Some(n) => {
let (nonce, _) = bincode::decode_from_slice::<u64, _>(&n, BINCODE_CONFIG)?; let (nonce, _) = bincode::decode_from_slice::<u64, _>(&n, BINCODE_CONFIG)?;
Ok(nonce) Ok(Some(nonce))
}, },
None => Err(DatabaseError::AccountNotFound(address.to_string())) None => Ok(None)
} }
} }
@ -197,19 +132,15 @@ impl ChainDb {
let mut batch = Batch::default(); let mut batch = Batch::default();
for (address, amount) in changes { for (address, amount) in changes {
let account_nonce = self.get_nonce(address)?; let balance_key = prefix(&BALANCE_PREFIX, address);
let account_nonce = account_nonce + 1;
let balance_key = balances_prefix(&address);
let bin_amount = bincode::encode_to_vec(amount, BINCODE_CONFIG)?; let bin_amount = bincode::encode_to_vec(amount, BINCODE_CONFIG)?;
let bin_nonce = bincode::encode_to_vec(&account_nonce, BINCODE_CONFIG)?; batch.insert(balance_key, bin_amount);
batch.insert(nonce_prefix(address).as_str(), bin_nonce);
batch.insert(balance_key.as_str(), bin_amount);
} }
Ok(self.db.apply_batch(batch)?) Ok(self.db.apply_batch(batch)?)
} }
pub fn get_balance(&self, address: &Address) -> Result<Option<u64>, DatabaseError> { pub fn get_balance(&self, address: &Address) -> Result<Option<u64>, DatabaseError> {
match self.db.get(balances_prefix(address))? { match self.db.get(prefix(&BALANCE_PREFIX, address))? {
Some(b) => { Some(b) => {
let (balance, _) = bincode::decode_from_slice::<u64, _>(&b, BINCODE_CONFIG)?; let (balance, _) = bincode::decode_from_slice::<u64, _>(&b, BINCODE_CONFIG)?;
Ok(Some(balance)) Ok(Some(balance))
@ -219,7 +150,7 @@ impl ChainDb {
} }
pub fn get_block_by_key(&self, block_hash: &str) -> Result<Option<Arc<core::Block>>, DatabaseError> { pub fn get_block_by_key(&self, block_hash: &str) -> Result<Option<Arc<core::Block>>, DatabaseError> {
let block_hash = block_prefix(block_hash); let block_hash = prefix(&BLOCK_PREFIX, block_hash.as_bytes());
if let Some(bin_block) = self.db.get(block_hash)? { if let Some(bin_block) = self.db.get(block_hash)? {
let (block, _size) = bincode::decode_from_slice::<core::Block, _>(&bin_block, BINCODE_CONFIG) let (block, _size) = bincode::decode_from_slice::<core::Block, _>(&bin_block, BINCODE_CONFIG)
.map_err(|e| DatabaseError::Decode(e))?; .map_err(|e| DatabaseError::Decode(e))?;
@ -233,7 +164,7 @@ impl ChainDb {
&self, &self,
height: u64, height: u64,
) -> Result<Option<Arc<core::Block>>, DatabaseError> { ) -> Result<Option<Arc<core::Block>>, DatabaseError> {
if let Some(hash) = self.db.get(height_to_hash_prefix(height))? { if let Some(hash) = self.db.get(prefix(&HEIGHT_TO_HASH_PREFIX, &height.to_be_bytes()))? {
let (hash_str, _) = bincode::decode_from_slice::<String, _>(&hash, BINCODE_CONFIG)?; let (hash_str, _) = bincode::decode_from_slice::<String, _>(&hash, BINCODE_CONFIG)?;
Ok(self.get_block_by_key(&hash_str)?) Ok(self.get_block_by_key(&hash_str)?)
} else { } else {
@ -245,12 +176,12 @@ impl ChainDb {
let mut chain_data = Vec::new(); let mut chain_data = Vec::new();
for data_hash in &block.data { for data_hash in &block.data {
let data_hash = data_prefix(data_hash); let data_hash = prefix(&CHAIN_DATA_PREFIX, data_hash.as_bytes());
if let Some(bin_data) = self.db.get(&data_hash)? { if let Some(bin_data) = self.db.get(&data_hash)? {
let (data, _) = bincode::decode_from_slice::<ChainData, _>(&bin_data, BINCODE_CONFIG)?; let (data, _) = bincode::decode_from_slice::<ChainData, _>(&bin_data, BINCODE_CONFIG)?;
chain_data.push(data); chain_data.push(data);
} else { } else {
return Err(DatabaseError::MissingData(data_hash.clone())); return Err(DatabaseError::MissingData(hex::encode(data_hash.clone())));
} }
} }
@ -272,7 +203,7 @@ impl ChainDb {
pub fn add_data(&self, data: &core::ChainData) -> Result<(), DatabaseError> { pub fn add_data(&self, data: &core::ChainData) -> Result<(), DatabaseError> {
let bin_data = bincode::encode_to_vec(data, BINCODE_CONFIG)?; let bin_data = bincode::encode_to_vec(data, BINCODE_CONFIG)?;
let data_hash = data_prefix(&Hasher::hash_chain_data(data)); let data_hash = prefix(&CHAIN_DATA_PREFIX, &Hasher::hash_chain_data(data));
self.db.insert(data_hash, bin_data)?; self.db.insert(data_hash, bin_data)?;
Ok(()) Ok(())
} }
@ -280,21 +211,21 @@ impl ChainDb {
pub fn add_block(&self, block: &core::Block) -> Result<(), DatabaseError> { pub fn add_block(&self, block: &core::Block) -> Result<(), DatabaseError> {
let mut db_batch = Batch::default(); let mut db_batch = Batch::default();
let bin_block = bincode::encode_to_vec(block, BINCODE_CONFIG)?; let bin_block = bincode::encode_to_vec(block, BINCODE_CONFIG)?;
db_batch.insert(block_prefix(block.head().block_hash()).as_str(), bin_block); db_batch.insert(prefix(&BLOCK_PREFIX, block.head().block_hash().as_bytes()), bin_block);
db_batch.insert( db_batch.insert(
height_to_hash_prefix(block.head().height).as_str(), prefix(&HEIGHT_TO_HASH_PREFIX, &block.head().height.to_be_bytes()),
block.head().block_hash(), block.head().block_hash(),
); );
for data in block.data() { for data in block.data() {
db_batch.insert( db_batch.insert(
data_to_block_prefix(data.as_str()).as_str(), prefix(&DATA_TO_BLOCK_PREFIX, data.as_bytes()),
block.head().block_hash(), block.head().block_hash(),
); );
} }
db_batch.insert(metadata_prefix(TIP_KEY).as_str(), block.head().block_hash()); db_batch.insert(prefix(&METADATA_PREFIX, &TIP_KEY), block.head().block_hash());
let bin_head = bincode::encode_to_vec(&block.head().height, BINCODE_CONFIG)?; let bin_head = bincode::encode_to_vec(&block.head().height, BINCODE_CONFIG)?;
db_batch.insert( db_batch.insert(
metadata_prefix(HEIGHT_KEY).as_str(), prefix(&METADATA_PREFIX, &HEIGHT_KEY),
bin_head bin_head
); );
self.db.apply_batch(db_batch)?; self.db.apply_batch(db_batch)?;

View File

@ -18,4 +18,6 @@ pub enum DatabaseError {
AccountNotFound(String), AccountNotFound(String),
#[error("Database corruption detected: {0}")] #[error("Database corruption detected: {0}")]
Corruption(String), Corruption(String),
#[error("Hex Decode error: {0}")]
Hex(#[from] hex::FromHexError),
} }

185
shared/Cargo.lock generated
View File

@ -58,12 +58,6 @@ version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]] [[package]]
name = "bincode" name = "bincode"
version = "2.0.1" version = "2.0.1"
@ -84,22 +78,6 @@ dependencies = [
"virtue", "virtue",
] ]
[[package]]
name = "bitcoin-io"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf"
[[package]]
name = "bitcoin_hashes"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
dependencies = [
"bitcoin-io",
"hex-conservative",
]
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.10.4" version = "0.10.4"
@ -109,16 +87,6 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "cc"
version = "1.2.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "590f9024a68a8c40351881787f1934dc11afd69090f5edb6831464694d836ea3"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.3" version = "1.0.3"
@ -200,12 +168,6 @@ dependencies = [
"crypto-common", "crypto-common",
] ]
[[package]]
name = "find-msvc-tools"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e178e4fba8a2726903f6ba98a6d221e76f9c12c650d5dc0e6afdc50677b49650"
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.7" version = "0.14.7"
@ -216,18 +178,6 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "getrandom"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasi",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.5.0" version = "0.5.0"
@ -240,15 +190,6 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hex-conservative"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
dependencies = [
"arrayvec",
]
[[package]] [[package]]
name = "is_terminal_polyfill" name = "is_terminal_polyfill"
version = "1.70.1" version = "1.70.1"
@ -261,6 +202,15 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "keccak"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
dependencies = [
"cpufeatures",
]
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.175" version = "0.2.175"
@ -279,15 +229,6 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.101" version = "1.0.101"
@ -306,67 +247,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rand"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.20" version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "secp256k1"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2"
dependencies = [
"bitcoin_hashes",
"rand",
"secp256k1-sys",
]
[[package]]
name = "secp256k1-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.219" version = "1.0.219"
@ -410,6 +296,16 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "sha3"
version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
dependencies = [
"digest",
"keccak",
]
[[package]] [[package]]
name = "shared" name = "shared"
version = "0.1.0" version = "0.1.0"
@ -418,19 +314,13 @@ dependencies = [
"bincode", "bincode",
"clap", "clap",
"hex", "hex",
"secp256k1",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
"sha3",
"thiserror", "thiserror",
] ]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.11.1" version = "0.11.1"
@ -504,15 +394,6 @@ version = "0.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
[[package]]
name = "wasi"
version = "0.14.3+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95"
dependencies = [
"wit-bindgen",
]
[[package]] [[package]]
name = "windows-link" name = "windows-link"
version = "0.1.3" version = "0.1.3"
@ -592,29 +473,3 @@ name = "windows_x86_64_msvc"
version = "0.53.0" version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
[[package]]
name = "wit-bindgen"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814"
[[package]]
name = "zerocopy"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View File

@ -13,9 +13,10 @@ full = ["node", "client"]
anyhow = "1.0.99" anyhow = "1.0.99"
bincode = "2.0.1" bincode = "2.0.1"
clap = { version = "4.5.47", features = ["derive"] } clap = { version = "4.5.47", features = ["derive"] }
# getrandom = { version = "0.3.3", features = ["wasm_js"] }
hex = "0.4.3" hex = "0.4.3"
secp256k1 = { version = "0.31.1", features = ["rand"] }
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.143" serde_json = "1.0.143"
sha2 = "0.10.9" sha2 = "0.10.9"
sha3 = "0.10.8"
thiserror = "2.0.16" thiserror = "2.0.16"

View File

@ -1,5 +1,6 @@
use sha2::Digest; use sha2::Digest;
use sha2::Sha256; use sha2::Sha256;
use sha3::Keccak256;
use super::{BlockHeader, ChainData}; use super::{BlockHeader, ChainData};
@ -7,7 +8,7 @@ pub struct Hasher {}
impl Hasher { impl Hasher {
pub fn hash_chain_data(data: &ChainData) -> [u8; 32] { pub fn hash_chain_data(data: &ChainData) -> [u8; 32] {
let mut hasher = Sha256::new(); let mut hasher = Keccak256::new();
match data { match data {
ChainData::Transaction(tx) => { ChainData::Transaction(tx) => {
hasher.update(tx.to()); hasher.update(tx.to());

View File

@ -2,14 +2,6 @@ use super::Address;
use thiserror::Error; use thiserror::Error;
//use secp256k1::{
// ecdsa::{RecoveryId, Signature},
// Message, PublicKey, Secp256k1, SecretKey,
//};
//
//use ring::digest;
//
#[derive(Clone)] #[derive(Clone)]
pub struct AddressParser {} pub struct AddressParser {}

View File

@ -17,7 +17,7 @@ thiserror = "2.0.16"
# Native-only dependencies # Native-only dependencies
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
age = { version = "0.11.1", features = ["cli-common"] } age = { version = "0.11.1", features = ["cli-common"] }
k256 = { version = "0.13.4", features = ["ecdsa", "sha256"] } k256 = { version = "0.13.4", features = ["ecdsa"] }
# WASM-only dependencies # WASM-only dependencies
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]