@@ -295,7 +295,7 @@ mod tests {
295295 const P2PK_SOURCE : & str = include_str ! ( "../../lwk_simplicity/data/p2pk.simf" ) ;
296296
297297 #[ test]
298- fn jade_signs_only_wallet_input_in_mixed_simplicity_pset ( ) {
298+ fn jade_signs_explicit_wallet_input_and_skips_simplicity_input ( ) {
299299 let env = lwk_test_util:: TestEnvBuilder :: from_env ( )
300300 . with_electrum ( )
301301 . build ( ) ;
@@ -317,11 +317,13 @@ mod tests {
317317 . unwrap ( ) ;
318318
319319 let wallet_funding_address = jade_wollet. address ( Some ( 0 ) ) . unwrap ( ) ;
320+ let explicit_wallet_address = wallet_funding_address. address ( ) . to_unconfidential ( ) ;
320321 let wallet_funding_txid =
321- env. elementsd_sendtoaddress ( wallet_funding_address . address ( ) , 10_000 , None ) ;
322+ env. elementsd_sendtoaddress ( & explicit_wallet_address , 10_000 , None ) ;
322323 env. elementsd_generate ( 1 ) ;
323324 wait_for_tx ( & mut jade_wollet, & mut client, & wallet_funding_txid) ;
324- assert_eq ! ( jade_wollet. utxos( ) . unwrap( ) . len( ) , 1 ) ;
325+ let jade_explicit_utxos = jade_wollet. explicit_utxos ( ) . unwrap ( ) ;
326+ assert_eq ! ( jade_explicit_utxos. len( ) , 1 ) ;
325327
326328 let ( simplicity_address, mut simplicity_wollet) = simplicity_p2pk_wallet ( network) ;
327329 let asset_amount = 1 ;
@@ -337,30 +339,32 @@ mod tests {
337339 let simplicity_utxos = simplicity_wollet. explicit_utxos ( ) . unwrap ( ) ;
338340 assert_eq ! ( simplicity_utxos. len( ) , 1 ) ;
339341
342+ let mut external_utxos = simplicity_utxos;
343+ external_utxos. extend ( jade_explicit_utxos) ;
344+
340345 let node_address = env. elementsd_getnewaddress ( ) . to_unconfidential ( ) ;
341346 let pset = jade_wollet
342347 . tx_builder ( )
343348 . add_explicit_recipient ( & node_address, asset_amount, asset)
344349 . unwrap ( )
345- . add_external_utxos ( simplicity_utxos )
350+ . add_external_utxos ( external_utxos )
346351 . unwrap ( )
347- . drain_lbtc_wallet ( )
348352 . finish ( )
349353 . unwrap ( ) ;
350354 assert_eq ! ( pset. inputs( ) . len( ) , 2 ) ;
351355
352356 let wallet_input_index = wallet_input_index ( & pset, & jade_fingerprint) ;
353357 let simplicity_input_index = simplicity_input_index ( & pset, & jade_fingerprint) ;
354358 assert_ne ! ( wallet_input_index, simplicity_input_index) ;
359+ assert ! ( is_explicit_input( & pset. inputs( ) [ wallet_input_index] ) ) ;
355360
356361 for input in pset. inputs ( ) {
357362 assert ! ( input. partial_sigs. is_empty( ) ) ;
358363 }
359- assert ! (
360- pset. outputs( )
361- . iter( )
362- . any( |output| is_explicit_normal_output( output) )
363- ) ;
364+ assert ! ( pset
365+ . outputs( )
366+ . iter( )
367+ . any( |output| is_explicit_normal_output( output) ) ) ;
364368 assert ! ( !has_jade_derivation(
365369 & pset. inputs( ) [ simplicity_input_index] ,
366370 & jade_fingerprint
@@ -449,6 +453,14 @@ mod tests {
449453 bytes. len ( ) == 34 && bytes[ 0 ] == 0x51 && bytes[ 1 ] == 0x20
450454 }
451455
456+ fn is_explicit_input ( input : & elements:: pset:: Input ) -> bool {
457+ input
458+ . witness_utxo
459+ . as_ref ( )
460+ . map ( |utxo| matches ! ( utxo. value, elements:: confidential:: Value :: Explicit ( _) ) )
461+ . unwrap_or ( false )
462+ }
463+
452464 fn is_explicit_normal_output ( output : & elements:: pset:: Output ) -> bool {
453465 !output. script_pubkey . is_empty ( )
454466 && output. script_pubkey != lwk_common:: burn_script ( )
0 commit comments