Skip to content

Commit cc1814b

Browse files
committed
Merge #257: Add joinpsbt command
b1e329c add joinpsbt (thesimplekid) Pull request description: ACKs for top commit: apoelstra: ACK b1e329c Tree-SHA512: ada2e72d9decf1a7acf6a6139bfaef9109474baf8d6e90c572cdd66e3eebd9d76261f3134f71d1ba8fed80a81acae8435657fc363e5df655038b163ad8186466
2 parents bde02d7 + b1e329c commit cc1814b

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

client/src/client.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,10 @@ pub trait RpcApi: Sized {
11031103
self.call("getdescriptorinfo", &[desc.to_string().into()])
11041104
}
11051105

1106+
fn join_psbt(&self, psbts: &[String]) -> Result<String> {
1107+
self.call("joinpsbts", &[into_json(psbts)?])
1108+
}
1109+
11061110
fn combine_psbt(&self, psbts: &[String]) -> Result<String> {
11071111
self.call("combinepsbt", &[into_json(psbts)?])
11081112
}

integration_test/src/main.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use bitcoin::hashes::hex::{FromHex, ToHex};
2525
use bitcoin::hashes::Hash;
2626
use bitcoin::secp256k1;
2727
use 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
};
3131
use 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+
785820
fn test_combine_psbt(cl: &Client) {
786821
let options = json::ListUnspentQueryOptions {
787822
minimum_amount: Some(btc(2)),

0 commit comments

Comments
 (0)