Skip to content

Commit e0d928c

Browse files
committed
Test walletprocesspsbt
The RPC was implemented for v17 but has a return change in v26 and is untested. Update the struct in v26. Add a test and update the types table.
1 parent 9c491d9 commit e0d928c

File tree

20 files changed

+125
-23
lines changed

20 files changed

+125
-23
lines changed

client/src/client_sync/v17/wallet.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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
};

integration_test/tests/wallet.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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]
10131036
fn wallet__wallet_lock() {
10141037
let node = Node::with_wallet(Wallet::Default, &[]);

types/src/model/wallet.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

types/src/v17/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
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
//!

types/src/v17/wallet/into.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

types/src/v18/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
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
//!

types/src/v19/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
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
//!

types/src/v20/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
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
//!

types/src/v21/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
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
//!

types/src/v22/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
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
//!

0 commit comments

Comments
 (0)