From 0757faad29d1885c576aa75841d4dea8ab22ac5e Mon Sep 17 00:00:00 2001 From: JHB <16675200+jharveyb@users.noreply.github.com> Date: Fri, 24 Jul 2026 18:47:42 -0400 Subject: [PATCH 1/2] bitcoind: fix raw TX fetching when using REST --- src/chain/bitcoind.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/chain/bitcoind.rs b/src/chain/bitcoind.rs index f857ef533..615d1945a 100644 --- a/src/chain/bitcoind.rs +++ b/src/chain/bitcoind.rs @@ -1354,9 +1354,12 @@ pub(crate) struct GetRawTransactionResponse(pub Transaction); impl TryInto for JsonResponse { type Error = String; fn try_into(self) -> Result { + // Accept both the bare hex-encoded TX from RPC, and the REST response + // of a JSON object with the hex-encoded TX in the 'hex' field. let tx = self .0 .as_str() + .or_else(|| self.0.get("hex").and_then(|v| v.as_str())) .ok_or("Failed to parse getrawtransaction response".to_string()) .and_then(|s| { bitcoin::consensus::encode::deserialize_hex(s) @@ -1640,6 +1643,26 @@ mod tests { prop_assert_eq!(decoded.0, tx); } + #[test] + fn prop_get_raw_transaction_response_json_object_roundtrip(tx in arbitrary_transaction()) { + let hex = bitcoin::consensus::encode::serialize_hex(&tx); + let vsize = tx.vsize(); + let json_val = json!({ + "version": tx.version, + "vsize": vsize, + "hex": hex, + }); + + let resp = JsonResponse(json_val); + let decoded: GetRawTransactionResponse = resp.try_into().unwrap(); + + prop_assert_eq!(decoded.0.compute_txid(), tx.compute_txid()); + prop_assert_eq!(decoded.0.compute_wtxid(), tx.compute_wtxid()); + + prop_assert_eq!(decoded.0, tx); + } + + #[test] fn prop_fee_response_roundtrip(fee_rate in any::()) { let fee_rate = fee_rate.abs(); From b9e07a6db0c5d8a3c0cf6ebaa65a317dd0d10977 Mon Sep 17 00:00:00 2001 From: JHB <16675200+jharveyb@users.noreply.github.com> Date: Tue, 28 Jul 2026 13:41:40 -0400 Subject: [PATCH 2/2] tests: support selecting bitcoind REST as a chain source --- tests/common/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 50e2b993c..5422a3944 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -330,7 +330,7 @@ pub(crate) fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) { pub(crate) fn random_chain_source<'a>( bitcoind: &'a BitcoinD, electrsd: &'a ElectrsD, ) -> TestChainSource<'a> { - let r = rand::random_range(0..3); + let r = rand::random_range(0..4); match r { 0 => { println!("Randomly setting up Esplora chain syncing...");