Skip to content

Commit 3a9c52a

Browse files
committed
Merge #367: Add a feature for serde deny unknown fields
14c3dd6 Feature gate serde(deny_unknown_fields) (Jamil Lambert, PhD) ba366fd Add a feature for serde deny unknown fields (Jamil Lambert, PhD) 2406d12 Remove serde deny_unknown_fields from client (Jamil Lambert, PhD) ced1f4f Use relative path dependencies for corepc crates (Jamil Lambert, PhD) f8fa8d6 Reorder dependencies in Cargo.toml files (Jamil Lambert, PhD) Pull request description: Currently there is no way to turn off the deny unknown fields attribute. This can cause issues when using the crate in cases where there are fields returned by the RPC that are not yet in the types structs, e.g. in unmerged Core PRs (see #366). - Reorder the dependencies in the `Cargo.toml` files to make checking for consistency across the crates easier. - Use relative paths for the `corepc` crates dependencies. - Remove one case of `#[serde(deny_unknown_fields)]` in `client` that is not needed. - Add a feature that can be used to enable the attribute, which is off by default since it is only needed in testing. Enable the feature in `integration_test` by adding a `types` dependency. - Search and replace all occurrences of `#[serde(deny_unknown_fields)]` with `#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]` Closes #366 ACKs for top commit: tcharding: ACK 14c3dd6 Tree-SHA512: 519ab2218685aeedfad737339a5907793c3ce0d80d5a5a5b6c56385af924bca6b13ae94e68baeb1c7a66a4f090eac3254f6137adcbdbde2393dc0ebf5a14e440
2 parents b779398 + 14c3dd6 commit 3a9c52a

File tree

86 files changed

+530
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+530
-537
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[workspace]
2-
members = ["client", "types", "node", "jsonrpc"]
2+
members = ["client", "jsonrpc", "node", "types"]
33
exclude = ["integration_test", "verify"]
44
resolver = "2"
55

66
[patch.crates-io.corepc-client]
77
path = "client"
88

9-
[patch.crates-io.corepc-types]
10-
path = "types"
9+
[patch.crates-io.jsonrpc]
10+
path = "jsonrpc"
1111

1212
[patch.crates-io.corepc-node]
1313
path = "node"
1414

15-
[patch.crates-io.jsonrpc]
16-
path = "jsonrpc"
15+
[patch.crates-io.corepc-types]
16+
path = "types"

client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ client-sync = ["jsonrpc"]
2222

2323
[dependencies]
2424
bitcoin = { version = "0.32.0", default-features = false, features = ["std", "serde"] }
25-
types = { package = "corepc-types", version = "0.9.0", default-features = false, features = ["std"] }
2625
log = "0.4"
2726
serde = { version = "1.0.103", default-features = false, features = [ "derive", "alloc" ] }
2827
serde_json = { version = "1.0.117" }
28+
types = { package = "corepc-types", path = "../types", default-features = false, features = ["std"] }
2929

30-
jsonrpc = { version = "0.18.0", features = ["minreq_http"], optional = true }
30+
jsonrpc = { path = "../jsonrpc", features = ["minreq_http"], optional = true }
3131

3232
[dev-dependencies]

client/src/client_sync/v21/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ crate::impl_client_v17__get_zmq_notifications!();
192192

193193
/// Request object for the `importdescriptors` method.
194194
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
195-
#[serde(deny_unknown_fields)]
196195
pub struct ImportDescriptorsRequest {
197196
/// Descriptor to import.
198197
#[serde(rename = "desc")]

integration_test/Cargo.toml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,10 @@ TODO = [] # This is a dirty hack while writing the tests.
5656

5757
[dependencies]
5858
bitcoin = { version = "0.32.0", default-features = false, features = ["std", "serde"] }
59-
node = { package = "corepc-node", version = "0.9.0", default-features = false }
60-
rand = "0.8.5"
6159
env_logger = "0.9.0"
60+
node = { package = "corepc-node", path = "../node", default-features = false }
61+
rand = "0.8.5"
62+
# Just so we can enable the feature.
63+
types = { package = "corepc-types", path = "../types", features = ["serde-deny-unknown-fields"] }
6264

6365
[dev-dependencies]
64-
65-
[patch.crates-io.corepc-client]
66-
path = "../client"
67-
68-
[patch.crates-io.corepc-types]
69-
path = "../types"
70-
71-
[patch.crates-io.corepc-node]
72-
path = "../node"

node/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ rust-version = "1.63.0"
1313
exclude = ["tests", "contrib"]
1414

1515
[dependencies]
16-
corepc-client = { version = "0.9.0", features = ["client-sync"] }
17-
log = { version = "0.4", default-features = false }
18-
which = { version = "3.1.1", default-features = false }
1916
anyhow = { version = "1.0.66", default-features = false, features = ["std"] }
20-
tempfile = {version = "3", default-features = false }
17+
corepc-client = { path = "../client", features = ["client-sync"] }
18+
log = { version = "0.4", default-features = false }
2119
serde_json = { version = "1.0.117", default-features = false }
20+
tempfile = { version = "3", default-features = false }
21+
which = { version = "3.1.1", default-features = false }
2222

2323
[dev-dependencies]
2424
env_logger = { version = "0.9.3", default-features = false }
@@ -27,8 +27,8 @@ env_logger = { version = "0.9.3", default-features = false }
2727
anyhow = { version = "1.0.66", optional = true }
2828
bitcoin_hashes = { version = ">= 0.13, <= 0.14", optional = true }
2929
flate2 = { version = "1.0", optional = true }
30-
tar = { version = "0.4", optional = true }
3130
minreq = { version = "2.9.1", default-features = false, features = ["https"], optional = true }
31+
tar = { version = "0.4", optional = true }
3232
zip = { version = "0.6.6", default-features = false, features = ["bzip2", "deflate"], optional = true }
3333

3434
# Please note, it is expected that a single version feature will be enabled however if you enable

types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ exclude = ["tests", "contrib"]
1515
[features]
1616
default = ["std"]
1717
std = ["bitcoin/std"]
18+
serde-deny-unknown-fields = []
1819

1920
[dependencies]
2021
bitcoin = { version = "0.32.0", default-features = false, features = ["serde", "base64", "secp-recovery"] }

types/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub fn compact_size_decode(slice: &mut &[u8]) -> u64 {
180180
/// backwards compatible so we only provide it not a v0.17 specific type. The `mtype::ScriptPubkey`
181181
/// mirrors this design (but with concrete `rust-bitcoin` types).
182182
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
183-
#[serde(deny_unknown_fields)]
183+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
184184
pub struct ScriptPubkey {
185185
/// Script assembly.
186186
pub asm: String,
@@ -219,7 +219,7 @@ impl ScriptPubkey {
219219

220220
/// Data returned by Core for a script signature.
221221
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
222-
#[serde(deny_unknown_fields)]
222+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
223223
pub struct ScriptSig {
224224
/// Assembly representation of the script.
225225
pub asm: String,

0 commit comments

Comments
 (0)