@@ -37,6 +37,9 @@ pub struct ReceiveSubCommand {
3737 /// Allow receiving from untrusted mints (mints not already in the wallet)
3838 #[ arg( long, default_value = "false" ) ]
3939 allow_untrusted : bool ,
40+ /// Only accept the token offline and place it into PendingReceive state
41+ #[ arg( long, default_value = "false" ) ]
42+ offline : bool ,
4043}
4144
4245pub async fn receive (
@@ -72,6 +75,7 @@ pub async fn receive(
7275 & signing_keys,
7376 & sub_command_args. preimage ,
7477 sub_command_args. allow_untrusted ,
78+ sub_command_args. offline ,
7579 unit,
7680 )
7781 . await ?
@@ -114,6 +118,7 @@ pub async fn receive(
114118 & signing_keys,
115119 & sub_command_args. preimage ,
116120 sub_command_args. allow_untrusted ,
121+ sub_command_args. offline ,
117122 unit,
118123 )
119124 . await
@@ -142,6 +147,7 @@ async fn receive_token(
142147 signing_keys : & [ SecretKey ] ,
143148 preimage : & [ String ] ,
144149 allow_untrusted : bool ,
150+ offline : bool ,
145151 unit : & CurrencyUnit ,
146152) -> Result < Amount > {
147153 let token: Token = Token :: from_str ( token_str) ?;
@@ -162,15 +168,24 @@ async fn receive_token(
162168 // Get or create wallet for the token's mint
163169 let wallet = get_or_create_wallet ( wallet_repository, & mint_url, unit) . await ?;
164170
165- // Create receive options
166- let receive_options = ReceiveOptions {
167- p2pk_signing_keys : signing_keys. to_vec ( ) ,
168- preimages : preimage. to_vec ( ) ,
169- ..Default :: default ( )
170- } ;
171-
172- let received = wallet. receive ( token_str, receive_options) . await ?;
173- Ok ( received)
171+ if offline {
172+ let options = cdk_common:: wallet:: OfflineReceiveOptions {
173+ minimum_locktime : None ,
174+ require_locked : false ,
175+ } ;
176+ let received = wallet. receive_offline ( token_str, options) . await ?;
177+ Ok ( received)
178+ } else {
179+ // Create receive options
180+ let receive_options = ReceiveOptions {
181+ p2pk_signing_keys : signing_keys. to_vec ( ) ,
182+ preimages : preimage. to_vec ( ) ,
183+ ..Default :: default ( )
184+ } ;
185+
186+ let received = wallet. receive ( token_str, receive_options) . await ?;
187+ Ok ( received)
188+ }
174189}
175190
176191/// Receive tokens sent to nostr pubkey via dm
0 commit comments