mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-21 10:14:30 +00:00
use monero_address
This commit is contained in:
parent
13f5ed9dd0
commit
1d3c807b98
4 changed files with 10 additions and 13 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1235,6 +1235,7 @@ dependencies = [
|
||||||
"hex",
|
"hex",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
"monero-address",
|
||||||
"monero-serai",
|
"monero-serai",
|
||||||
"paste",
|
"paste",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
|
|
|
@ -132,6 +132,7 @@ futures = { version = "0.3", default-features = false }
|
||||||
hex = { version = "0.4", default-features = false }
|
hex = { version = "0.4", default-features = false }
|
||||||
hex-literal = { version = "0.4", default-features = false }
|
hex-literal = { version = "0.4", default-features = false }
|
||||||
indexmap = { version = "2", default-features = false }
|
indexmap = { version = "2", default-features = false }
|
||||||
|
monero-address = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce", default-features = false }
|
||||||
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce", default-features = false }
|
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce", default-features = false }
|
||||||
paste = { version = "1", default-features = false }
|
paste = { version = "1", default-features = false }
|
||||||
pin-project = { version = "1", default-features = false }
|
pin-project = { version = "1", default-features = false }
|
||||||
|
|
|
@ -58,6 +58,7 @@ futures = { workspace = true }
|
||||||
hex = { workspace = true }
|
hex = { workspace = true }
|
||||||
hex-literal = { workspace = true }
|
hex-literal = { workspace = true }
|
||||||
indexmap = { workspace = true }
|
indexmap = { workspace = true }
|
||||||
|
monero-address = { workspace = true }
|
||||||
monero-serai = { workspace = true }
|
monero-serai = { workspace = true }
|
||||||
paste = { workspace = true }
|
paste = { workspace = true }
|
||||||
pin-project = { workspace = true }
|
pin-project = { workspace = true }
|
||||||
|
|
|
@ -147,22 +147,16 @@ async fn get_block_template(
|
||||||
return Err(anyhow!("Too big extra_nonce size"));
|
return Err(anyhow!("Too big extra_nonce size"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is hardcoded for the current address scheme + mainnet,
|
// TODO: This should be `cuprated`'s active network.
|
||||||
// create/use a more well-defined wallet lib.
|
let network = match Network::Mainnet {
|
||||||
let parse_wallet_address = || {
|
Network::Mainnet => monero_address::Network::Mainnet,
|
||||||
if request.wallet_address.len() == 95 {
|
Network::Stagenet => monero_address::Network::Stagenet,
|
||||||
Ok(())
|
Network::Testnet => monero_address::Network::Testnet,
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let is_correct_address_type = || !request.wallet_address.starts_with("4");
|
|
||||||
|
|
||||||
if parse_wallet_address().is_err() {
|
let address = monero_address::MoneroAddress::from_str(network, &request.wallet_address)?;
|
||||||
return Err(anyhow!("Failed to parse wallet address"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_correct_address_type() {
|
if *address.kind() != monero_address::AddressType::Legacy {
|
||||||
return Err(anyhow!("Incorrect address type"));
|
return Err(anyhow!("Incorrect address type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue