diff options
Diffstat (limited to 'btc-wire/src/rpc.rs')
-rw-r--r-- | btc-wire/src/rpc.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/btc-wire/src/rpc.rs b/btc-wire/src/rpc.rs index 1b02aeb..4b7e424 100644 --- a/btc-wire/src/rpc.rs +++ b/btc-wire/src/rpc.rs @@ -7,6 +7,8 @@ //! //! We only parse the thing we actually use, this reduce memory usage and //! make our code more compatible with future deprecation +//! +//! bitcoincore RPC documentation: <https://bitcoincore.org/en/doc/22.0.0/> use bitcoin::{hashes::hex::ToHex, Address, Amount, BlockHash, SignedAmount, Txid}; use serde_json::{json, Value}; @@ -272,7 +274,7 @@ impl BtcRpc { pub fn list_since_block( &mut self, hash: Option<&BlockHash>, - confirmation: u8, + confirmation: u16, include_remove: bool, ) -> Result<ListSinceBlock> { self.call("listsinceblock", &(hash, confirmation, (), include_remove)) @@ -285,6 +287,10 @@ impl BtcRpc { } } + pub fn get_chain_tips(&mut self) -> Result<Vec<ChainTips>> { + self.call("getchaintips", &EMPTY) + } + pub fn get_tx(&mut self, id: &Txid) -> Result<TransactionFull> { self.call("gettransaction", &(id, (), true)) } @@ -400,6 +406,28 @@ pub struct HexWrapper { pub hex: String, } +#[derive(Clone, PartialEq, Eq, serde::Deserialize, Debug)] +pub struct ChainTips { + pub height: u64, + pub hash: bitcoin::BlockHash, + #[serde(rename = "branchlen")] + pub branch_length: usize, + pub status: ChainTipsStatus, +} + +#[derive(Copy, serde::Deserialize, Clone, PartialEq, Eq, Debug)] +#[serde(rename_all = "lowercase")] +pub enum ChainTipsStatus { + Invalid, + #[serde(rename = "headers-only")] + HeadersOnly, + #[serde(rename = "valid-headers")] + ValidHeaders, + #[serde(rename = "valid-fork")] + ValidFork, + Active, +} + #[derive(Debug, serde::Deserialize)] pub struct Nothing {} |