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 {
765
765
( ) => {
766
766
impl Client {
767
767
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( ) ] )
769
773
}
770
774
}
771
775
} ;
Original file line number Diff line number Diff line change @@ -1009,6 +1009,29 @@ fn wallet__wallet_create_funded_psbt__modelled() {
1009
1009
assert ! ( !psbt. psbt. inputs. is_empty( ) ) ;
1010
1010
}
1011
1011
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
+
1012
1035
#[ test]
1013
1036
fn wallet__wallet_lock ( ) {
1014
1037
let node = Node :: with_wallet ( Wallet :: Default , & [ ] ) ;
Original file line number Diff line number Diff line change @@ -867,4 +867,6 @@ pub struct WalletProcessPsbt {
867
867
pub psbt : Psbt ,
868
868
/// If the transaction has a complete set of signatures.
869
869
pub complete : bool ,
870
+ /// The hex-encoded network transaction if complete.
871
+ pub hex : Option < Transaction > ,
870
872
}
Original file line number Diff line number Diff line change 207
207
//! | walletlock | returns nothing | |
208
208
//! | walletpassphrase | returns nothing | |
209
209
//! | walletpassphrasechange | returns nothing | |
210
- //! | walletprocesspsbt | version + model | UNTESTED |
210
+ //! | walletprocesspsbt | version + model | |
211
211
//!
212
212
//! </details>
213
213
//!
Original file line number Diff line number Diff line change @@ -763,6 +763,10 @@ impl WalletProcessPsbt {
763
763
/// Converts version specific type to a version nonspecific, more strongly typed type.
764
764
pub fn into_model ( self ) -> Result < model:: WalletProcessPsbt , PsbtParseError > {
765
765
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
+ } )
767
771
}
768
772
}
Original file line number Diff line number Diff line change 209
209
//! | walletlock | returns nothing | |
210
210
//! | walletpassphrase | returns nothing | |
211
211
//! | walletpassphrasechange | returns nothing | |
212
- //! | walletprocesspsbt | version + model | UNTESTED |
212
+ //! | walletprocesspsbt | version + model | |
213
213
//!
214
214
//! </details>
215
215
//!
Original file line number Diff line number Diff line change 211
211
//! | walletlock | returns nothing | |
212
212
//! | walletpassphrase | returns nothing | |
213
213
//! | walletpassphrasechange | returns nothing | |
214
- //! | walletprocesspsbt | version + model | UNTESTED |
214
+ //! | walletprocesspsbt | version + model | |
215
215
//!
216
216
//! </details>
217
217
//!
Original file line number Diff line number Diff line change 212
212
//! | walletlock | returns nothing | |
213
213
//! | walletpassphrase | returns nothing | |
214
214
//! | walletpassphrasechange | returns nothing | |
215
- //! | walletprocesspsbt | version + model | UNTESTED |
215
+ //! | walletprocesspsbt | version + model | |
216
216
//!
217
217
//! </details>
218
218
//!
Original file line number Diff line number Diff line change 218
218
//! | walletlock | returns nothing | |
219
219
//! | walletpassphrase | returns nothing | |
220
220
//! | walletpassphrasechange | returns nothing | |
221
- //! | walletprocesspsbt | version + model | UNTESTED |
221
+ //! | walletprocesspsbt | version + model | |
222
222
//!
223
223
//! </details>
224
224
//!
Original file line number Diff line number Diff line change 229
229
//! | walletlock | returns nothing | |
230
230
//! | walletpassphrase | returns nothing | |
231
231
//! | walletpassphrasechange | returns nothing | |
232
- //! | walletprocesspsbt | version + model | UNTESTED |
232
+ //! | walletprocesspsbt | version + model | |
233
233
//!
234
234
//! </details>
235
235
//!
You can’t perform that action at this time.
0 commit comments