1616mod simulation;
1717
1818use std:: {
19+ borrow:: Cow ,
1920 convert:: Infallible ,
2021 sync:: { Arc , Mutex } ,
2122 time:: Duration ,
@@ -42,7 +43,14 @@ use common::{
4243 authorize_pubkey_spend:: sign_public_key_spending,
4344 standard_signature:: StandardInputSignature , InputWitness ,
4445 } ,
45- sighash:: { sighashtype:: SigHashType , signature_hash} ,
46+ sighash:: {
47+ input_commitments:: {
48+ make_sighash_input_commitments_for_transaction_inputs, SighashInputCommitment ,
49+ TrivialUtxoProvider ,
50+ } ,
51+ sighashtype:: SigHashType ,
52+ signature_hash,
53+ } ,
4654 } ,
4755 stakelock:: StakePoolData ,
4856 timelock:: OutputTimeLock ,
@@ -547,25 +555,27 @@ async fn compare_pool_rewards_with_chainstate_real_state(#[case] seed: Seed) {
547555 sync_and_compare ( & mut tf, block, & mut local_state, pool_id) . await ;
548556
549557 let remaining_coins = remaining_coins - rng. gen_range ( 0 ..10 ) ;
558+ let input1 = TxInput :: from_utxo ( OutPointSourceId :: Transaction ( prev_tx_id) , 0 ) ;
559+ let input2 = TxInput :: from_utxo ( OutPointSourceId :: BlockReward ( prev_block_hash. into ( ) ) , 0 ) ;
550560 let transaction = TransactionBuilder :: new ( )
551- . add_input (
552- TxInput :: from_utxo ( OutPointSourceId :: Transaction ( prev_tx_id) , 0 ) ,
553- InputWitness :: NoSignature ( None ) ,
554- )
555- . add_input (
556- TxInput :: from_utxo ( OutPointSourceId :: BlockReward ( prev_block_hash. into ( ) ) , 0 ) ,
557- InputWitness :: NoSignature ( None ) ,
558- )
561+ . add_input ( input1. clone ( ) , InputWitness :: NoSignature ( None ) )
562+ . add_input ( input2. clone ( ) , InputWitness :: NoSignature ( None ) )
559563 . add_output ( TxOutput :: Transfer (
560564 OutputValue :: Coin ( Amount :: from_atoms ( remaining_coins) ) ,
561565 Destination :: AnyoneCanSpend ,
562566 ) )
563567 . build ( ) ;
564568
569+ let utxos = [ Some ( coin_tx_out) , Some ( from_block_output) ] ;
570+ let input_commitments = make_sighash_input_commitments_for_transaction_inputs (
571+ & [ input1, input2] ,
572+ & TrivialUtxoProvider ( & utxos) ,
573+ )
574+ . unwrap ( ) ;
565575 let sighash = signature_hash (
566576 SigHashType :: default ( ) ,
567577 transaction. transaction ( ) ,
568- & [ Some ( & coin_tx_out ) , Some ( & from_block_output ) ] ,
578+ & input_commitments ,
569579 1 ,
570580 )
571581 . unwrap ( ) ;
@@ -787,7 +797,10 @@ async fn reorg_locked_balance(#[case] seed: Seed) {
787797 let sighash = signature_hash (
788798 SigHashType :: default ( ) ,
789799 spend_transaction. transaction ( ) ,
790- & [ Some ( & lock_for_block_count) , Some ( & lock_until_height) ] ,
800+ & [
801+ SighashInputCommitment :: Utxo ( Cow :: Borrowed ( & lock_for_block_count) ) ,
802+ SighashInputCommitment :: Utxo ( Cow :: Borrowed ( & lock_until_height) ) ,
803+ ] ,
791804 idx,
792805 )
793806 . unwrap ( ) ;
@@ -865,7 +878,10 @@ async fn reorg_locked_balance(#[case] seed: Seed) {
865878 let sighash = signature_hash (
866879 SigHashType :: default ( ) ,
867880 spend_time_locked. transaction ( ) ,
868- & [ Some ( & lock_for_sec) , Some ( & lock_until_time) ] ,
881+ & [
882+ SighashInputCommitment :: Utxo ( Cow :: Borrowed ( & lock_for_sec) ) ,
883+ SighashInputCommitment :: Utxo ( Cow :: Borrowed ( & lock_until_time) ) ,
884+ ] ,
869885 idx,
870886 )
871887 . unwrap ( ) ;
0 commit comments