corepc_client/client_sync/v17/
blockchain.rs1#[macro_export]
14macro_rules! impl_client_v17__get_blockchain_info {
15 () => {
16 impl Client {
17 pub fn get_blockchain_info(&self) -> Result<GetBlockchainInfo> {
18 self.call("getblockchaininfo", &[])
19 }
20 }
21 };
22}
23
24#[macro_export]
26macro_rules! impl_client_v17__get_best_block_hash {
27 () => {
28 impl Client {
29 pub fn best_block_hash(&self) -> Result<bitcoin::BlockHash> {
31 let json = self.get_best_block_hash()?;
32 Ok(json.block_hash()?)
33 }
34
35 pub fn get_best_block_hash(&self) -> Result<GetBestBlockHash> {
36 self.call("getbestblockhash", &[])
37 }
38 }
39 };
40}
41
42#[macro_export]
44macro_rules! impl_client_v17__get_block {
45 () => {
46 impl Client {
47 pub fn get_block(&self, hash: BlockHash) -> Result<Block> {
49 let json = self.get_block_verbose_zero(hash)?;
50 Ok(json.block()?)
51 }
52
53 pub fn get_block_verbose_zero(&self, hash: BlockHash) -> Result<GetBlockVerboseZero> {
55 self.call("getblock", &[into_json(hash)?, 0.into()])
56 }
57
58 pub fn get_block_verbose_one(&self, hash: BlockHash) -> Result<GetBlockVerboseOne> {
60 self.call("getblock", &[into_json(hash)?, 1.into()])
61 }
62 }
63 };
64}
65
66#[macro_export]
68macro_rules! impl_client_v17__get_block_count {
69 () => {
70 impl Client {
71 pub fn get_block_count(&self) -> Result<GetBlockCount> {
72 self.call("getblockcount", &[])
73 }
74 }
75 };
76}
77
78#[macro_export]
80macro_rules! impl_client_v17__get_block_hash {
81 () => {
82 impl Client {
83 pub fn get_block_hash(&self, height: u64) -> Result<GetBlockHash> {
84 self.call("getblockhash", &[into_json(height)?])
85 }
86 }
87 };
88}
89
90#[macro_export]
92macro_rules! impl_client_v17__get_block_header {
93 () => {
94 impl Client {
95 pub fn get_block_header(&self, hash: &BlockHash) -> Result<GetBlockHeader> {
96 self.call("getblockheader", &[into_json(hash)?, into_json(false)?])
97 }
98
99 pub fn get_block_header_verbose(
101 &self,
102 hash: &BlockHash,
103 ) -> Result<GetBlockHeaderVerbose> {
104 self.call("getblockheader", &[into_json(hash)?])
105 }
106 }
107 };
108}
109
110#[macro_export]
112macro_rules! impl_client_v17__get_block_stats {
113 () => {
114 impl Client {
115 pub fn get_block_stats_by_height(
116 &self,
117 height: u32,
118 stats: Option<&[&str]>,
119 ) -> Result<GetBlockStats> {
120 self.call("getblockstats", &[into_json(height)?, into_json(stats)?])
121 }
122
123 pub fn get_block_stats_by_block_hash(
124 &self,
125 hash: &BlockHash,
126 stats: Option<&[&str]>,
127 ) -> Result<GetBlockStats> {
128 self.call("getblockstats", &[into_json(hash)?, into_json(stats)?])
129 }
130 }
131 };
132}
133
134#[macro_export]
136macro_rules! impl_client_v17__get_chain_tips {
137 () => {
138 impl Client {
139 pub fn get_chain_tips(&self) -> Result<GetChainTips> { self.call("getchaintips", &[]) }
140 }
141 };
142}
143
144#[macro_export]
146macro_rules! impl_client_v17__get_chain_tx_stats {
147 () => {
148 impl Client {
149 pub fn get_chain_tx_stats(&self) -> Result<GetChainTxStats> {
150 self.call("getchaintxstats", &[])
151 }
152 }
153 };
154}
155
156#[macro_export]
158macro_rules! impl_client_v17__get_difficulty {
159 () => {
160 impl Client {
161 pub fn get_difficulty(&self) -> Result<GetDifficulty> {
162 self.call("getdifficulty", &[])
163 }
164 }
165 };
166}
167
168#[macro_export]
170macro_rules! impl_client_v17__get_mempool_ancestors {
171 () => {
172 impl Client {
173 pub fn get_mempool_ancestors(&self, txid: Txid) -> Result<GetMempoolAncestors> {
174 self.call("getmempoolancestors", &[into_json(txid)?])
176 }
177
178 pub fn get_mempool_ancestors_verbose(
179 &self,
180 txid: Txid,
181 ) -> Result<GetMempoolAncestorsVerbose> {
182 self.call("getmempoolancestors", &[into_json(txid)?, into_json(true)?])
183 }
184 }
185 };
186}
187
188#[macro_export]
190macro_rules! impl_client_v17__get_mempool_descendants {
191 () => {
192 impl Client {
193 pub fn get_mempool_descendants(&self, txid: Txid) -> Result<GetMempoolDescendants> {
194 self.call("getmempooldescendants", &[into_json(txid)?])
196 }
197
198 pub fn get_mempool_descendants_verbose(
199 &self,
200 txid: Txid,
201 ) -> Result<GetMempoolDescendantsVerbose> {
202 self.call("getmempooldescendants", &[into_json(txid)?, into_json(true)?])
203 }
204 }
205 };
206}
207
208#[macro_export]
210macro_rules! impl_client_v17__get_mempool_entry {
211 () => {
212 impl Client {
213 pub fn get_mempool_entry(&self, txid: Txid) -> Result<GetMempoolEntry> {
214 self.call("getmempoolentry", &[into_json(txid)?])
215 }
216 }
217 };
218}
219
220#[macro_export]
222macro_rules! impl_client_v17__get_mempool_info {
223 () => {
224 impl Client {
225 pub fn get_mempool_info(&self) -> Result<GetMempoolInfo> {
226 self.call("getmempoolinfo", &[])
227 }
228 }
229 };
230}
231
232#[macro_export]
234macro_rules! impl_client_v17__get_raw_mempool {
235 () => {
236 impl Client {
237 pub fn get_raw_mempool(&self) -> Result<GetRawMempool> {
238 self.call("getrawmempool", &[])
240 }
241
242 pub fn get_raw_mempool_verbose(&self) -> Result<GetRawMempoolVerbose> {
243 self.call("getrawmempool", &[into_json(true)?])
244 }
245 }
246 };
247}
248
249#[macro_export]
251macro_rules! impl_client_v17__get_tx_out {
252 () => {
253 impl Client {
254 pub fn get_tx_out(&self, txid: Txid, vout: u64) -> Result<GetTxOut> {
255 self.call("gettxout", &[into_json(txid)?, into_json(vout)?])
256 }
257 }
258 };
259}
260
261#[macro_export]
263macro_rules! impl_client_v17__get_tx_out_proof {
264 () => {
265 impl Client {
266 pub fn get_tx_out_proof(&self, txids: &[Txid]) -> Result<String> {
267 self.call("gettxoutproof", &[into_json(txids)?])
268 }
269 }
270 };
271}
272
273#[macro_export]
275macro_rules! impl_client_v17__get_tx_out_set_info {
276 () => {
277 impl Client {
278 pub fn get_tx_out_set_info(&self) -> Result<GetTxOutSetInfo> {
279 self.call("gettxoutsetinfo", &[])
280 }
281 }
282 };
283}
284
285#[macro_export]
287macro_rules! impl_client_v17__precious_block {
288 () => {
289 impl Client {
290 pub fn precious_block(&self, hash: BlockHash) -> Result<()> {
291 match self.call("preciousblock", &[into_json(hash)?]) {
292 Ok(serde_json::Value::Null) => Ok(()),
293 Ok(res) => Err(Error::Returned(res.to_string())),
294 Err(err) => Err(err.into()),
295 }
296 }
297 }
298 };
299}
300
301#[macro_export]
303macro_rules! impl_client_v17__prune_blockchain {
304 () => {
305 impl Client {
306 pub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain> {
308 self.call("pruneblockchain", &[target.into()])
309 }
310 }
311 };
312}
313
314#[macro_export]
316macro_rules! impl_client_v17__save_mempool {
317 () => {
318 impl Client {
319 pub fn save_mempool(&self) -> Result<()> {
320 match self.call("savemempool", &[]) {
321 Ok(serde_json::Value::Null) => Ok(()),
322 Ok(res) => Err(Error::Returned(res.to_string())),
323 Err(err) => Err(err.into()),
324 }
325 }
326 }
327 };
328}
329
330#[macro_export]
332macro_rules! impl_client_v17__scan_tx_out_set {
333 () => {
334 impl Client {
335 pub fn scan_tx_out_set_abort(&self) -> Result<ScanTxOutSetAbort> {
337 self.call("scantxoutset", &[into_json("abort")?])
338 }
339
340 pub fn scan_tx_out_set_start(
342 &self,
343 scan_objects: &[&str],
344 ) -> Result<ScanTxOutSetStart> {
345 self.call("scantxoutset", &[into_json("start")?, into_json(scan_objects)?])
346 }
347
348 pub fn scan_tx_out_set_status(&self) -> Result<Option<ScanTxOutSetStatus>> {
350 self.call("scantxoutset", &[into_json("status")?])
351 }
352 }
353 };
354}
355
356#[macro_export]
358macro_rules! impl_client_v17__verify_chain {
359 () => {
360 impl Client {
361 pub fn verify_chain(&self) -> Result<VerifyChain> { self.call("verifychain", &[]) }
362 }
363 };
364}
365
366#[macro_export]
368macro_rules! impl_client_v17__verify_tx_out_proof {
369 () => {
370 impl Client {
371 pub fn verify_tx_out_proof(&self, proof: &str) -> Result<VerifyTxOutProof> {
373 self.call("verifytxoutproof", &[into_json(proof)?])
374 }
375 }
376 };
377}