@@ -345,6 +345,15 @@ impl Wallet {
345345 Ok ( proofs. into_iter ( ) . map ( |p| p. into ( ) ) . collect ( ) )
346346 }
347347
348+ /// Check and mint any paid but unissued mint quotes.
349+ ///
350+ /// This is useful during startup or recovery after incomplete mint quote flows.
351+ /// It may perform network requests and write newly issued proofs to the wallet store.
352+ pub async fn mint_unissued_quotes ( & self ) -> Result < Amount , FfiError > {
353+ let minted = self . inner . mint_unissued_quotes ( ) . await ?;
354+ Ok ( minted. into ( ) )
355+ }
356+
348357 /// Prepare a melt operation
349358 ///
350359 /// Returns a `PreparedMelt` that can be confirmed or cancelled.
@@ -925,3 +934,44 @@ pub fn mnemonic_to_entropy(mnemonic: String) -> Result<Vec<u8>, FfiError> {
925934 . map_err ( |e| FfiError :: internal ( format ! ( "Invalid mnemonic: {}" , e) ) ) ?;
926935 Ok ( m. to_entropy ( ) )
927936}
937+
938+ #[ cfg( test) ]
939+ mod tests {
940+ use cdk_common:: wallet:: Wallet as WalletTrait ;
941+
942+ use crate :: database:: custom_wallet_store;
943+ use crate :: sqlite:: WalletSqliteDatabase ;
944+
945+ use super :: * ;
946+
947+ fn test_wallet ( ) -> Wallet {
948+ let db = WalletSqliteDatabase :: new_in_memory ( ) . expect ( "in-memory wallet db should open" ) ;
949+ Wallet :: new (
950+ "https://mint.example.com" . to_string ( ) ,
951+ CurrencyUnit :: Sat ,
952+ "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
953+ . to_string ( ) ,
954+ custom_wallet_store ( db) ,
955+ WalletConfig {
956+ target_proof_count : None ,
957+ } ,
958+ )
959+ . expect ( "wallet should be created" )
960+ }
961+
962+ #[ tokio:: test( flavor = "multi_thread" ) ]
963+ async fn mint_unissued_quotes_is_available_on_wallet_and_trait ( ) {
964+ let wallet = test_wallet ( ) ;
965+
966+ let minted = wallet
967+ . mint_unissued_quotes ( )
968+ . await
969+ . expect ( "empty quote store should mint zero" ) ;
970+ assert ! ( minted. is_zero( ) ) ;
971+
972+ let trait_minted = <Wallet as WalletTrait >:: mint_unissued_quotes ( & wallet)
973+ . await
974+ . expect ( "trait call should mint zero from empty quote store" ) ;
975+ assert ! ( trait_minted. is_zero( ) ) ;
976+ }
977+ }
0 commit comments