mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 21:49:26 +00:00
Smash out RPC, wallet
This commit is contained in:
@@ -31,7 +31,8 @@ bitcoin-serai = { path = "../../coins/bitcoin" }
|
||||
k256 = "0.13"
|
||||
ethereum-serai = { path = "../../coins/ethereum" }
|
||||
|
||||
monero-serai = { path = "../../coins/monero" }
|
||||
monero-simple-request-rpc = { path = "../../coins/monero/rpc/simple-request" }
|
||||
monero-wallet = { path = "../../coins/monero/wallet" }
|
||||
|
||||
messages = { package = "serai-processor-messages", path = "../../processor/messages" }
|
||||
|
||||
|
||||
@@ -274,11 +274,11 @@ impl Coordinator {
|
||||
}
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
use monero_serai::rpc::HttpRpc;
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
|
||||
// Monero's won't, so call get_height
|
||||
if handle
|
||||
.block_on(HttpRpc::new(rpc_url.clone()))
|
||||
.block_on(SimpleRequestRpc::new(rpc_url.clone()))
|
||||
.ok()
|
||||
.and_then(|rpc| handle.block_on(rpc.get_height()).ok())
|
||||
.is_some()
|
||||
@@ -403,15 +403,13 @@ impl Coordinator {
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
use curve25519_dalek::{constants::ED25519_BASEPOINT_POINT, scalar::Scalar};
|
||||
use monero_serai::{
|
||||
wallet::{
|
||||
ViewPair,
|
||||
address::{Network, AddressSpec},
|
||||
},
|
||||
rpc::HttpRpc,
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{
|
||||
ViewPair,
|
||||
address::{Network, AddressSpec},
|
||||
};
|
||||
|
||||
let rpc = HttpRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
let rpc = SimpleRequestRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
let _: EmptyResponse = rpc
|
||||
.json_rpc_call(
|
||||
"generateblocks",
|
||||
@@ -517,15 +515,18 @@ impl Coordinator {
|
||||
}
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
use monero_serai::rpc::HttpRpc;
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
|
||||
let rpc = HttpRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
let rpc = SimpleRequestRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
let to = rpc.get_height().await.unwrap();
|
||||
for coordinator in others {
|
||||
let other_rpc =
|
||||
HttpRpc::new(network_rpc(coordinator.network, ops, &coordinator.network_handle))
|
||||
.await
|
||||
.expect("couldn't connect to the Monero RPC");
|
||||
let other_rpc = SimpleRequestRpc::new(network_rpc(
|
||||
coordinator.network,
|
||||
ops,
|
||||
&coordinator.network_handle,
|
||||
))
|
||||
.await
|
||||
.expect("couldn't connect to the Monero RPC");
|
||||
|
||||
let from = other_rpc.get_height().await.unwrap();
|
||||
for b in from .. to {
|
||||
@@ -574,10 +575,12 @@ impl Coordinator {
|
||||
let _ = provider.send_raw_transaction(tx).await.unwrap();
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
use monero_serai::{transaction::Transaction, rpc::HttpRpc};
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::monero::transaction::Transaction;
|
||||
|
||||
let rpc =
|
||||
HttpRpc::new(rpc_url).await.expect("couldn't connect to the coordinator's Monero RPC");
|
||||
let rpc = SimpleRequestRpc::new(rpc_url)
|
||||
.await
|
||||
.expect("couldn't connect to the coordinator's Monero RPC");
|
||||
rpc.publish_transaction(&Transaction::read(&mut &*tx).unwrap()).await.unwrap();
|
||||
}
|
||||
NetworkId::Serai => panic!("processor tests broadcasting block to Serai"),
|
||||
@@ -672,10 +675,11 @@ impl Coordinator {
|
||||
None
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
use monero_serai::rpc::HttpRpc;
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
|
||||
let rpc =
|
||||
HttpRpc::new(rpc_url).await.expect("couldn't connect to the coordinator's Monero RPC");
|
||||
let rpc = SimpleRequestRpc::new(rpc_url)
|
||||
.await
|
||||
.expect("couldn't connect to the coordinator's Monero RPC");
|
||||
let mut hash = [0; 32];
|
||||
hash.copy_from_slice(tx);
|
||||
if let Ok(tx) = rpc.get_transaction(hash).await {
|
||||
|
||||
@@ -103,8 +103,8 @@ pub enum Wallet {
|
||||
Monero {
|
||||
handle: String,
|
||||
spend_key: Zeroizing<curve25519_dalek::scalar::Scalar>,
|
||||
view_pair: monero_serai::wallet::ViewPair,
|
||||
inputs: Vec<monero_serai::wallet::ReceivedOutput>,
|
||||
view_pair: monero_wallet::ViewPair,
|
||||
inputs: Vec<monero_wallet::ReceivedOutput>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -189,12 +189,10 @@ impl Wallet {
|
||||
|
||||
NetworkId::Monero => {
|
||||
use curve25519_dalek::{constants::ED25519_BASEPOINT_POINT, scalar::Scalar};
|
||||
use monero_serai::{
|
||||
wallet::{
|
||||
ViewPair, Scanner,
|
||||
address::{Network, AddressSpec},
|
||||
},
|
||||
rpc::HttpRpc,
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{
|
||||
ViewPair, Scanner,
|
||||
address::{Network, AddressSpec},
|
||||
};
|
||||
|
||||
let mut bytes = [0; 64];
|
||||
@@ -206,7 +204,7 @@ impl Wallet {
|
||||
let view_pair =
|
||||
ViewPair::new(ED25519_BASEPOINT_POINT * spend_key, Zeroizing::new(view_key));
|
||||
|
||||
let rpc = HttpRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
let rpc = SimpleRequestRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
|
||||
let height = rpc.get_height().await.unwrap();
|
||||
// Mines 200 blocks so sufficient decoys exist, as only 60 is needed for maturity
|
||||
@@ -436,20 +434,17 @@ impl Wallet {
|
||||
|
||||
Wallet::Monero { handle, ref spend_key, ref view_pair, ref mut inputs } => {
|
||||
use curve25519_dalek::constants::ED25519_BASEPOINT_POINT;
|
||||
use monero_serai::{
|
||||
Protocol,
|
||||
wallet::{
|
||||
address::{Network, AddressType, AddressMeta, Address},
|
||||
SpendableOutput, DecoySelection, Decoys, Change, FeePriority, Scanner,
|
||||
SignableTransaction,
|
||||
},
|
||||
rpc::HttpRpc,
|
||||
io::decompress_point,
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{
|
||||
monero::{Protocol, io::decompress_point},
|
||||
address::{Network, AddressType, AddressMeta, Address},
|
||||
SpendableOutput, DecoySelection, Decoys, Change, FeePriority, Scanner,
|
||||
SignableTransaction,
|
||||
};
|
||||
use processor::{additional_key, networks::Monero};
|
||||
|
||||
let rpc_url = network_rpc(NetworkId::Monero, ops, handle);
|
||||
let rpc = HttpRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
let rpc = SimpleRequestRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
|
||||
// Prepare inputs
|
||||
let outputs = std::mem::take(inputs);
|
||||
@@ -532,7 +527,7 @@ impl Wallet {
|
||||
)
|
||||
.unwrap(),
|
||||
Wallet::Monero { view_pair, .. } => {
|
||||
use monero_serai::wallet::address::{Network, AddressSpec};
|
||||
use monero_wallet::address::{Network, AddressSpec};
|
||||
ExternalAddress::new(
|
||||
networks::monero::Address::new(
|
||||
view_pair.address(Network::Mainnet, AddressSpec::Standard),
|
||||
|
||||
Reference in New Issue
Block a user