Skip to content

Commit 2424425

Browse files
committed
feat(multipath): Update wallets public desc output
1 parent 0881d45 commit 2424425

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ pub struct WalletConfig {
2727
pub struct WalletConfigInner {
2828
pub wallet: String,
2929
pub network: String,
30+
/// This can be a single multipath descriptor (BIP389) or a standard external descriptor.
3031
pub ext_descriptor: String,
32+
/// optional; Do not use if external descriptor is a multipath (BIP389) string
3133
pub int_descriptor: Option<String>,
3234
#[cfg(any(feature = "sqlite", feature = "redb"))]
3335
pub database_type: String,

src/handlers.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -480,25 +480,32 @@ pub fn handle_offline_wallet_subcommand(
480480
let internal = wallet.public_descriptor(KeychainKind::Internal).to_string();
481481

482482
if cli_opts.pretty {
483-
let table = vec![
484-
vec![
485-
"External Descriptor".cell().bold(true),
486-
external.to_string().cell(),
487-
],
483+
let rows = if external == internal {
484+
vec![vec![
485+
"Multipath Descriptor".cell().bold(true),
486+
external.cell(),
487+
]]
488+
} else {
488489
vec![
489-
"Internal Descriptor".cell().bold(true),
490-
internal.to_string().cell(),
491-
],
492-
]
493-
.table()
494-
.display()
495-
.map_err(|e| Error::Generic(e.to_string()))?;
490+
vec!["External Descriptor".cell().bold(true), external.cell()],
491+
vec!["Internal Descriptor".cell().bold(true), internal.cell()],
492+
]
493+
};
494+
let table = rows
495+
.table()
496+
.display()
497+
.map_err(|e| Error::Generic(e.to_string()))?;
496498
Ok(format!("{table}"))
497499
} else {
498-
Ok(serde_json::to_string_pretty(&json!({
499-
"external": external.to_string(),
500-
"internal": internal.to_string(),
501-
}))?)
500+
let desc = if external == internal {
501+
json!({"multipath_descriptor": external.to_string()})
502+
} else {
503+
json!({
504+
"external": external.to_string(),
505+
"internal": internal.to_string(),
506+
})
507+
};
508+
Ok(serde_json::to_string_pretty(&desc)?)
502509
}
503510
}
504511
Sign {

0 commit comments

Comments
 (0)