@@ -225,6 +225,24 @@ impl Wallet {
225225 NewError :: Persist ( _) => unreachable ! ( "no persistence so it can't fail" ) ,
226226 } )
227227 }
228+
229+ /// Infallibly return a derived address using the external descriptor, see [`AddressIndex`] for
230+ /// available address index selection strategies. If none of the keys in the descriptor are derivable
231+ /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
232+ pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
233+ self . try_get_address ( address_index) . unwrap ( )
234+ }
235+
236+ /// Infallibly return a derived address using the internal (change) descriptor.
237+ ///
238+ /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
239+ ///
240+ /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
241+ /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
242+ /// be returned for any [`AddressIndex`].
243+ pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
244+ self . try_get_internal_address ( address_index) . unwrap ( )
245+ }
228246}
229247
230248#[ derive( Debug ) ]
@@ -395,27 +413,37 @@ impl<D> Wallet<D> {
395413 /// Return a derived address using the external descriptor, see [`AddressIndex`] for
396414 /// available address index selection strategies. If none of the keys in the descriptor are derivable
397415 /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
398- pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
416+ ///
417+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
418+ /// to the `PersistBackend`.
419+ pub fn try_get_address (
420+ & mut self ,
421+ address_index : AddressIndex ,
422+ ) -> Result < AddressInfo , D :: WriteError >
399423 where
400424 D : PersistBackend < ChangeSet > ,
401425 {
402426 self . _get_address ( KeychainKind :: External , address_index)
403- . expect ( "persistence backend must not fail" )
404427 }
405428
406429 /// Return a derived address using the internal (change) descriptor.
407430 ///
408431 /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
409432 ///
433+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
434+ /// to the `PersistBackend`.
435+ ///
410436 /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
411437 /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
412438 /// be returned for any [`AddressIndex`].
413- pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
439+ pub fn try_get_internal_address (
440+ & mut self ,
441+ address_index : AddressIndex ,
442+ ) -> Result < AddressInfo , D :: WriteError >
414443 where
415444 D : PersistBackend < ChangeSet > ,
416445 {
417446 self . _get_address ( KeychainKind :: Internal , address_index)
418- . expect ( "persistence backend must not fail" )
419447 }
420448
421449 /// Return a derived address using the specified `keychain` (external/internal).
0 commit comments