Skip to content

Commit 523268e

Browse files
committed
Minimalist fix for genesis tx error
1 parent 4d1fdaf commit 523268e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/daemon.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,32 @@ impl Daemon {
606606
blockhash: &BlockHash,
607607
verbose: bool,
608608
) -> Result<Value> {
609-
self.request(
609+
match self.request(
610610
"getrawtransaction",
611611
json!([txid.to_hex(), verbose, blockhash]),
612-
)
612+
) {
613+
#[cfg(not(feature = "liquid"))]
614+
Err(e)
615+
if e.to_string().contains(
616+
"genesis block coinbase is not considered an ordinary transaction",
617+
) =>
618+
{
619+
let block = self.getblock(blockhash)?;
620+
621+
// Assert that there's only 1 tx, the previous block hash is all zeroes, and not using verbose
622+
if verbose
623+
|| block.txdata.len() != 1
624+
|| block.header.prev_blockhash != BlockHash::default()
625+
{
626+
Err(e)
627+
} else {
628+
Ok(Value::String(bitcoin::consensus::encode::serialize_hex(
629+
&block.txdata[0],
630+
)))
631+
}
632+
}
633+
res => res,
634+
}
613635
}
614636

615637
pub fn getmempooltx(&self, txhash: &Txid) -> Result<Transaction> {

0 commit comments

Comments
 (0)