From ffab4f4efa74efa3b1a175d49840e1e09f95896c Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 24 Aug 2021 23:30:45 +0300 Subject: [PATCH] Fix incorrect JSON response for 'blockchain.transaction.get' RPC Daemon::get_transaction_hex should return a string, not a dictionary. --- src/daemon.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/daemon.rs b/src/daemon.rs index 45d32aa9c..d7a5ef868 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -1,6 +1,8 @@ use anyhow::{Context, Result}; -use bitcoin::{Amount, Block, BlockHash, Transaction, Txid}; +use bitcoin::{ + consensus::serialize, hashes::hex::ToHex, Amount, Block, BlockHash, Transaction, Txid, +}; use bitcoincore_rpc::{self, json, RpcApi}; use parking_lot::Mutex; use serde_json::{json, Value}; @@ -144,10 +146,9 @@ impl Daemon { &self, txid: &Txid, blockhash: Option, - ) -> Result { - self.rpc - .get_raw_transaction_info(txid, blockhash.as_ref()) - .context("failed to get transaction info") + ) -> Result { + let tx = self.get_transaction(txid, blockhash)?; + Ok(json!(serialize(&tx).to_hex())) } pub(crate) fn get_transaction(