@@ -256,6 +256,24 @@ impl Wallet {
256256 NewError :: Write ( _) => unreachable ! ( "mock-write must always succeed" ) ,
257257 } )
258258 }
259+
260+ /// Infallibly return a derived address using the external descriptor, see [`AddressIndex`] for
261+ /// available address index selection strategies. If none of the keys in the descriptor are derivable
262+ /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
263+ pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
264+ self . try_get_address ( address_index) . unwrap ( )
265+ }
266+
267+ /// Infallibly return a derived address using the internal (change) descriptor.
268+ ///
269+ /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
270+ ///
271+ /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
272+ /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
273+ /// be returned for any [`AddressIndex`].
274+ pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
275+ self . try_get_internal_address ( address_index) . unwrap ( )
276+ }
259277}
260278
261279/// The error type when constructing a fresh [`Wallet`].
@@ -668,27 +686,37 @@ impl<D> Wallet<D> {
668686 /// Return a derived address using the external descriptor, see [`AddressIndex`] for
669687 /// available address index selection strategies. If none of the keys in the descriptor are derivable
670688 /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
671- pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
689+ ///
690+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
691+ /// to the `PersistBackend`.
692+ pub fn try_get_address (
693+ & mut self ,
694+ address_index : AddressIndex ,
695+ ) -> Result < AddressInfo , D :: WriteError >
672696 where
673697 D : PersistBackend < ChangeSet > ,
674698 {
675699 self . _get_address ( KeychainKind :: External , address_index)
676- . expect ( "persistence backend must not fail" )
677700 }
678701
679702 /// Return a derived address using the internal (change) descriptor.
680703 ///
681704 /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
682705 ///
706+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
707+ /// to the `PersistBackend`.
708+ ///
683709 /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
684710 /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
685711 /// be returned for any [`AddressIndex`].
686- pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
712+ pub fn try_get_internal_address (
713+ & mut self ,
714+ address_index : AddressIndex ,
715+ ) -> Result < AddressInfo , D :: WriteError >
687716 where
688717 D : PersistBackend < ChangeSet > ,
689718 {
690719 self . _get_address ( KeychainKind :: Internal , address_index)
691- . expect ( "persistence backend must not fail" )
692720 }
693721
694722 /// Return a derived address using the specified `keychain` (external/internal).
0 commit comments