Skip to content

Address all TODO in v22 #295

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 4 commits into from
Jul 19, 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
6 changes: 6 additions & 0 deletions client/src/client_sync/v22/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//!
//! We ignore option arguments unless they effect the shape of the returned JSON data.

mod signer;
mod wallet;

use std::collections::BTreeMap;
Expand Down Expand Up @@ -110,6 +111,9 @@ crate::impl_client_v17__sign_raw_transaction_with_key!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -151,6 +155,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -176,6 +181,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
22 changes: 22 additions & 0 deletions client/src/client_sync/v22/signer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: CC0-1.0

//! Macros for implementing JSON-RPC methods on a client.
//!
//! Specifically this is methods found under the `== Signer ==` section of the
//! API docs of Bitcoin Core `v22`.
//!
//! All macros require `Client` to be in scope.
//!
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.

/// Implements Bitcoin Core JSON-RPC API method `enumeratesigners`
#[macro_export]
macro_rules! impl_client_v22__enumerate_signers {
() => {
impl Client {
pub fn enumerate_signers(&self) -> Result<EnumerateSigners> {
self.call("enumeratesigners", &[])
}
}
};
}
24 changes: 24 additions & 0 deletions client/src/client_sync/v22/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
//!
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.

/// Implements Bitcoin Core JSON-RPC API method `listdescriptors`
#[macro_export]
macro_rules! impl_client_v22__list_descriptors {
() => {
impl Client {
pub fn list_descriptors(&self) -> Result<ListDescriptors> {
self.call("listdescriptors", &[])
}
}
};
}

/// Implements Bitcoin Core JSON-RPC API method `loadwallet`
#[macro_export]
macro_rules! impl_client_v22__load_wallet {
Expand All @@ -20,3 +32,15 @@ macro_rules! impl_client_v22__load_wallet {
}
};
}

/// Implements Bitcoin Core JSON-RPC API method `walletdisplayaddress`
#[macro_export]
macro_rules! impl_client_v22__wallet_display_address {
() => {
impl Client {
pub fn wallet_display_address(&self, address: &str) -> Result<WalletDisplayAddress> {
self.call("walletdisplayaddress", &[address.into()])
}
}
};
}
5 changes: 5 additions & 0 deletions client/src/client_sync/v23/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ crate::impl_client_v17__sign_raw_transaction_with_key!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -153,6 +156,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -178,6 +182,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
5 changes: 5 additions & 0 deletions client/src/client_sync/v24/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ crate::impl_client_v17__sign_raw_transaction_with_key!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -150,6 +153,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -175,6 +179,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
5 changes: 5 additions & 0 deletions client/src/client_sync/v25/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ crate::impl_client_v17__sign_raw_transaction_with_key!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -152,6 +155,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -177,6 +181,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
5 changes: 5 additions & 0 deletions client/src/client_sync/v26/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ crate::impl_client_v26__submit_package!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -156,6 +159,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -181,6 +185,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
5 changes: 5 additions & 0 deletions client/src/client_sync/v27/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ crate::impl_client_v26__submit_package!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -152,6 +155,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -177,6 +181,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
5 changes: 5 additions & 0 deletions client/src/client_sync/v28/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ crate::impl_client_v28__submit_package!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -154,6 +157,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -179,6 +183,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
5 changes: 5 additions & 0 deletions client/src/client_sync/v29/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ crate::impl_client_v28__submit_package!();
crate::impl_client_v17__test_mempool_accept!();
crate::impl_client_v18__utxo_update_psbt!();

// == Signer ==
crate::impl_client_v22__enumerate_signers!();

// == Util ==
crate::impl_client_v17__create_multisig!();
crate::impl_client_v18__derive_addresses!();
Expand Down Expand Up @@ -154,6 +157,7 @@ crate::impl_client_v17__import_pubkey!();
crate::impl_client_v17__import_wallet!();
crate::impl_client_v17__key_pool_refill!();
crate::impl_client_v17__list_address_groupings!();
crate::impl_client_v22__list_descriptors!();
crate::impl_client_v18__list_received_by_label!();
crate::impl_client_v17__list_labels!();
crate::impl_client_v17__list_lock_unspent!();
Expand All @@ -179,6 +183,7 @@ crate::impl_client_v17__sign_raw_transaction_with_wallet!();
crate::impl_client_v21__unload_wallet!();
crate::impl_client_v21__upgrade_wallet!();
crate::impl_client_v17__wallet_create_funded_psbt!();
crate::impl_client_v22__wallet_display_address!();
crate::impl_client_v17__wallet_lock!();
crate::impl_client_v17__wallet_passphrase!();
crate::impl_client_v17__wallet_passphrase_change!();
Expand Down
19 changes: 19 additions & 0 deletions integration_test/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,25 @@ fn wallet__import_pubkey() {
let _: () = node.client.import_pubkey(&pubkey).expect("importpubkey");
}

#[test]
#[cfg(not(feature = "v21_and_below"))]
fn wallet__list_descriptors() {
let node = Node::with_wallet(Wallet::None, &[]);
let wallet_name = "desc_wallet";

#[cfg(feature = "v22_and_below")]
node.client.create_wallet_with_descriptors(wallet_name).expect("create descriptor wallet");

// v23 onwards uses descriptor wallets by default.
#[cfg(not(feature = "v22_and_below"))]
node.client.create_wallet(wallet_name).expect("create wallet");

let json: ListDescriptors = node.client.list_descriptors().expect("listdescriptors");

let has_descriptor = json.descriptors.iter().any(|desc_info| desc_info.descriptor.starts_with("wpkh(") || desc_info.descriptor.starts_with("pkh("));
assert!(has_descriptor, "No standard descriptors found in listdescriptors result");
}

#[test]
fn wallet__list_unspent__modelled() {
let node = match () {
Expand Down
3 changes: 2 additions & 1 deletion types/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub use self::{
ListReceivedByLabel, ListReceivedByLabelItem, ListSinceBlock, ListSinceBlockTransaction,
ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets,
LoadWallet, PsbtBumpFee, RescanBlockchain, ScriptType, Send, SendMany, SendToAddress,
SignMessage, TransactionCategory, UnloadWallet, WalletCreateFundedPsbt, WalletProcessPsbt,
SignMessage, TransactionCategory, UnloadWallet, WalletCreateFundedPsbt,
WalletDisplayAddress, WalletProcessPsbt,
},
};
8 changes: 8 additions & 0 deletions types/src/model/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,14 @@ pub struct WalletCreateFundedPsbt {
pub change_pos: u32,
}

/// Models the result of JSON-RPC method `walletdisplayaddress`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct WalletDisplayAddress {
/// The address as confirmed by the signer
pub address: Address<NetworkUnchecked>,
}

/// Models the result of JSON-RPC method `walletprocesspsbt`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
Expand Down
10 changes: 7 additions & 3 deletions types/src/v22/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
//!
//! | JSON-RPC Method Name | Returns | Notes |
//! |:-----------------------------------|:---------------:|:--------------------------------------:|
//! | enumeratesigners | version + model | TODO |
//! | enumeratesigners | version | UNTESTED |
//!
//! </details>
//!
Expand Down Expand Up @@ -198,7 +198,7 @@
//! | importwallet | returns nothing | |
//! | keypoolrefill | returns nothing | |
//! | listaddressgroupings | version + model | UNTESTED |
//! | listdescriptors | version + model | TODO |
//! | listdescriptors | version | |
//! | listlabels | version + model | UNTESTED |
//! | listlockunspent | version + model | UNTESTED |
//! | psbtbumpfee | version + model | |
Expand All @@ -225,7 +225,7 @@
//! | unloadwallet | returns nothing | |
//! | upgradewallet | version | |
//! | walletcreatefundedpsbt | version + model | UNTESTED |
//! | walletdisplayaddress | version + model | TODO |
//! | walletdisplayaddress | version + model | UNTESTED |
//! | walletlock | returns nothing | |
//! | walletpassphrase | returns nothing | |
//! | walletpassphrasechange | returns nothing | |
Expand All @@ -247,13 +247,17 @@ mod blockchain;
mod control;
mod network;
mod raw_transactions;
mod signer;
mod wallet;

#[doc(inline)]
pub use self::{
blockchain::GetMempoolInfo,
control::Logging,
network::{Banned, GetPeerInfo, ListBanned},
raw_transactions::{DecodeScript, DecodeScriptError},
signer::EnumerateSigners,
wallet::{ListDescriptors, WalletDisplayAddress},
};
#[doc(inline)]
pub use crate::{
Expand Down
25 changes: 25 additions & 0 deletions types/src/v22/signer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: CC0-1.0

//! The JSON-RPC API for Bitcoin Core `v22` - signer.
//!
//! Types for methods found under the `== Signer ==` section of the API docs.

use serde::{Deserialize, Serialize};

/// Result of JSON-RPC method `enumeratesigners`.
///
/// > Returns a list of external signers from -signer.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct EnumerateSigners(pub Vec<Signers>);

/// 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,
/// Device name.
#[serde(rename = "str")]
pub device_name: String,
}
Loading