} Ok(client) } pub(crate) fn bitcoin_rpc_client_for_wallet_command(&self, create: bool) -> Result { let client = self.bitcoin_rpc_client()?; const MIN_VERSION: usize = 240000; let bitcoin_version = client.version()?; if bitcoin_version < MIN_VERSION { bail!( "Bitcoin Core {} or newer required, current version is {}", Self::format_bitcoin_core_version(MIN_VERSION), Self::format_bitcoin_core_version(bitcoin_version), ); } if !create { if !client.list_wallets()?.contains(&self.wallet) { client.load_wallet(&self.wallet)?; } let descriptors = client.list_descriptors(None)?.descriptors; let tr = descriptors .iter() .filter(|descriptor| descriptor.desc.starts_with("tr(")) .count(); let rawtr = descriptors .iter() .filter(|descriptor| descriptor.desc.starts_with("rawtr(")) .count(); if tr != 2 || descriptors.len() != 2 + rawtr { bail!("wallet \"{}\" contains unexpected output descriptors, and does not appear to be an `ord` wallet, create a new wallet with `ord wallet create`", self.wallet);