Skip to content

Commit

Permalink
Merge pull request #2 from mayoreee/master
Browse files Browse the repository at this point in the history
dashcore masternode RPC support
  • Loading branch information
QuantumExplorer authored Jul 25, 2022
2 parents 69ac802 + 84445e6 commit 8d3c4f4
Show file tree
Hide file tree
Showing 15 changed files with 303 additions and 254 deletions.
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("localhost:19998".to_string(),
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(
"localhost: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

0 comments on commit 8d3c4f4

Please sign in to comment.