-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Communicate with monero node over proxy
- Loading branch information
Showing
9 changed files
with
636 additions
and
211 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2024. The Tari Project | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
// following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
// disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the | ||
// following disclaimer in the documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
// products derived from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("Config error: {0}")] | ||
Config(#[from] ConfigError), | ||
#[error("Common config error: {0}")] | ||
CommonConfig(#[from] tari_common::configuration::error::ConfigError), | ||
#[error("Reqwest error: {0}")] | ||
Reqwest(#[from] reqwest::Error), | ||
#[error("General error: {0}")] | ||
General(String), | ||
#[error("Request error: {0}")] | ||
Request(#[from] RequestError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum ConfigError { | ||
#[error("Missing base node or proxy address")] | ||
MissingBaseNode, | ||
#[error("Missing monero wallet address")] | ||
MissingMoneroWalletAddress, | ||
#[error("Common config error: {0}")] | ||
CommonConfig(#[from] tari_common::configuration::error::ConfigError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum RequestError { | ||
#[error("Failed to process request `get_block_count`: {0}")] | ||
GetBlockCount(String), | ||
#[error("Failed to process request `get_block_template`: {0}")] | ||
GetBlockTemplate(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2024. The Tari Project | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
// following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
// disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the | ||
// following disclaimer in the documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
// products derived from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize)] | ||
pub struct Request<'a> { | ||
jsonrpc: &'a str, | ||
id: &'a str, | ||
method: &'a str, | ||
params: serde_json::Value, | ||
} | ||
|
||
impl Request<'_> { | ||
pub fn new(method: &str, params: serde_json::Value) -> Request { | ||
Request { | ||
jsonrpc: "2.0", | ||
id: "0", | ||
method, | ||
params, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct GetBlockCountResponse { | ||
jsonrpc: String, | ||
id: String, | ||
pub result: GetBlockCountResult, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct GetBlockCountResult { | ||
pub count: u64, | ||
pub status: String, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct GetBlockTemplateResponse { | ||
jsonrpc: String, | ||
id: String, | ||
pub result: GetBlockTemplateResult, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct GetBlockTemplateResult { | ||
pub blocktemplate_blob: String, | ||
pub blockhashing_blob: String, | ||
pub difficulty: u64, | ||
pub height: u64, | ||
pub prev_hash: String, | ||
pub reserved_offset: u64, | ||
pub status: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.