From ce7a5c03d054a1f398d90bee6a8f5d6f24b06385 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Wed, 27 Aug 2025 12:58:16 +0100 Subject: [PATCH 1/2] Fix v22 enumeratesigners The v22 help is not correct, it gives incorrect field names. They are correct in v23. Fix the v22 struct to match the correct names in v23. --- types/src/v22/signer.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/types/src/v22/signer.rs b/types/src/v22/signer.rs index 80de88a8..da0c54a6 100644 --- a/types/src/v22/signer.rs +++ b/types/src/v22/signer.rs @@ -11,15 +11,17 @@ use serde::{Deserialize, Serialize}; /// > Returns a list of external signers from -signer. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct EnumerateSigners(pub Vec); +pub struct EnumerateSigners { + /// List of external signers. + pub signers: Vec, +} /// An item from the list returned by the JSON-RPC method `enumeratesigners` #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] pub struct Signers { /// Master key fingerprint. - pub hex: String, + pub fingerprint: String, /// Device name. - #[serde(rename = "str")] - pub device_name: String, + pub name: String, } From 4d4c3d71a5758700b73efcc6eeb3fb2259c1d807 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Wed, 27 Aug 2025 12:46:42 +0100 Subject: [PATCH 2/2] Test enumeratesigners `enumeratesigners` is implemented but not tested. Add a test and update the types table. --- integration_test/tests/signer.rs | 31 +++++++++++++++++++++++++++++++ types/src/v22/mod.rs | 2 +- types/src/v23/mod.rs | 2 +- types/src/v24/mod.rs | 2 +- types/src/v25/mod.rs | 2 +- types/src/v26/mod.rs | 2 +- types/src/v27/mod.rs | 2 +- types/src/v28/mod.rs | 2 +- types/src/v29/mod.rs | 2 +- 9 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 integration_test/tests/signer.rs diff --git a/integration_test/tests/signer.rs b/integration_test/tests/signer.rs new file mode 100644 index 00000000..954855e3 --- /dev/null +++ b/integration_test/tests/signer.rs @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Tests for methods found under the `== Signer ==` section of the API docs. + +#![allow(non_snake_case)] // Test names intentionally use double underscore. +#![allow(unused_imports)] // Because of feature gated tests. + +use integration_test::{Node, NodeExt as _, Wallet}; +use node::{mtype, Input, Output}; +use node::vtype::*; // All the version specific types. + +#[test] +#[cfg(not(feature = "v21_and_below"))] +fn signer__enumerate_signers() { + let script_path = integration_test::random_tmp_file(); + let script_body = "#!/bin/sh\necho '[{\"fingerprint\":\"deadbeef\",\"name\":\"TestSigner\"}]'\n"; + std::fs::write(&script_path, script_body).expect("write signer script"); + + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(&script_path, std::fs::Permissions::from_mode(0o755)) + .expect("chmod"); + } + + let signer_arg = format!("-signer={}", script_path.to_str().unwrap()); + let node = Node::with_wallet(Wallet::None, &[&signer_arg]); + let json: EnumerateSigners = node.client.enumerate_signers().expect("enumeratesigners"); + + assert_eq!(json.signers[0].fingerprint, "deadbeef"); +} diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 95f6225e..b518c26b 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -144,7 +144,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 2d7b6e48..b26fc6e2 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -135,7 +135,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 2a9fbd3f..f5a848b1 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -136,7 +136,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index a49d4743..10e3abac 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -137,7 +137,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 31af8770..e6c90786 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -145,7 +145,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 9fbebc08..8ebcbea0 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -145,7 +145,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 3e300966..67fa7a11 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -145,7 +145,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //! diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 295bff69..828c5e99 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -146,7 +146,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | enumeratesigners | version | UNTESTED | +//! | enumeratesigners | version | | //! //! //!