@@ -59,6 +59,17 @@ impl Deref for HWIClient {
5959
6060impl HWIClient {
6161 /// Lists all HW devices currently connected.
62+ /// ```no_run
63+ /// # use hwi::HWIClient;
64+ /// # use hwi::error::Error;
65+ /// # fn main() -> Result<(), Error> {
66+ /// let devices = HWIClient::enumerate()?;
67+ /// for device in devices {
68+ /// println!("I can see a {} here 😄", device.model);
69+ /// }
70+ /// # Ok(())
71+ /// # }
72+ /// ```
6273 pub fn enumerate ( ) -> Result < Vec < HWIDevice > , Error > {
6374 let libs = HWILib :: initialize ( ) ?;
6475 Python :: with_gil ( |py| {
@@ -68,11 +79,28 @@ impl HWIClient {
6879 } )
6980 }
7081
71- /// Finds the Python object of the device corresponding to Device
72- /// # Arguements
73- /// * `device` - The device for which the Python object will be passed
74- /// * `expert` - Whether the device should be opened in expert mode (enables additional output for some actions)
75- /// * `chain` - The Chain this client will be using
82+ /// Returns the HWIClient for a certain device. You can list all the available devices using
83+ /// [`enumerate`](HWIClient::enumerate).
84+ ///
85+ /// Setting `expert` to `true` will enable additional output for some commands.
86+ /// ```
87+ /// # use hwi::HWIClient;
88+ /// # use hwi::types::*;
89+ /// # use hwi::error::Error;
90+ /// # fn main() -> Result<(), Error> {
91+ /// let devices = HWIClient::enumerate()?;
92+ /// for device in devices {
93+ /// let client = HWIClient::get_client(&device, false, HWIChain::Test)?;
94+ /// let xpub = client.get_master_xpub(HWIAddressType::Tap, 0)?;
95+ /// println!(
96+ /// "I can see a {} here, and its xpub is {}",
97+ /// device.model,
98+ /// xpub.to_string()
99+ /// );
100+ /// }
101+ /// # Ok(())
102+ /// # }
103+ /// ```
76104 pub fn get_client (
77105 device : & HWIDevice ,
78106 expert : bool ,
@@ -92,7 +120,7 @@ impl HWIClient {
92120 } )
93121 }
94122
95- /// Returns the master xpub of a device.
123+ /// Returns the master xpub of a device, given the address type and the account number .
96124 pub fn get_master_xpub (
97125 & self ,
98126 addrtype : HWIAddressType ,
@@ -109,9 +137,7 @@ impl HWIClient {
109137 } )
110138 }
111139
112- /// Returns a psbt signed.
113- /// # Arguments
114- /// * `psbt` - The PSBT to be signed.
140+ /// Signs a PSBT.
115141 pub fn sign_tx (
116142 & self ,
117143 psbt : & PartiallySignedTransaction ,
@@ -128,10 +154,7 @@ impl HWIClient {
128154 } )
129155 }
130156
131- /// Returns the xpub of a device.
132- /// # Arguments
133- /// * `path` - The derivation path to derive the key.
134- /// * `expert` - Whether the device should be opened in expert mode (enables additional output for some actions)
157+ /// Returns the xpub of a device. If `expert` is set, additional output is returned.
135158 pub fn get_xpub (
136159 & self ,
137160 path : & DerivationPath ,
@@ -150,9 +173,6 @@ impl HWIClient {
150173 }
151174
152175 /// Signs a message.
153- /// # Arguments
154- /// * `message` - The message to sign.
155- /// * `path` - The derivation path to derive the key.
156176 pub fn sign_message (
157177 & self ,
158178 message : & str ,
@@ -171,10 +191,10 @@ impl HWIClient {
171191 }
172192
173193 /// Returns an array of keys that can be imported in Bitcoin core using importmulti
174- /// # Arguments
194+ ///
175195 /// * `keypool` - `keypool` value in result. Check bitcoin core importmulti documentation for further information
176196 /// * `internal` - Whether to use internal (change) or external keys
177- /// * `addr_type` - HWIAddressType to use
197+ /// * `addr_type` - Address type to use
178198 /// * `addr_all` - Whether to return a multiple descriptors for every address type
179199 /// * `account` - Optional BIP43 account to use
180200 /// * `path` - The derivation path to derive the keys.
@@ -218,9 +238,7 @@ impl HWIClient {
218238 } )
219239 }
220240
221- /// Returns device descriptors
222- /// # Arguments
223- /// * `account` - Optional BIP43 account to use.
241+ /// Returns device descriptors. You can optionally specify a BIP43 account to use.
224242 pub fn get_descriptors ( & self , account : Option < u32 > ) -> Result < HWIDescriptor , Error > {
225243 Python :: with_gil ( |py| {
226244 let func_args = ( & self . hw_client , account. unwrap_or ( 0 ) ) ;
@@ -234,9 +252,7 @@ impl HWIClient {
234252 } )
235253 }
236254
237- /// Returns an address given a descriptor.
238- /// # Arguments
239- /// * `descriptor` - The descriptor to use. HWI doesn't support descriptors checksums.
255+ /// Returns an address given a descriptor. Note that HWI doesn't support descriptors checksums.
240256 pub fn display_address_with_desc ( & self , descriptor : & str ) -> Result < HWIAddress , Error > {
241257 Python :: with_gil ( |py| {
242258 let path = py. None ( ) ;
@@ -251,10 +267,7 @@ impl HWIClient {
251267 } )
252268 }
253269
254- /// Returns an address given pat and address type
255- /// # Arguments
256- /// * `path` - The derivation path to use.
257- /// * `address_type` - Address type to use.
270+ /// Returns an address given path and address type.
258271 pub fn display_address_with_path (
259272 & self ,
260273 path : & DerivationPath ,
@@ -274,9 +287,9 @@ impl HWIClient {
274287 }
275288
276289 /// Install the udev rules to the local machine.
277- /// The rules will be copied from the source to the location.
278- /// The default source location is "./udev"
279- /// The default destination location is " /lib/udev/rules.d"
290+ ///
291+ /// The rules will be copied from the source to the location; the default source location is
292+ /// `./udev`, the default destination location is ` /lib/udev/rules.d`
280293 pub fn install_udev_rules ( source : Option < & str > , location : Option < & str > ) -> Result < ( ) , Error > {
281294 Python :: with_gil ( |py| {
282295 let libs = HWILib :: initialize ( ) ?;
0 commit comments