|
| 1 | +# pivx-rpc-rs |
| 2 | +A Rust library for interacting with the PIVX Core RPC and it defines several data structures. |
| 3 | + |
| 4 | +## Data Structures |
| 5 | + |
| 6 | +- `Block`: Represents a block in a blockchain with various properties such as `hash`, `confirmations`, `height`, and more. |
| 7 | +- `FullBlock`: Similar to `Block` but with additional properties like `size`, `tx`, and `nextblockhash`. |
| 8 | +- `Transaction`: Represents a transaction with properties such as `txid`, `version`, `size`, `vin`, and `vout`. |
| 9 | +- `Vin`: Represents an input to a transaction, which can be either a `Coinbase` or `Tx` input. |
| 10 | +- `Vout`: Represents an output of a transaction with properties like `value` and `script_pub_key`. |
| 11 | +- `BlockChainInfo`: Contains information about the blockchain such as `chain`, `blocks`, `headers`, and more. |
| 12 | +- `ShieldPoolValue`: Represents the value of the shield pool with properties `chainValue` and `valueDelta`. |
| 13 | +- `Softfork`: Represents a soft fork with properties like `id`, `version`, and `reject`. |
| 14 | +- `Upgrades`: Contains information about various upgrades with properties like `pos`, `pos_v2`, and more. |
| 15 | +- `Tip`: Represents a tip of the blockchain with properties like `height`, `hash`, `branchlen`, and `status`. |
| 16 | +- `MemPoolInfo`: Contains information about the mempool such as `loaded`, `size`, `bytes`, and more. |
| 17 | +- `ScriptPubKey`: Represents the script public key with properties like `asm`, `hex`, and `req_sigs`. |
| 18 | +- `ScriptSig`: Represents the script signature with properties like `asm` and `hex`. |
| 19 | +- `TxOut`: Represents a transaction output with properties like `bestblock`, `confirmations`, `value`, and more. |
| 20 | +- `GetTxOutReply`: Represents the reply from the `gettxout` RPC call, which can be either `Null` or `TxOut`. |
| 21 | +- `TxOutSetInfo`: Contains information about the transaction output set with properties like `height`, `bestblock`, and more. |
| 22 | +- `MemPoolTx`: Represents a transaction in the mempool with properties like `size`, `fee`, `modifiedfee`, and more. |
| 23 | +- `RawMemPool`: Represents the raw mempool response, which can be either `True` or `False`. (Needs updating) |
| 24 | +- `TxInput`: Represents an input to a transaction with properties like `txid`, `vout`, and `sequence`. |
| 25 | +- `TxOutput`: Represents an output of a transaction with properties like `txid`, `vout`, `script_pub_key`, and more. |
| 26 | +- `SignedTx`: Represents a signed transaction with properties like `hex` and `complete`. |
| 27 | +- `MasternodeList`: Represents a masternode with properties like `rank`, `mn_type`, `network`, and more. |
| 28 | +- `PivxStatus`: Contains various status properties like `staking_status`, `staking_enabled`, and more. |
| 29 | +- `MasternodeCount`: Contains the count of masternodes with properties like `total`, `stable`, `enabled`, and more. |
| 30 | +- `GetInfo`: Contains information about the node with properties like `version`, `protocolversion`, `services`, and more. |
| 31 | +- `BudgetInfo`: Represents budget information with properties like `name`, `url`, `hash`, and more. |
| 32 | +- `ColdUtxo`: Represents a cold UTXO with properties like `txid`, `txidn`, `amount`, and more. |
| 33 | +- `ListColdUtxos`: Represents a list of cold UTXOs. |
| 34 | + |
| 35 | +## RPC Client |
| 36 | + |
| 37 | +The RPC client module provides functions to interact with a remote RPC server. It allows sending RPC commands and retrieving responses from the server. |
| 38 | + |
| 39 | +### Features |
| 40 | + |
| 41 | +- Supports authentication with username and password. |
| 42 | +- Handles JSON-RPC requests and responses. |
| 43 | +- Provides convenient methods for common RPC commands. |
| 44 | + |
| 45 | +### Example Usage |
| 46 | + |
| 47 | +Here's an example of how to use the RPC client module: |
| 48 | + |
| 49 | +```rust |
| 50 | +use pivx_rpc_rs; |
| 51 | + |
| 52 | +use pivx_rpc_rs::FullBlock; |
| 53 | +use pivx_rpc_rs::BitcoinRpcClient; |
| 54 | + |
| 55 | +fn main() { |
| 56 | + //Rpc settings |
| 57 | + let rpchost = String::from("http://127.0.0.1:51475"); |
| 58 | + let rpcuser = String::from("rpcuser"); |
| 59 | + let rpcpass = String::from("rpcpass"); |
| 60 | + |
| 61 | + let client = BitcoinRpcClient::new( |
| 62 | + rpchost, |
| 63 | + Some(rpcuser), |
| 64 | + Some(rpcpass), |
| 65 | + 3, |
| 66 | + 10, |
| 67 | + 1000 |
| 68 | + ); |
| 69 | + |
| 70 | + let block_hash = client.getbestblockhash(); |
| 71 | + let block_info = client.getblock(block_hash.unwrap()); |
| 72 | + println!("{:#?}",&block_info); |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | + |
0 commit comments