@@ -230,12 +230,15 @@ where
230230 pub async fn claim_outputs < I : IntoIterator < Item = OutputId > + Send > (
231231 & self ,
232232 output_ids_to_claim : I ,
233+ transaction_options : impl Into < Option < TransactionOptions > > + Send ,
233234 ) -> Result < TransactionWithMetadata , WalletError >
234235 where
235236 I :: IntoIter : Send ,
236237 {
237238 log:: debug!( "[OUTPUT_CLAIMING] claim_outputs" ) ;
238- let prepared_transaction = self . prepare_claim_outputs ( output_ids_to_claim) . await ?;
239+ let prepared_transaction = self
240+ . prepare_claim_outputs ( output_ids_to_claim, transaction_options)
241+ . await ?;
239242
240243 let claim_tx = self . sign_and_submit_transaction ( prepared_transaction, None ) . await ?;
241244
@@ -251,6 +254,7 @@ where
251254 pub async fn prepare_claim_outputs < I : IntoIterator < Item = OutputId > + Send > (
252255 & self ,
253256 output_ids_to_claim : I ,
257+ transaction_options : impl Into < Option < TransactionOptions > > + Send ,
254258 ) -> Result < PreparedTransactionData , WalletError >
255259 where
256260 I :: IntoIter : Send ,
@@ -278,7 +282,8 @@ where
278282 ) ) ;
279283 }
280284
281- let wallet_address = self . address ( ) . await ;
285+ let transaction_options = transaction_options. into ( ) ;
286+ let remainder_address = self . get_remainder_address ( transaction_options. clone ( ) ) . await ?;
282287 drop ( wallet_ledger) ;
283288
284289 let mut nft_outputs_to_send = Vec :: new ( ) ;
@@ -301,31 +306,39 @@ where
301306 // deposit for the remaining amount and possible native tokens
302307 NftOutputBuilder :: from ( nft_output)
303308 . with_nft_id ( nft_output. nft_id_non_null ( & output_data. output_id ) )
304- . with_unlock_conditions ( [ AddressUnlockCondition :: new ( & wallet_address ) ] )
309+ . with_unlock_conditions ( [ AddressUnlockCondition :: new ( remainder_address . clone ( ) ) ] )
305310 . finish_output ( ) ?
306311 } else {
307312 NftOutputBuilder :: from ( nft_output)
308313 . with_minimum_amount ( storage_score_params)
309314 . with_nft_id ( nft_output. nft_id_non_null ( & output_data. output_id ) )
310- . with_unlock_conditions ( [ AddressUnlockCondition :: new ( & wallet_address ) ] )
315+ . with_unlock_conditions ( [ AddressUnlockCondition :: new ( remainder_address . clone ( ) ) ] )
311316 . finish_output ( ) ?
312317 } ;
313318
314319 nft_outputs_to_send. push ( nft_output) ;
315320 }
316321 }
317322
323+ let required_inputs = outputs_to_claim
324+ . iter ( )
325+ . map ( |o| o. output_id )
326+ // add additional inputs
327+ . chain ( possible_additional_inputs. iter ( ) . map ( |o| o. output_id ) )
328+ . collect ( ) ;
329+
318330 self . prepare_send_outputs (
319331 // We only need to provide the NFT outputs, ISA automatically creates basic outputs as remainder outputs
320332 nft_outputs_to_send,
321- TransactionOptions {
322- required_inputs : outputs_to_claim
323- . iter ( )
324- . map ( |o| o. output_id )
325- // add additional inputs
326- . chain ( possible_additional_inputs. iter ( ) . map ( |o| o. output_id ) )
327- . collect ( ) ,
328- ..Default :: default ( )
333+ match transaction_options {
334+ Some ( mut tx_options) => {
335+ tx_options. required_inputs = required_inputs;
336+ tx_options
337+ }
338+ None => TransactionOptions {
339+ required_inputs,
340+ ..Default :: default ( )
341+ } ,
329342 } ,
330343 )
331344 . await
0 commit comments