15
15
16
16
#![ crate_name = "bitcoincore_rpc_json" ]
17
17
#![ crate_type = "rlib" ]
18
- #![ allow( deprecated) ] // Because of `GetPeerInfoResultNetwork::Unroutable`.
18
+ #![ allow( deprecated) ] // Because of `GetPeerInfoResultNetwork::Unroutable`.
19
19
20
20
pub extern crate bitcoin;
21
21
#[ allow( unused) ]
@@ -25,13 +25,15 @@ extern crate serde_json;
25
25
26
26
use std:: collections:: HashMap ;
27
27
28
-
29
28
use bitcoin:: address:: NetworkUnchecked ;
30
29
use bitcoin:: block:: Version ;
31
30
use bitcoin:: consensus:: encode;
32
31
use bitcoin:: hashes:: hex:: FromHex ;
33
32
use bitcoin:: hashes:: sha256;
34
- use bitcoin:: { Address , Amount , PrivateKey , PublicKey , SignedAmount , Transaction , ScriptBuf , Script , bip158, bip32, Network } ;
33
+ use bitcoin:: {
34
+ bip158, bip32, Address , Amount , Network , PrivateKey , PublicKey , Script , ScriptBuf ,
35
+ SignedAmount , Transaction ,
36
+ } ;
35
37
use serde:: de:: Error as SerdeError ;
36
38
use serde:: { Deserialize , Serialize } ;
37
39
use std:: fmt;
@@ -1008,8 +1010,8 @@ pub struct GetAddressInfoResult {
1008
1010
#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
1009
1011
#[ serde( untagged) ]
1010
1012
pub enum StringOrStringArray {
1011
- String ( String ) ,
1012
- StringArray ( Vec < String > ) ,
1013
+ String ( String ) ,
1014
+ StringArray ( Vec < String > ) ,
1013
1015
}
1014
1016
1015
1017
/// Models the result of "getblockchaininfo"
@@ -1556,6 +1558,52 @@ pub enum GetBlockTemplateModes {
1556
1558
// side.
1557
1559
}
1558
1560
1561
+ /// Models the result of "getblock "blockhash" [verbosity=3]"
1562
+ #[ derive( Clone , PartialEq , Debug , Deserialize , Serialize ) ]
1563
+ pub struct GetBlockVerboseResult {
1564
+ /// The current block hash
1565
+ pub hash : bitcoin:: BlockHash ,
1566
+ /// The number of confirmations, or -1 if the block is not on the main chain
1567
+ pub confirmations : i64 ,
1568
+ /// The block size
1569
+ pub size : u64 ,
1570
+ /// The block size excluding witness data
1571
+ pub strippedsize : u64 ,
1572
+ /// The block weight as defined in BIP 141
1573
+ pub weight : u64 ,
1574
+ /// The block height or index
1575
+ pub height : u64 ,
1576
+ /// The block version
1577
+ pub version : u32 ,
1578
+ /// The block version formatted in hexadecimal
1579
+ #[ serde( rename = "versionHex" , with = "crate::serde_hex" ) ]
1580
+ pub version_hex : Vec < u8 > ,
1581
+ /// The merkle root
1582
+ pub merkleroot : bitcoin:: hash_types:: TxMerkleNode ,
1583
+ /// The transaction ids
1584
+ pub tx : Vec < GetBlockVerboseTransactionResult > ,
1585
+ /// The block time
1586
+ pub time : usize ,
1587
+ /// The median block time expressed in UNIX epoch time
1588
+ pub mediantime : Option < usize > ,
1589
+ /// The nonce
1590
+ pub nonce : u32 ,
1591
+ /// The bits
1592
+ pub bits : String ,
1593
+ /// The difficulty
1594
+ pub difficulty : f64 ,
1595
+ /// Expected number of hashes required to produce the chain up to this block
1596
+ #[ serde( with = "crate::serde_hex" ) ]
1597
+ pub chainwork : Vec < u8 > ,
1598
+ /// The number of transactions in the block
1599
+ #[ serde( rename = "nTx" ) ]
1600
+ pub n_tx : usize ,
1601
+ /// The hash of the previous block (if available)
1602
+ pub previousblockhash : Option < bitcoin:: BlockHash > ,
1603
+ /// The hash of the next block (if available)
1604
+ pub nextblockhash : Option < bitcoin:: BlockHash > ,
1605
+ }
1606
+
1559
1607
/// Models the result of "getblocktemplate"
1560
1608
#[ derive( Clone , PartialEq , Eq , Debug , Deserialize , Serialize ) ]
1561
1609
pub struct GetBlockTemplateResult {
@@ -1782,6 +1830,28 @@ pub struct DecodeRawTransactionResult {
1782
1830
pub vout : Vec < GetRawTransactionResultVout > ,
1783
1831
}
1784
1832
1833
+ /// Model for Getblock tx verbosity 2
1834
+ #[ derive( Clone , PartialEq , Eq , Debug , Deserialize , Serialize ) ]
1835
+ pub struct GetBlockVerboseTransactionResult {
1836
+ pub txid : bitcoin:: Txid ,
1837
+ pub hash : bitcoin:: Wtxid ,
1838
+ pub size : u32 ,
1839
+ pub vsize : u32 ,
1840
+ pub weight : u32 ,
1841
+ pub version : u32 ,
1842
+ pub locktime : u32 ,
1843
+ pub vin : Vec < GetRawTransactionResultVin > ,
1844
+ pub vout : Vec < GetRawTransactionResultVout > ,
1845
+ #[ serde(
1846
+ default ,
1847
+ with = "bitcoin::amount::serde::as_btc::opt" ,
1848
+ skip_serializing_if = "Option::is_none"
1849
+ ) ]
1850
+ pub fee : Option < Amount > ,
1851
+ #[ serde( default , with = "crate::serde_hex" ) ]
1852
+ pub hex : Vec < u8 > ,
1853
+ }
1854
+
1785
1855
/// Models the result of "getchaintips"
1786
1856
pub type GetChainTipsResult = Vec < GetChainTipsResultTip > ;
1787
1857
@@ -1889,10 +1959,7 @@ pub struct FundRawTransactionOptions {
1889
1959
/// The fee rate to pay per kvB. NB. This field is converted to camelCase
1890
1960
/// when serialized, so it is receeived by fundrawtransaction as `feeRate`,
1891
1961
/// which fee rate per kvB, and *not* `fee_rate`, which is per vB.
1892
- #[ serde(
1893
- with = "bitcoin::amount::serde::as_btc::opt" ,
1894
- skip_serializing_if = "Option::is_none"
1895
- ) ]
1962
+ #[ serde( with = "bitcoin::amount::serde::as_btc::opt" , skip_serializing_if = "Option::is_none" ) ]
1896
1963
pub fee_rate : Option < Amount > ,
1897
1964
#[ serde( skip_serializing_if = "Option::is_none" ) ]
1898
1965
pub subtract_fee_from_outputs : Option < Vec < u32 > > ,
@@ -2192,7 +2259,7 @@ where
2192
2259
2193
2260
/// deserialize_bip70_network deserializes a Bitcoin Core network according to BIP70
2194
2261
/// The accepted input variants are: {"main", "test", "signet", "regtest"}
2195
- fn deserialize_bip70_network < ' de , D > ( deserializer : D ) -> Result < Network , D :: Error >
2262
+ fn deserialize_bip70_network < ' de , D > ( deserializer : D ) -> Result < Network , D :: Error >
2196
2263
where
2197
2264
D : serde:: Deserializer < ' de > ,
2198
2265
{
@@ -2201,8 +2268,12 @@ where
2201
2268
type Value = Network ;
2202
2269
2203
2270
fn visit_str < E : serde:: de:: Error > ( self , s : & str ) -> Result < Self :: Value , E > {
2204
- Network :: from_core_arg ( s)
2205
- . map_err ( |_| E :: invalid_value ( serde:: de:: Unexpected :: Str ( s) , & "bitcoin network encoded as a string" ) )
2271
+ Network :: from_core_arg ( s) . map_err ( |_| {
2272
+ E :: invalid_value (
2273
+ serde:: de:: Unexpected :: Str ( s) ,
2274
+ & "bitcoin network encoded as a string" ,
2275
+ )
2276
+ } )
2206
2277
}
2207
2278
2208
2279
fn expecting ( & self , formatter : & mut fmt:: Formatter ) -> fmt:: Result {
0 commit comments