@@ -2358,6 +2358,7 @@ public void CanBuildTransaction(PSBTVersion version)
23582358 txBuilder . StandardTransactionPolicy = EasyPolicy ;
23592359 txBuilder . MergeOutputs = false ;
23602360 var tx = txBuilder
2361+ . SetLockTime ( 1 )
23612362 . AddCoins ( allCoins )
23622363 . AddKeys ( keys )
23632364 . Send ( destinations [ 0 ] , Money . Parse ( "6" ) * 2 )
@@ -2370,7 +2371,8 @@ public void CanBuildTransaction(PSBTVersion version)
23702371 Assert . True ( txBuilder . Verify ( tx , "0.0001" ) ) ;
23712372
23722373 // Let's check if PSBT can be finalized
2373- var psbt = txBuilder . BuildPSBT ( true ) ;
2374+ var psbt = txBuilder . BuildPSBT ( true , version ) ;
2375+ Assert . Equal ( new LockTime ( 1 ) , psbt . GetGlobalTransaction ( ) . LockTime ) ;
23742376 Assert . All ( psbt . Inputs , input => input . PartialSigs . Any ( ) ) ; // All inputs should have partial sigs
23752377 Assert . False ( psbt . IsAllFinalized ( ) ) ;
23762378 Assert . False ( psbt . TryFinalize ( out _ ) ) ;
@@ -3191,9 +3193,11 @@ public void CanCreateBigTransactionsWithLotsOfInputs()
31913193 var ex = Assert . Throws < NotEnoughFundsException > ( ( ) => tx = builder . BuildTransaction ( true ) ) ;
31923194 Assert . Contains ( "You may have" , ex . Message ) ;
31933195 }
3194- [ Fact ]
3196+ [ Theory ]
3197+ [ InlineData ( PSBTVersion . PSBTv0 ) ]
3198+ [ InlineData ( PSBTVersion . PSBTv2 ) ]
31953199 [ Trait ( "UnitTest" , "UnitTest" ) ]
3196- public void CanSignWithCoinSpecificKey ( )
3200+ public void CanSignWithCoinSpecificKey ( PSBTVersion version )
31973201 {
31983202 var k = new Key ( ) ;
31993203 var addr = k . GetScriptPubKey ( ScriptPubKeyType . Segwit ) ;
@@ -3206,7 +3210,7 @@ public void CanSignWithCoinSpecificKey()
32063210 builder . SetChange ( new Key ( ) ) ;
32073211 builder . SendAllRemainingToChange ( ) ;
32083212 builder . SendEstimatedFees ( new FeeRate ( 1.0m ) ) ;
3209- var psbt = builder . BuildPSBT ( true ) ;
3213+ var psbt = builder . BuildPSBT ( true , version ) ;
32103214 Assert . True ( psbt . Inputs . FindIndexedInput ( coins [ 0 ] . Outpoint ) . TryFinalizeInput ( out _ ) ) ;
32113215 Assert . False ( psbt . Inputs . FindIndexedInput ( coins [ 1 ] . Outpoint ) . TryFinalizeInput ( out _ ) ) ;
32123216 }
@@ -3281,10 +3285,12 @@ public void TransactionBuilderDoesNotRunForever()
32813285 Assert . Equal ( 3 , tx . Inputs . Count ) ;
32823286 }
32833287
3284- [ Fact ]
3288+ [ Theory ]
3289+ [ InlineData ( PSBTVersion . PSBTv0 ) ]
3290+ [ InlineData ( PSBTVersion . PSBTv2 ) ]
32853291 [ Trait ( "UnitTest" , "UnitTest" ) ]
32863292 // Fix https://github.com/MetacoSA/NBitcoin/issues/746
3287- public void TransactionBuilderDoesNotCreateInvalidTx ( )
3293+ public void TransactionBuilderDoesNotCreateInvalidTx ( PSBTVersion version )
32883294 {
32893295 var masterKey = new ExtKey ( ) ;
32903296 var keys = Enumerable . Range ( 0 , 4 ) . Select ( x => masterKey . Derive ( ( uint ) x ) ) . ToArray ( ) ;
@@ -3300,7 +3306,7 @@ public void TransactionBuilderDoesNotCreateInvalidTx()
33003306 builder . SendAllRemaining ( new Key ( ) ) ;
33013307 builder . SendEstimatedFees ( new FeeRate ( 10m ) ) ;
33023308
3303- var psbt = builder . BuildPSBT ( false ) ;
3309+ var psbt = builder . BuildPSBT ( false , version ) ;
33043310 builder = builder . AddKeys ( keys . ToArray ( ) ) ;
33053311 builder . SignPSBT ( psbt ) ;
33063312 psbt . Finalize ( ) ;
0 commit comments