@@ -365,9 +365,9 @@ public async Task CanCreatePSBT()
365
365
Assert . NotNull ( spendingPSBT . Inputs [ 0 ] . WitnessUtxo ) ;
366
366
///////////////////////////
367
367
368
- // CanCreatePSBTCore(tester, ScriptPubKeyType.SegwitP2SH);
369
- // CanCreatePSBTCore(tester, ScriptPubKeyType.Segwit);
370
- // CanCreatePSBTCore(tester, ScriptPubKeyType.Legacy);
368
+ CanCreatePSBTCore ( tester , ScriptPubKeyType . SegwitP2SH ) ;
369
+ CanCreatePSBTCore ( tester , ScriptPubKeyType . Segwit ) ;
370
+ CanCreatePSBTCore ( tester , ScriptPubKeyType . Legacy ) ;
371
371
CanCreatePSBTCore ( tester , ScriptPubKeyType . TaprootBIP86 ) ;
372
372
373
373
// If we build a list of unconf transaction which is too long, the CreatePSBT should
@@ -471,6 +471,11 @@ private static void CanCreatePSBTCore(ServerTester tester, ScriptPubKeyType type
471
471
Assert . Empty ( input . HDKeyPaths ) ;
472
472
Assert . Single ( input . HDTaprootKeyPaths ) ;
473
473
Assert . NotNull ( input . TaprootInternalKey ) ;
474
+
475
+ var output = Assert . Single ( minimumInputs . PSBT . Outputs , o => o . ScriptPubKey == minimumInputs . ChangeAddress . ScriptPubKey ) ;
476
+ Assert . NotNull ( output . TaprootInternalKey ) ;
477
+ Assert . Empty ( output . HDKeyPaths ) ;
478
+ Assert . NotEmpty ( output . HDTaprootKeyPaths ) ;
474
479
}
475
480
Assert . Equal ( 2 , spendAllOutpoints . PSBT . Inputs . Count ) ;
476
481
}
@@ -849,8 +854,8 @@ private static void CanCreatePSBTCore(ServerTester tester, ScriptPubKeyType type
849
854
ReserveChangeAddress = false
850
855
} ) ;
851
856
Assert . Equal ( 3 , psbt2 . PSBT . Outputs . Count ) ;
852
- Assert . Equal ( 2 , psbt2 . PSBT . Outputs . Where ( o => o . HDKeyPaths . Any ( ) ) . Count ( ) ) ;
853
- Assert . Single ( psbt2 . PSBT . Outputs , o => o . HDKeyPaths . Any ( h => h . Value . KeyPath == newAddress . KeyPath ) ) ;
857
+
858
+ AssertHasOutput ( type , newAddress . KeyPath , psbt2 ) ;
854
859
foreach ( var input in psbt2 . PSBT . GetGlobalTransaction ( ) . Inputs )
855
860
{
856
861
Assert . Equal ( Sequence . Final , input . Sequence ) ;
@@ -914,8 +919,9 @@ private static void CanCreatePSBTCore(ServerTester tester, ScriptPubKeyType type
914
919
Assert . Equal ( new KeyPath ( "49'/0'" ) , globalXPub . KeyPath ) ;
915
920
916
921
Assert . Equal ( 3 , psbt2 . PSBT . Outputs . Count ) ;
917
- Assert . Equal ( 2 , psbt2 . PSBT . Outputs . Where ( o => o . HDKeyPaths . Any ( ) ) . Count ( ) ) ;
918
- var selfchange = Assert . Single ( psbt2 . PSBT . Outputs , o => o . HDKeyPaths . Any ( h => h . Key . GetAddress ( type , tester . Network ) . ScriptPubKey == newAddress . ScriptPubKey ) ) ;
922
+
923
+ var selfchange = AssertHasOutput ( type , new KeyPath ( "49'/0'" ) . Derive ( newAddress . KeyPath ) , psbt2 ) ;
924
+
919
925
Assert . All ( psbt2 . PSBT . Inputs . Concat < PSBTCoin > ( new [ ] { selfchange } ) . SelectMany ( i => i . HDKeyPaths ) , i =>
920
926
{
921
927
Assert . Equal ( rootHD , i . Value . MasterFingerprint ) ;
@@ -1022,6 +1028,20 @@ private static void CanCreatePSBTCore(ServerTester tester, ScriptPubKeyType type
1022
1028
}
1023
1029
}
1024
1030
1031
+ private static PSBTOutput AssertHasOutput ( ScriptPubKeyType type , KeyPath keyPath , CreatePSBTResponse psbt2 )
1032
+ {
1033
+ if ( type == ScriptPubKeyType . TaprootBIP86 )
1034
+ {
1035
+ Assert . Equal ( 2 , psbt2 . PSBT . Outputs . Where ( o => o . HDTaprootKeyPaths . Any ( ) ) . Count ( ) ) ;
1036
+ return Assert . Single ( psbt2 . PSBT . Outputs , o => o . HDTaprootKeyPaths . Any ( h => h . Value . RootedKeyPath . KeyPath == keyPath ) ) ;
1037
+ }
1038
+ else
1039
+ {
1040
+ Assert . Equal ( 2 , psbt2 . PSBT . Outputs . Where ( o => o . HDKeyPaths . Any ( ) ) . Count ( ) ) ;
1041
+ return Assert . Single ( psbt2 . PSBT . Outputs , o => o . HDKeyPaths . Any ( h => h . Value . KeyPath == keyPath ) ) ;
1042
+ }
1043
+ }
1044
+
1025
1045
[ TheoryWithTimeout ]
1026
1046
[ InlineData ( true ) ]
1027
1047
[ InlineData ( false ) ]
@@ -2563,16 +2583,6 @@ public async Task CanTrackAddress()
2563
2583
}
2564
2584
}
2565
2585
2566
- [ Fact ]
2567
- public async Task Test ( )
2568
- {
2569
- var rpc = new RPCClient ( new RPCCredentialString ( )
2570
- {
2571
- UserPassword = new NetworkCredential ( "dashrpc" , "PQQgOzs1jN7q2SWQ6TpBNLm9j" ) ,
2572
- } , "https://dash-testnet.nodes.m3t4c0.xyz" , AltNetworkSets . Dash . Testnet ) ;
2573
- var b1 = await rpc . GetBlockAsync ( new uint256 ( "000001f02c1623e0bb12b54ac505cefdfca3f0f664bf333fc73ae5eafe34b830" ) ) ;
2574
- }
2575
-
2576
2586
[ FactWithTimeout ]
2577
2587
public async Task CanTrack2 ( )
2578
2588
{
0 commit comments