Skip to content

Commit 4ff70e8

Browse files
committed
Merge #270: add combine raw transaction
7a8bec6 add combine raw transaction (thesimplekid) Pull request description: ACKs for top commit: apoelstra: ACK 7a8bec6 Tree-SHA512: 222b93c4df45f9b99aef89446a6400f601f8409f3b391a3f6ce87bbe713c204f34f7017e746c3631187b75c398ce1eaa9f46b433b2fd11700fd36ef37e9563af
2 parents 6c4cd8a + 7a8bec6 commit 4ff70e8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

client/src/client.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,10 @@ pub trait RpcApi: Sized {
11391139
self.call("combinepsbt", &[into_json(psbts)?])
11401140
}
11411141

1142+
fn combine_raw_transaction(&self, hex_strings: &[String]) -> Result<String> {
1143+
self.call("combinerawtransaction", &[into_json(hex_strings)?])
1144+
}
1145+
11421146
fn finalize_psbt(&self, psbt: &str, extract: Option<bool>) -> Result<json::FinalizePsbtResult> {
11431147
let mut args = [into_json(psbt)?, opt_into_json(extract)?];
11441148
self.call("finalizepsbt", handle_defaults(&mut args, &[true.into()]))

integration_test/src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ fn main() {
175175
test_wallet_process_psbt(&cl);
176176
test_join_psbt(&cl);
177177
test_combine_psbt(&cl);
178+
test_combine_raw_transaction(&cl);
178179
test_create_psbt(&cl);
179180
test_finalize_psbt(&cl);
180181
test_list_received_by_address(&cl);
@@ -849,6 +850,27 @@ fn test_combine_psbt(cl: &Client) {
849850
assert!(!psbt.is_empty());
850851
}
851852

853+
fn test_combine_raw_transaction(cl: &Client) {
854+
let options = json::ListUnspentQueryOptions {
855+
minimum_amount: Some(btc(2)),
856+
..Default::default()
857+
};
858+
let unspent = cl.list_unspent(Some(6), None, None, None, Some(options)).unwrap();
859+
let unspent = unspent.into_iter().nth(0).unwrap();
860+
let input = json::CreateRawTransactionInput {
861+
txid: unspent.txid,
862+
vout: unspent.vout,
863+
sequence: None,
864+
};
865+
let mut output = HashMap::new();
866+
output.insert(RANDOM_ADDRESS.to_string(), btc(1));
867+
let tx = cl.create_raw_transaction_hex(&[input.clone()], &output, Some(500_000), None).unwrap();
868+
869+
let transaction = cl.combine_raw_transaction(&[tx.clone(), tx]).unwrap();
870+
871+
assert!(!transaction.is_empty());
872+
}
873+
852874
fn test_create_psbt(cl: &Client) {
853875
let options = json::ListUnspentQueryOptions {
854876
minimum_amount: Some(btc(2)),

0 commit comments

Comments
 (0)