Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAnybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
I'm trying to get the raw transaction hex string of a transaction that I know the id from.
I would like to do that without using txindex=1.
As I assume the transaction is unspent (and confirmed) I'm doing the following steps:
bitcoin-cli gettxout 'txid'
bitcoin-cli getblockcount
bitcoin-cli getblockhash 'blockcount - txout.confirmations + 1'
bitcoin-cli getrawtransaction 'txid' 0 'blockhash'
I have a race condition when getting the blockcount.
Is there a better way to do that?
To avoid a race condition with getblockcount
, you could use getblockheader
with the bestblock
result from gettxout
and get its height. Then do the height calculation with the number of confirmations to get the block hash to pass to getrawtransaction
.
You can get bonuses upto $100 FREE BONUS when you:
π° Install these recommended apps:
π² SocialGood - 100% Crypto Back on Everyday Shopping
π² xPortal - The DeFi For The Next Billion
π² CryptoTab Browser - Lightweight, fast, and ready to mine!
π° Register on these recommended exchanges:
π‘ Binanceπ‘ Bitfinexπ‘ Bitmartπ‘ Bittrexπ‘ Bitget
π‘ CoinExπ‘ Crypto.comπ‘ Gate.ioπ‘ Huobiπ‘ Kucoin.
Comments