A Rust library for interacting with the PIVX Core RPC and it defines several data structures.
Block
: Represents a block in a blockchain with various properties such ashash
,confirmations
,height
, and more.FullBlock
: Similar toBlock
but with additional properties likesize
,tx
, andnextblockhash
.Transaction
: Represents a transaction with properties such astxid
,version
,size
,vin
, andvout
.Vin
: Represents an input to a transaction, which can be either aCoinbase
orTx
input.Vout
: Represents an output of a transaction with properties likevalue
andscript_pub_key
.BlockChainInfo
: Contains information about the blockchain such aschain
,blocks
,headers
, and more.ShieldPoolValue
: Represents the value of the shield pool with propertieschainValue
andvalueDelta
.Softfork
: Represents a soft fork with properties likeid
,version
, andreject
.Upgrades
: Contains information about various upgrades with properties likepos
,pos_v2
, and more.Tip
: Represents a tip of the blockchain with properties likeheight
,hash
,branchlen
, andstatus
.MemPoolInfo
: Contains information about the mempool such asloaded
,size
,bytes
, and more.ScriptPubKey
: Represents the script public key with properties likeasm
,hex
, andreq_sigs
.ScriptSig
: Represents the script signature with properties likeasm
andhex
.TxOut
: Represents a transaction output with properties likebestblock
,confirmations
,value
, and more.GetTxOutReply
: Represents the reply from thegettxout
RPC call, which can be eitherNull
orTxOut
.TxOutSetInfo
: Contains information about the transaction output set with properties likeheight
,bestblock
, and more.MemPoolTx
: Represents a transaction in the mempool with properties likesize
,fee
,modifiedfee
, and more.RawMemPool
: Represents the raw mempool response, which can be eitherTrue
orFalse
. (Needs updating)TxInput
: Represents an input to a transaction with properties liketxid
,vout
, andsequence
.TxOutput
: Represents an output of a transaction with properties liketxid
,vout
,script_pub_key
, and more.SignedTx
: Represents a signed transaction with properties likehex
andcomplete
.MasternodeList
: Represents a masternode with properties likerank
,mn_type
,network
, and more.PivxStatus
: Contains various status properties likestaking_status
,staking_enabled
, and more.MasternodeCount
: Contains the count of masternodes with properties liketotal
,stable
,enabled
, and more.GetInfo
: Contains information about the node with properties likeversion
,protocolversion
,services
, and more.BudgetInfo
: Represents budget information with properties likename
,url
,hash
, and more.ColdUtxo
: Represents a cold UTXO with properties liketxid
,txidn
,amount
, and more.ListColdUtxos
: Represents a list of cold UTXOs.
The RPC client module provides functions to interact with a remote RPC server. It allows sending RPC commands and retrieving responses from the server.
- Supports authentication with username and password.
- Handles JSON-RPC requests and responses.
- Provides convenient methods for common RPC commands.
Here's an example of how to use the RPC client module:
use pivx_rpc_rs;
use pivx_rpc_rs::FullBlock;
use pivx_rpc_rs::BitcoinRpcClient;
fn main() {
//Rpc settings
let rpchost = String::from("http://127.0.0.1:51475");
let rpcuser = String::from("rpcuser");
let rpcpass = String::from("rpcpass");
let client = BitcoinRpcClient::new(
rpchost,
Some(rpcuser),
Some(rpcpass),
3,
10,
1000
);
let block_hash = client.getbestblockhash();
let block_info = client.getblock(block_hash.unwrap());
println!("{:#?}",&block_info);
}