Skip to content

Commit 207e17d

Browse files
committed
Merge #539: Test walletdisplayaddress
df26039 Add integration test for walletdisplayaddress RPC (Abeeujah) Pull request description: `signer__wallet_display_address` tests `walletdisplayaddress` RPC call mocking an external signer. The test mocks a Hardware Wallet (HWW) interaction by: 1. Creating a temporary shell script that acts as an external signer. 2. Handling the 'enumerate', 'getdescriptors', and 'displayaddress' commands expected by Bitcoin Core. 3. Spawning a node with the `-signer` argument pointing to this mock. 4. Creating a descriptor-based wallet with `external_signer` enabled. 5. Asserting that calling `wallet_display_address` returns the expected address from the mock signer. Heavily Inspired by [wallet_signer.py](https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_signer.py) ACKs for top commit: jamillambert: ACK df26039 tcharding: ACK df26039 Tree-SHA512: 6956528c25a812388f36fc1b5126afb2b735974cd78f7b82ac9696a5ceb961d76a69f56911adc19d0d76bfec43320cd00af2a1af425083f9bf5d6b9f3f14cf44
2 parents dfbd013 + df26039 commit 207e17d

20 files changed

Lines changed: 116 additions & 9 deletions

File tree

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ crate::impl_client_v17__add_multisig_address!();
144144
crate::impl_client_v17__backup_wallet!();
145145
crate::impl_client_v17__bump_fee!();
146146
crate::impl_client_v21__create_wallet!();
147+
crate::impl_client_v22__create_wallet!();
147148
crate::impl_client_v17__dump_priv_key!();
148149
crate::impl_client_v17__dump_wallet!();
149150
crate::impl_client_v17__encrypt_wallet!();

client/src/client_sync/v22/wallet.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,50 @@ macro_rules! impl_client_v22__wallet_display_address {
4444
}
4545
};
4646
}
47+
48+
/// Implements Bitcoin Core JSON-RPC API method `createwallet`.
49+
#[macro_export]
50+
macro_rules! impl_client_v22__create_wallet {
51+
() => {
52+
impl Client {
53+
/// Creates a wallet with external_signer=true.
54+
///
55+
/// > createwallet "wallet_name" ( disable_private_keys blank "passphrase" avoid_reuse descriptors load_on_startup external_signer )
56+
/// >
57+
/// > Creates and loads a new wallet.
58+
/// >
59+
/// > Arguments:
60+
/// > 1. wallet_name (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location.
61+
/// > 2. disable_private_keys (boolean, optional, default=false) Disable the possibility of private keys (only watchonlys are possible in this mode).
62+
/// > 3. blank (boolean, optional, default=false) Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed.
63+
/// > 4. passphrase (string, optional) Encrypt the wallet with this passphrase.
64+
/// > 5. avoid_reuse (boolean, optional, default=false) Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind.
65+
/// > 6. descriptors (boolean, optional, default=true) Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation
66+
/// > 7. load_on_startup (boolean, optional) Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged.
67+
/// > 8. external_signer (boolean, optional, default=false) Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true.
68+
pub fn create_wallet_external_signer(&self, wallet: &str) -> Result<CreateWallet> {
69+
let disable_private_keys = true;
70+
let blank = false;
71+
let passphrase = String::new();
72+
let avoid_reuse = false;
73+
let descriptors = true;
74+
let load_on_startup = false;
75+
let external_signer = true;
76+
77+
self.call(
78+
"createwallet",
79+
&[
80+
wallet.into(),
81+
disable_private_keys.into(),
82+
blank.into(),
83+
passphrase.into(),
84+
avoid_reuse.into(),
85+
descriptors.into(),
86+
load_on_startup.into(),
87+
external_signer.into(),
88+
],
89+
)
90+
}
91+
}
92+
};
93+
}

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ crate::impl_client_v17__abort_rescan!();
145145
crate::impl_client_v17__add_multisig_address!();
146146
crate::impl_client_v17__backup_wallet!();
147147
crate::impl_client_v17__bump_fee!();
148+
crate::impl_client_v22__create_wallet!();
148149
crate::impl_client_v23__create_wallet!();
149150
crate::impl_client_v17__dump_priv_key!();
150151
crate::impl_client_v17__dump_wallet!();

client/src/client_sync/v24/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ crate::impl_client_v17__abort_rescan!();
146146
crate::impl_client_v17__add_multisig_address!();
147147
crate::impl_client_v17__backup_wallet!();
148148
crate::impl_client_v17__bump_fee!();
149+
crate::impl_client_v22__create_wallet!();
149150
crate::impl_client_v23__create_wallet!();
150151
crate::impl_client_v17__dump_priv_key!();
151152
crate::impl_client_v17__dump_wallet!();

client/src/client_sync/v25/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ crate::impl_client_v17__abort_rescan!();
147147
crate::impl_client_v17__add_multisig_address!();
148148
crate::impl_client_v17__backup_wallet!();
149149
crate::impl_client_v17__bump_fee!();
150+
crate::impl_client_v22__create_wallet!();
150151
crate::impl_client_v23__create_wallet!();
151152
crate::impl_client_v17__dump_priv_key!();
152153
crate::impl_client_v17__dump_wallet!();

client/src/client_sync/v26/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ crate::impl_client_v17__abort_rescan!();
158158
crate::impl_client_v17__add_multisig_address!();
159159
crate::impl_client_v17__backup_wallet!();
160160
crate::impl_client_v17__bump_fee!();
161+
crate::impl_client_v22__create_wallet!();
161162
crate::impl_client_v23__create_wallet!();
162163
crate::impl_client_v17__dump_priv_key!();
163164
crate::impl_client_v17__dump_wallet!();

client/src/client_sync/v27/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ crate::impl_client_v17__abort_rescan!();
154154
crate::impl_client_v17__add_multisig_address!();
155155
crate::impl_client_v17__backup_wallet!();
156156
crate::impl_client_v17__bump_fee!();
157+
crate::impl_client_v22__create_wallet!();
157158
crate::impl_client_v23__create_wallet!();
158159
crate::impl_client_v17__dump_priv_key!();
159160
crate::impl_client_v17__dump_wallet!();

client/src/client_sync/v28/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ crate::impl_client_v17__abort_rescan!();
155155
crate::impl_client_v17__add_multisig_address!();
156156
crate::impl_client_v17__backup_wallet!();
157157
crate::impl_client_v17__bump_fee!();
158+
crate::impl_client_v22__create_wallet!();
158159
crate::impl_client_v23__create_wallet!();
159160
crate::impl_client_v28__create_wallet_descriptor!();
160161
crate::impl_client_v17__dump_priv_key!();

client/src/client_sync/v29/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ crate::impl_client_v17__abort_rescan!();
162162
crate::impl_client_v17__add_multisig_address!();
163163
crate::impl_client_v17__backup_wallet!();
164164
crate::impl_client_v17__bump_fee!();
165+
crate::impl_client_v22__create_wallet!();
165166
crate::impl_client_v23__create_wallet!();
166167
crate::impl_client_v28__create_wallet_descriptor!();
167168
crate::impl_client_v17__dump_priv_key!();

client/src/client_sync/v30/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ crate::impl_client_v17__abandon_transaction!();
159159
crate::impl_client_v17__abort_rescan!();
160160
crate::impl_client_v17__backup_wallet!();
161161
crate::impl_client_v17__bump_fee!();
162+
crate::impl_client_v22__create_wallet!();
162163
crate::impl_client_v23__create_wallet!();
163164
crate::impl_client_v28__create_wallet_descriptor!();
164165
crate::impl_client_v17__encrypt_wallet!();

0 commit comments

Comments
 (0)