Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashcore masternode RPC support #2

Merged
merged 9 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use dashcore_rpc::{Auth, Client, RpcApi};

fn main() {

let rpc = Client::new("http://localhost:8332".to_string(),
let rpc = Client::new(&"http://127.0.0.1:19998".to_string(),
mayoreee marked this conversation as resolved.
Show resolved Hide resolved
Auth::UserPass("<FILL RPC USERNAME>".to_string(),
"<FILL RPC PASSWORD>".to_string())).unwrap();
let best_block_hash = rpc.get_best_block_hash().unwrap();
Expand Down
14 changes: 7 additions & 7 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[package]
name = "bitcoincore-rpc"
name = "dashcore-rpc"
version = "0.15.0"
authors = [
"Steven Roose <steven@stevenroose.org>",
"Jean Pierre Dudey <jeandudey@hotmail.com>",
"Dawid Ciężarkiewicz <dpc@dpc.pw>",
]
license = "CC0-1.0"
homepage = "https://github.com/rust-bitcoin/rust-bitcoincore-rpc/"
repository = "https://github.com/rust-bitcoin/rust-bitcoincore-rpc/"
description = "RPC client library for the Bitcoin Core JSON-RPC API."
keywords = ["crypto", "bitcoin", "bitcoin-core", "rpc"]
homepage = "https://github.com/dashevo/rust-dashcore/"
repository = "https://github.com/dashevo/rust-dashcore/"
description = "RPC client library for the Dash Core JSON-RPC API."
keywords = ["crypto", "dash", "dash-core", "rpc"]
readme = "README.md"

[lib]
name = "bitcoincore_rpc"
name = "dashcore_rpc"
path = "src/lib.rs"

[dependencies]
bitcoincore-rpc-json = { version = "0.15.0", path = "../json" }
dashcore-rpc-json = { version = "0.15.0", path = "../json" }

log = "0.4.5"
jsonrpc = "0.12.0"
Expand Down
6 changes: 3 additions & 3 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
bitcoincore-rpc
dashcore-rpc
===============

Rust client library for the Bitcoin Core daemon's JSON-RPC API.
Rust client library for the Dash Core daemon's JSON-RPC API.

Separate `bitcoincore-rpc-json` crate with the JSON-enabled data types used
Separate `dashcore-rpc-json` crate with the JSON-enabled data types used
in the interface of this crate.


Expand Down
31 changes: 31 additions & 0 deletions client/examples/connect_to_masternode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extern crate dashcore_rpc;

use dashcore_rpc::{Auth, Client, RpcApi};

fn main() {
let rpc = Client::new(
&"http://127.0.0.1:19998".to_string(),
Auth::UserPass("dashrpc".to_string(), "rpcpassword".to_string()),
)
.unwrap();

// Get Dash network info
let network_info = rpc.get_network_info().unwrap();
println!("\nDash network info: \n{:?}", network_info);

// Get best block hash
let best_block_hash = rpc.get_best_block_hash().unwrap();
println!("\n\nBest block hash: \n{}", best_block_hash);

// Get block count
let block_count = rpc.get_block_count().unwrap();
println!("\n\nBlock count: \n{}", block_count);

// Get block hash (for the a specified block height)
let block_hash = rpc.get_block_hash(block_count).unwrap();
println!("\n\nBlock hash at block height \n{}: {}", block_count, block_hash);

// Get masternode count
let masternode_count = rpc.get_masternode_count().unwrap();
println!("\n\nMasternode Count: \n{:?}", masternode_count);
}
4 changes: 2 additions & 2 deletions client/examples/retry_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
//

extern crate bitcoincore_rpc;
extern crate dashcore_rpc;
extern crate jsonrpc;
extern crate serde;
extern crate serde_json;

use bitcoincore_rpc::{Client, Error, Result, RpcApi};
use dashcore_rpc::{Client, Error, Result, RpcApi};

pub struct RetryClient {
client: Client,
Expand Down
12 changes: 6 additions & 6 deletions client/examples/test_against_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

//! A very simple example used as a self-test of this library against a Bitcoin
//! Core node.
extern crate bitcoincore_rpc;
extern crate dashcore_rpc;

use bitcoincore_rpc::{bitcoin, Auth, Client, Error, RpcApi};
use dashcore_rpc::{dashcore, Auth, Client, Error, RpcApi};

fn main_result() -> Result<(), Error> {
let mut args = std::env::args();
Expand All @@ -35,10 +35,10 @@ fn main_result() -> Result<(), Error> {
println!("best block hash by height: {}", best_block_hash_by_height);
assert_eq!(best_block_hash_by_height, best_block_hash);

let bitcoin_block: bitcoin::Block = rpc.get_by_id(&best_block_hash)?;
println!("best block hash by `get`: {}", bitcoin_block.header.prev_blockhash);
let bitcoin_tx: bitcoin::Transaction = rpc.get_by_id(&bitcoin_block.txdata[0].txid())?;
println!("tx by `get`: {}", bitcoin_tx.txid());
let dashcore_block: dashcore::Block = rpc.get_by_id(&best_block_hash)?;
println!("best block hash by `get`: {}", dashcore_block.header.prev_blockhash);
let dashcore_tx: dashcore::Transaction = rpc.get_by_id(&dashcore_block.txdata[0].txid())?;
println!("tx by `get`: {}", dashcore_tx.txid());

Ok(())
}
Expand Down
Loading