File tree Expand file tree Collapse file tree 20 files changed +125
-23
lines changed
client/src/client_sync/v17 Expand file tree Collapse file tree 20 files changed +125
-23
lines changed Original file line number Diff line number Diff line change @@ -765,7 +765,11 @@ macro_rules! impl_client_v17__wallet_process_psbt {
765765 ( ) => {
766766 impl Client {
767767 pub fn wallet_process_psbt( & self , psbt: & bitcoin:: Psbt ) -> Result <WalletProcessPsbt > {
768- self . call( "walletprocesspsbt" , & [ into_json( psbt) ?] )
768+ // Core expects the PSBT as a base64 string argument (same representation
769+ // used by `finalizepsbt`). Serializing the struct with `into_json` produced
770+ // an object which Core rejected ("Expected type string, got object").
771+ let psbt = format!( "{}" , psbt) ;
772+ self . call( "walletprocesspsbt" , & [ psbt. into( ) ] )
769773 }
770774 }
771775 } ;
Original file line number Diff line number Diff line change @@ -1009,6 +1009,29 @@ fn wallet__wallet_create_funded_psbt__modelled() {
10091009 assert ! ( !psbt. psbt. inputs. is_empty( ) ) ;
10101010}
10111011
1012+ #[ test]
1013+ fn wallet__wallet_process_psbt__modelled ( ) {
1014+ let node = Node :: with_wallet ( Wallet :: Default , & [ ] ) ;
1015+ node. fund_wallet ( ) ;
1016+
1017+ let addr = node. client . new_address ( ) . expect ( "newaddress" ) ;
1018+ let outputs = BTreeMap :: from ( [ ( addr, Amount :: from_sat ( 50_000 ) ) ] ) ;
1019+ let funded_psbt: WalletCreateFundedPsbt = node
1020+ . client
1021+ . wallet_create_funded_psbt ( vec ! [ ] , vec ! [ outputs] )
1022+ . expect ( "walletcreatefundedpsbt" ) ;
1023+ let funded_psbt_model: mtype:: WalletCreateFundedPsbt = funded_psbt. into_model ( ) . unwrap ( ) ;
1024+
1025+ let json: WalletProcessPsbt = node
1026+ . client
1027+ . wallet_process_psbt ( & funded_psbt_model. psbt )
1028+ . expect ( "walletprocesspsbt" ) ;
1029+ let model: Result < mtype:: WalletProcessPsbt , _ > = json. into_model ( ) ;
1030+ let processed = model. unwrap ( ) ;
1031+
1032+ assert_eq ! ( processed. psbt. inputs. len( ) , funded_psbt_model. psbt. inputs. len( ) ) ;
1033+ }
1034+
10121035#[ test]
10131036fn wallet__wallet_lock ( ) {
10141037 let node = Node :: with_wallet ( Wallet :: Default , & [ ] ) ;
Original file line number Diff line number Diff line change @@ -867,4 +867,6 @@ pub struct WalletProcessPsbt {
867867 pub psbt : Psbt ,
868868 /// If the transaction has a complete set of signatures.
869869 pub complete : bool ,
870+ /// The hex-encoded network transaction if complete.
871+ pub hex : Option < Transaction > ,
870872}
Original file line number Diff line number Diff line change 207207//! | walletlock | returns nothing | |
208208//! | walletpassphrase | returns nothing | |
209209//! | walletpassphrasechange | returns nothing | |
210- //! | walletprocesspsbt | version + model | UNTESTED |
210+ //! | walletprocesspsbt | version + model | |
211211//!
212212//! </details>
213213//!
Original file line number Diff line number Diff line change @@ -763,6 +763,10 @@ impl WalletProcessPsbt {
763763 /// Converts version specific type to a version nonspecific, more strongly typed type.
764764 pub fn into_model ( self ) -> Result < model:: WalletProcessPsbt , PsbtParseError > {
765765 let psbt = self . psbt . parse :: < Psbt > ( ) ?;
766- Ok ( model:: WalletProcessPsbt { psbt, complete : self . complete } )
766+ Ok ( model:: WalletProcessPsbt {
767+ psbt,
768+ complete : self . complete ,
769+ hex : None , // v26 and later only.
770+ } )
767771 }
768772}
Original file line number Diff line number Diff line change 209209//! | walletlock | returns nothing | |
210210//! | walletpassphrase | returns nothing | |
211211//! | walletpassphrasechange | returns nothing | |
212- //! | walletprocesspsbt | version + model | UNTESTED |
212+ //! | walletprocesspsbt | version + model | |
213213//!
214214//! </details>
215215//!
Original file line number Diff line number Diff line change 211211//! | walletlock | returns nothing | |
212212//! | walletpassphrase | returns nothing | |
213213//! | walletpassphrasechange | returns nothing | |
214- //! | walletprocesspsbt | version + model | UNTESTED |
214+ //! | walletprocesspsbt | version + model | |
215215//!
216216//! </details>
217217//!
Original file line number Diff line number Diff line change 212212//! | walletlock | returns nothing | |
213213//! | walletpassphrase | returns nothing | |
214214//! | walletpassphrasechange | returns nothing | |
215- //! | walletprocesspsbt | version + model | UNTESTED |
215+ //! | walletprocesspsbt | version + model | |
216216//!
217217//! </details>
218218//!
Original file line number Diff line number Diff line change 218218//! | walletlock | returns nothing | |
219219//! | walletpassphrase | returns nothing | |
220220//! | walletpassphrasechange | returns nothing | |
221- //! | walletprocesspsbt | version + model | UNTESTED |
221+ //! | walletprocesspsbt | version + model | |
222222//!
223223//! </details>
224224//!
Original file line number Diff line number Diff line change 229229//! | walletlock | returns nothing | |
230230//! | walletpassphrase | returns nothing | |
231231//! | walletpassphrasechange | returns nothing | |
232- //! | walletprocesspsbt | version + model | UNTESTED |
232+ //! | walletprocesspsbt | version + model | |
233233//!
234234//! </details>
235235//!
You can’t perform that action at this time.
0 commit comments