Minimalist fix for genesis tx error

This commit is contained in:
junderw 2025-04-16 19:03:30 +09:00
parent 4d1fdaf7b4
commit 523268e9a3
No known key found for this signature in database
GPG Key ID: B256185D3A971908

View File

@ -606,10 +606,32 @@ impl Daemon {
blockhash: &BlockHash,
verbose: bool,
) -> Result<Value> {
self.request(
match self.request(
"getrawtransaction",
json!([txid.to_hex(), verbose, blockhash]),
)
) {
#[cfg(not(feature = "liquid"))]
Err(e)
if e.to_string().contains(
"genesis block coinbase is not considered an ordinary transaction",
) =>
{
let block = self.getblock(blockhash)?;
// Assert that there's only 1 tx, the previous block hash is all zeroes, and not using verbose
if verbose
|| block.txdata.len() != 1
|| block.header.prev_blockhash != BlockHash::default()
{
Err(e)
} else {
Ok(Value::String(bitcoin::consensus::encode::serialize_hex(
&block.txdata[0],
)))
}
}
res => res,
}
}
pub fn getmempooltx(&self, txhash: &Txid) -> Result<Transaction> {