Skip to content

Commit bc072ae

Browse files
committed
feat: added listwalletdir rpc
1 parent 400a3c0 commit bc072ae

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

client/src/client.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ pub trait RpcApi: Sized {
294294
self.call("listwallets", &[])
295295
}
296296

297+
fn list_wallet_dir(&self) -> Result<Vec<String>> {
298+
let result: json::ListWalletDirResult = self.call("listwalletdir", &[])?;
299+
let names = result.wallets.into_iter().map(|x| x.name).collect();
300+
Ok(names)
301+
}
302+
297303
fn get_wallet_info(&self) -> Result<json::GetWalletInfoResult> {
298304
self.call("getwalletinfo", &[])
299305
}

integration_test/src/main.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,16 +1015,23 @@ fn test_create_wallet(cl: &Client) {
10151015
);
10161016
}
10171017

1018-
let mut wallet_list = cl.list_wallets().unwrap();
1018+
let mut loaded_wallet_list = cl.list_wallets().unwrap();
10191019

1020-
wallet_list.sort();
1020+
loaded_wallet_list.sort();
10211021

10221022
// Main wallet created for tests
1023-
assert!(wallet_list.iter().any(|w| w == "testwallet"));
1024-
wallet_list.retain(|w| w != "testwallet" && w != "");
1023+
assert!(loaded_wallet_list.iter().any(|w| w == "testwallet"));
1024+
loaded_wallet_list.retain(|w| w != "testwallet" && w != "");
10251025

10261026
// Created wallets
1027-
assert!(wallet_list.iter().zip(wallet_names).all(|(a, b)| a == b));
1027+
assert!(loaded_wallet_list.iter().zip(wallet_names).all(|(a, b)| a == b));
1028+
1029+
// get all wallets, including any that are not loaded
1030+
let wallet_list = cl.list_wallet_dir().unwrap();
1031+
// check that wallet_list is a superset of loaded_wallet_list
1032+
for ref wallet in loaded_wallet_list {
1033+
assert!(wallet_list.iter().any(|x| x == wallet));
1034+
}
10281035
}
10291036

10301037
fn test_get_tx_out_set_info(cl: &Client) {

json/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ pub struct LoadWalletResult {
131131
pub warning: Option<String>,
132132
}
133133

134+
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
135+
pub struct ListWalletDirResult {
136+
pub wallets: Vec<ListWalletDirItem>,
137+
}
138+
139+
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
140+
pub struct ListWalletDirItem {
141+
pub name: String,
142+
}
143+
134144
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
135145
pub struct GetWalletInfoResult {
136146
#[serde(rename = "walletname")]

0 commit comments

Comments
 (0)