Skip to content

Commit

Permalink
Fix incorrect JSON response for 'blockchain.transaction.get' RPC
Browse files Browse the repository at this point in the history
Daemon::get_transaction_hex should return a string, not a dictionary.
  • Loading branch information
romanz committed Aug 24, 2021
1 parent c7eb0ba commit ffab4f4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/daemon.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -144,10 +146,9 @@ impl Daemon {
&self,
txid: &Txid,
blockhash: Option<BlockHash>,
) -> Result<json::GetRawTransactionResult> {
self.rpc
.get_raw_transaction_info(txid, blockhash.as_ref())
.context("failed to get transaction info")
) -> Result<Value> {
let tx = self.get_transaction(txid, blockhash)?;
Ok(json!(serialize(&tx).to_hex()))
}

pub(crate) fn get_transaction(
Expand Down

0 comments on commit ffab4f4

Please sign in to comment.