@@ -160,6 +160,24 @@ impl Wallet {
160160 NewError :: Persist ( _) => unreachable ! ( "no persistence so it can't fail" ) ,
161161 } )
162162 }
163+
164+ /// Infallibly return a derived address using the external descriptor, see [`AddressIndex`] for
165+ /// available address index selection strategies. If none of the keys in the descriptor are derivable
166+ /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
167+ pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
168+ self . try_get_address ( address_index) . unwrap ( )
169+ }
170+
171+ /// Infallibly return a derived address using the internal (change) descriptor.
172+ ///
173+ /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
174+ ///
175+ /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
176+ /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
177+ /// be returned for any [`AddressIndex`].
178+ pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
179+ self . try_get_internal_address ( address_index) . unwrap ( )
180+ }
163181}
164182
165183#[ derive( Debug ) ]
@@ -330,27 +348,37 @@ impl<D> Wallet<D> {
330348 /// Return a derived address using the external descriptor, see [`AddressIndex`] for
331349 /// available address index selection strategies. If none of the keys in the descriptor are derivable
332350 /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
333- pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
351+ ///
352+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
353+ /// to the `PersistBackend`.
354+ pub fn try_get_address (
355+ & mut self ,
356+ address_index : AddressIndex ,
357+ ) -> Result < AddressInfo , D :: WriteError >
334358 where
335359 D : PersistBackend < ChangeSet > ,
336360 {
337361 self . _get_address ( KeychainKind :: External , address_index)
338- . expect ( "persistence backend must not fail" )
339362 }
340363
341364 /// Return a derived address using the internal (change) descriptor.
342365 ///
343366 /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
344367 ///
368+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
369+ /// to the `PersistBackend`.
370+ ///
345371 /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
346372 /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
347373 /// be returned for any [`AddressIndex`].
348- pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
374+ pub fn try_get_internal_address (
375+ & mut self ,
376+ address_index : AddressIndex ,
377+ ) -> Result < AddressInfo , D :: WriteError >
349378 where
350379 D : PersistBackend < ChangeSet > ,
351380 {
352381 self . _get_address ( KeychainKind :: Internal , address_index)
353- . expect ( "persistence backend must not fail" )
354382 }
355383
356384 /// Return a derived address using the specified `keychain` (external/internal).
0 commit comments