Skip to content

Ensure missing return fields from types structs are tested for #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub fn compact_size_decode(slice: &mut &[u8]) -> u64 {
/// backwards compatible so we only provide it not a v0.17 specific type. The `mtype::ScriptPubkey`
/// mirrors this design (but with concrete `rust-bitcoin` types).
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ScriptPubkey {
/// Script assembly.
pub asm: String,
Expand Down Expand Up @@ -218,6 +219,7 @@ impl ScriptPubkey {

/// Data returned by Core for a script signature.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ScriptSig {
/// Assembly representation of the script.
pub asm: String,
Expand Down
33 changes: 33 additions & 0 deletions types/src/model/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ use crate::ScriptPubkey;

/// Models the result of JSON-RPC method `getbestblockhash`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBestBlockHash(pub BlockHash);

/// Models the result of JSON-RPC method `getblock` with verbosity set to 0.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockVerboseZero(pub Block);

/// Models the result of JSON-RPC method `getblock` with verbosity set to 1.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockVerboseOne {
/// The block hash (same as provided) in RPC call.
pub hash: BlockHash,
Expand Down Expand Up @@ -69,6 +72,7 @@ pub struct GetBlockVerboseOne {

/// Models the result of JSON-RPC method `getblockchaininfo`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockchainInfo {
/// Current network name as defined in BIP70 (main, test, signet, regtest).
pub chain: Network,
Expand Down Expand Up @@ -114,6 +118,7 @@ pub struct GetBlockchainInfo {

/// Status of softfork.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Softfork {
/// The [`SoftforkType`]: one of "buried", "bip9".
#[serde(rename = "type")]
Expand Down Expand Up @@ -142,6 +147,7 @@ pub enum SoftforkType {

/// Status of BIP-9 softforks.
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Bip9SoftforkInfo {
/// One of "defined", "started", "locked_in", "active", "failed".
pub status: Bip9SoftforkStatus,
Expand Down Expand Up @@ -176,6 +182,7 @@ pub enum Bip9SoftforkStatus {

/// Statistics for a BIP-9 softfork.
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Bip9SoftforkStatistics {
/// The length in blocks of the BIP9 signalling period.
pub period: u32,
Expand All @@ -191,10 +198,12 @@ pub struct Bip9SoftforkStatistics {

/// Models the result of JSON-RPC method `getblockcount`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockCount(pub u64);

/// Models the result of JSON-RPC method `getblockfilter`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockFilter {
/// The filter data.
pub filter: Vec<u8>,
Expand All @@ -204,14 +213,17 @@ pub struct GetBlockFilter {

/// Models the result of JSON-RPC method `getblockhash`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockHash(pub BlockHash);

/// Models the result of JSON-RPC method `getblockheader`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockHeader(pub block::Header);

/// Models the result of JSON-RPC method `getblockheader`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockHeaderVerbose {
/// the block hash (same as provided).
pub hash: BlockHash,
Expand Down Expand Up @@ -247,6 +259,7 @@ pub struct GetBlockHeaderVerbose {

/// Models the result of JSON-RPC method `getblockstats`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockStats {
/// Average fee in the block.
pub average_fee: Amount,
Expand Down Expand Up @@ -316,10 +329,12 @@ pub struct GetBlockStats {

/// Models the result of JSON-RPC method `getchaintips`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetChainTips(pub Vec<ChainTips>);

/// An individual list item from the result of JSON-RPC method `getchaintips`.
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ChainTips {
/// Height of the chain tip.
pub height: u32,
Expand Down Expand Up @@ -349,6 +364,7 @@ pub enum ChainTipsStatus {

/// Models the result of JSON-RPC method `getchaintxstats`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetChainTxStats {
/// The timestamp for the final block in the window in UNIX format.
pub time: u32,
Expand All @@ -370,30 +386,37 @@ pub struct GetChainTxStats {

/// Models the result of JSON-RPC method `getdifficulty`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetDifficulty(pub f64);

/// Models the result of JSON-RPC method `getmempoolancestors` with verbose set to false.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMempoolAncestors(pub Vec<Txid>);

/// Models the result of JSON-RPC method `getmempoolancestors` with verbose set to true.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMempoolAncestorsVerbose(pub BTreeMap<Txid, MempoolEntry>);

/// Models the result of JSON-RPC method `getmempoolancestors` with verbose set to false.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMempoolDescendants(pub Vec<Txid>);

/// Models the result of JSON-RPC method `getmempooldescendants` with verbose set to true.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMempoolDescendantsVerbose(pub BTreeMap<Txid, MempoolEntry>);

/// Models the result of JSON-RPC method `getmempoolentry`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMempoolEntry(pub MempoolEntry);

/// A relative (ancestor or descendant) transaction of a transaction in the mempool.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct MempoolEntry {
/// Virtual transaction size as defined in BIP 141. v0.19 and later only.
///
Expand Down Expand Up @@ -436,6 +459,7 @@ pub struct MempoolEntry {

/// (No docs in Core v0.17.)
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct MempoolEntryFees {
/// Transaction fee in BTC.
pub base: Amount,
Expand All @@ -449,6 +473,7 @@ pub struct MempoolEntryFees {

/// Models the result of JSON-RPC method `getmempoolinfo` with verbose set to true.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMempoolInfo {
/// True if the mempool is fully loaded. v0.19 and later only.
pub loaded: Option<bool>,
Expand Down Expand Up @@ -482,14 +507,17 @@ pub struct GetMempoolInfo {

/// Models the result of JSON-RPC method `getrawmempool` with verbose set to false.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetRawMempool(pub Vec<Txid>);

/// Models the result of JSON-RPC method `getrawmempool` with verbose set to true.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetRawMempoolVerbose(pub BTreeMap<Txid, MempoolEntry>);

/// Models the result of JSON-RPC method `gettxout`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetTxOut {
/// The hash of the block at the tip of the chain.
pub best_block: BlockHash,
Expand All @@ -507,6 +535,7 @@ pub struct GetTxOut {

/// Models the result of JSON-RPC method `gettxoutsetinfo`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetTxOutSetInfo {
/// The current block height (index).
pub height: u32,
Expand All @@ -533,10 +562,12 @@ pub struct GetTxOutSetInfo {

/// Models the result of JSON-RPC method `verifytxoutproof`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct VerifyTxOutProof(pub Vec<Txid>);

/// Models the result of the JSON-RPC method `getdescriptoractivity`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetDescriptorActivity {
/// A list of activity events related to the descriptors.
pub activity: Vec<ActivityEntry>,
Expand All @@ -553,6 +584,7 @@ pub enum ActivityEntry {

/// Models a 'spend' activity event with strongly typed fields.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct SpendActivity {
/// The total amount of the spent output.
pub amount: Amount,
Expand All @@ -574,6 +606,7 @@ pub struct SpendActivity {

/// Models a 'receive' activity event with strongly typed fields.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ReceiveActivity {
/// The total amount in BTC of the new output, converted to `bitcoin::Amount`.
pub amount: Amount,
Expand Down
2 changes: 2 additions & 0 deletions types/src/model/generating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};

/// Models the result of JSON-RPC method `generate`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Generate(pub Vec<BlockHash>);

impl Generate {
Expand All @@ -22,6 +23,7 @@ impl Generate {

/// Models the result of JSON-RPC method `generatetoaddress`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GenerateToAddress(pub Vec<BlockHash>);

impl GenerateToAddress {
Expand Down
6 changes: 6 additions & 0 deletions types/src/model/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use serde::{Deserialize, Serialize};

/// Models the result of JSON-RPC method `getblocktemplate`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetBlockTemplate {
/// The preferred block version.
pub version: block::Version,
Expand Down Expand Up @@ -73,6 +74,7 @@ pub struct GetBlockTemplate {
///
/// Returned as part of `getblocktemplate`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct BlockTemplateTransaction {
/// The transaction.
pub data: Transaction,
Expand All @@ -99,6 +101,7 @@ pub struct BlockTemplateTransaction {

/// Models the result of JSON-RPC method `getmininginfo`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetMiningInfo {
/// The current block.
pub blocks: u64,
Expand Down Expand Up @@ -131,6 +134,7 @@ pub struct GetMiningInfo {

/// Represents the `next` block information within the GetMiningInfo result.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct NextBlockInfo {
/// The next height.
pub height: u64,
Expand All @@ -144,9 +148,11 @@ pub struct NextBlockInfo {

/// Models the result of JSON-RPC method `getprioritisedtransactions`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetPrioritisedTransactions(pub BTreeMap<Txid, PrioritisedTransaction>);

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PrioritisedTransaction {
/// Transaction fee delta in satoshis.
pub fee_delta: i64,
Expand Down
5 changes: 5 additions & 0 deletions types/src/model/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};

/// Models the result of JSON-RPC method `getnetworkinfo`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetNetworkInfo {
/// The server version.
pub version: usize,
Expand Down Expand Up @@ -48,6 +49,7 @@ pub struct GetNetworkInfo {

/// Part of the result of the JSON-RPC method `getnetworkinfo` (information per network).
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetNetworkInfoNetwork {
/// Network (ipv4, ipv6, onion, i2p, cjdns).
pub name: String,
Expand All @@ -63,6 +65,7 @@ pub struct GetNetworkInfoNetwork {

/// Part of the result of the JSON-RPC method `getnetworkinfo` (local address info).
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetNetworkInfoAddress {
/// Network address.
pub address: String,
Expand All @@ -78,10 +81,12 @@ pub struct GetNetworkInfoAddress {
/// >
/// > Return known addresses which can potentially be used to find new nodes in the network.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct GetNodeAddresses(pub Vec<NodeAddress>);

/// An item from the list returned by the JSON-RPC method `getnodeaddresses`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct NodeAddress {
/// Timestamp in seconds since epoch (Jan 1 1970 GMT) when the node was last seen.
pub time: u64,
Expand Down
Loading