@@ -259,6 +259,29 @@ impl Wallet {
259259 }
260260}
261261
262+ impl < D > Wallet < D >
263+ where
264+ D : PersistBackend < ChangeSet , WriteError = core:: convert:: Infallible > ,
265+ {
266+ /// Infallibly return a derived address using the external descriptor, see [`AddressIndex`] for
267+ /// available address index selection strategies. If none of the keys in the descriptor are derivable
268+ /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
269+ pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
270+ self . try_get_address ( address_index) . unwrap ( )
271+ }
272+
273+ /// Infallibly return a derived address using the internal (change) descriptor.
274+ ///
275+ /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
276+ ///
277+ /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
278+ /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
279+ /// be returned for any [`AddressIndex`].
280+ pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo {
281+ self . try_get_internal_address ( address_index) . unwrap ( )
282+ }
283+ }
284+
262285/// The error type when constructing a fresh [`Wallet`].
263286///
264287/// Methods [`new`] and [`new_with_genesis_hash`] may return this error.
@@ -611,27 +634,37 @@ impl<D> Wallet<D> {
611634 /// Return a derived address using the external descriptor, see [`AddressIndex`] for
612635 /// available address index selection strategies. If none of the keys in the descriptor are derivable
613636 /// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
614- pub fn get_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
637+ ///
638+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
639+ /// to the `PersistBackend`.
640+ pub fn try_get_address (
641+ & mut self ,
642+ address_index : AddressIndex ,
643+ ) -> Result < AddressInfo , D :: WriteError >
615644 where
616645 D : PersistBackend < ChangeSet > ,
617646 {
618647 self . _get_address ( KeychainKind :: External , address_index)
619- . expect ( "persistence backend must not fail" )
620648 }
621649
622650 /// Return a derived address using the internal (change) descriptor.
623651 ///
624652 /// If the wallet doesn't have an internal descriptor it will use the external descriptor.
625653 ///
654+ /// A `PersistBackend<ChangeSet>::WriteError` will result if unable to persist the new address
655+ /// to the `PersistBackend`.
656+ ///
626657 /// see [`AddressIndex`] for available address index selection strategies. If none of the keys
627658 /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always
628659 /// be returned for any [`AddressIndex`].
629- pub fn get_internal_address ( & mut self , address_index : AddressIndex ) -> AddressInfo
660+ pub fn try_get_internal_address (
661+ & mut self ,
662+ address_index : AddressIndex ,
663+ ) -> Result < AddressInfo , D :: WriteError >
630664 where
631665 D : PersistBackend < ChangeSet > ,
632666 {
633667 self . _get_address ( KeychainKind :: Internal , address_index)
634- . expect ( "persistence backend must not fail" )
635668 }
636669
637670 /// Return a derived address using the specified `keychain` (external/internal).
0 commit comments