@@ -25,8 +25,8 @@ use bitcoin::hashes::hex::{FromHex, ToHex};
2525use bitcoin:: hashes:: Hash ;
2626use bitcoin:: secp256k1;
2727use bitcoin:: {
28- Address , Amount , PackedLockTime , Network , OutPoint , PrivateKey , Script , EcdsaSighashType , SignedAmount ,
29- Sequence , Transaction , TxIn , TxOut , Txid , Witness ,
28+ Address , Amount , EcdsaSighashType , Network , OutPoint , PackedLockTime , PrivateKey , Script ,
29+ Sequence , SignedAmount , Transaction , TxIn , TxOut , Txid , Witness ,
3030} ;
3131use bitcoincore_rpc:: bitcoincore_rpc_json:: {
3232 GetBlockTemplateModes , GetBlockTemplateRules , ScanTxOutRequest ,
@@ -172,6 +172,7 @@ fn main() {
172172 test_test_mempool_accept ( & cl) ;
173173 test_wallet_create_funded_psbt ( & cl) ;
174174 test_wallet_process_psbt ( & cl) ;
175+ test_join_psbt ( & cl) ;
175176 test_combine_psbt ( & cl) ;
176177 test_finalize_psbt ( & cl) ;
177178 test_list_received_by_address ( & cl) ;
@@ -782,6 +783,40 @@ fn test_wallet_process_psbt(cl: &Client) {
782783 assert ! ( res. complete) ;
783784}
784785
786+ fn test_join_psbt ( cl : & Client ) {
787+ let options = json:: ListUnspentQueryOptions {
788+ minimum_amount : Some ( btc ( 2 ) ) ,
789+ ..Default :: default ( )
790+ } ;
791+ let unspent = cl. list_unspent ( Some ( 6 ) , None , None , None , Some ( options) ) . unwrap ( ) ;
792+ let unspent1 = unspent[ 0 ] . clone ( ) ;
793+ let input = json:: CreateRawTransactionInput {
794+ txid : unspent1. txid ,
795+ vout : unspent1. vout ,
796+ sequence : None ,
797+ } ;
798+ let mut output = HashMap :: new ( ) ;
799+ output. insert ( RANDOM_ADDRESS . to_string ( ) , btc ( 1 ) ) ;
800+ let psbt1 = cl
801+ . wallet_create_funded_psbt ( & [ input. clone ( ) ] , & output, Some ( 500_000 ) , None , Some ( true ) )
802+ . unwrap ( ) ;
803+
804+ let unspent = unspent. into_iter ( ) . nth ( 1 ) . unwrap ( ) ;
805+ let input2 = json:: CreateRawTransactionInput {
806+ txid : unspent. txid ,
807+ vout : unspent. vout ,
808+ sequence : None ,
809+ } ;
810+ let mut output2 = HashMap :: new ( ) ;
811+ output2. insert ( RANDOM_ADDRESS . to_string ( ) , btc ( 1 ) ) ;
812+ let psbt2 = cl
813+ . wallet_create_funded_psbt ( & [ input2. clone ( ) ] , & output, Some ( 500_000 ) , None , Some ( true ) )
814+ . unwrap ( ) ;
815+
816+ let psbt = cl. join_psbt ( & [ psbt1. psbt , psbt2. psbt ] ) . unwrap ( ) ;
817+ assert ! ( !psbt. is_empty( ) ) ;
818+ }
819+
785820fn test_combine_psbt ( cl : & Client ) {
786821 let options = json:: ListUnspentQueryOptions {
787822 minimum_amount : Some ( btc ( 2 ) ) ,
0 commit comments