Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: btctousd81 on July 29, 2017, 05:55:41 PM



Title: is there a way i can get getRawTransaction without querying bitcoind/bitcoin-cli
Post by: btctousd81 on July 29, 2017, 05:55:41 PM
hi, i am trying to understand how does the bitcoind works.,

lets say if i have tx_hex ,

can i get the getRawTransaction from tx_hex , without querying the bitcoind/bitcoin-cli ?

i mean just by decoding ?

or tx_hex a key, and value is stored in the data directory of bitcoin ?

more like

key => value pair

where tx_hex is key and hextransaction is stored on disk ?

thanks for your time.


Title: Re: is there a way i can get getRawTransaction without querying bitcoind/bitcoin-cli
Post by: achow101 on July 29, 2017, 07:07:10 PM
Your question is incredibly hard to understand.

What is "tx_hex"? Do you mean the hexstring of the raw transaction or the txid?

If you have a hexstring, you can use decoderawtransaction to decode the raw hex of a transaction.

or tx_hex a key, and value is stored in the data directory of bitcoin ?

more like

key => value pair

where tx_hex is key and hextransaction is stored on disk ?
No. That is completely incorrect. When you have ask for a transaction with getrawtransaction, you must have txindex enabled. The txindex means that Bitcoin Core's databases will have records with txids and the location of where the transaction data is stored in the blk*.dat files. When you request a transaction, it looks up the txid in the database and pulls it from the disk. Then it represents the binary data as a hex string.


Title: Re: is there a way i can get getRawTransaction without querying bitcoind/bitcoin-cli
Post by: btctousd81 on July 29, 2017, 07:18:31 PM
Your question is incredibly hard to understand.

What is "tx_hex"? Do you mean the hexstring of the raw transaction or the txid?

If you have a hexstring, you can use decoderawtransaction to decode the raw hex of a transaction.

or tx_hex a key, and value is stored in the data directory of bitcoin ?

more like

key => value pair

where tx_hex is key and hextransaction is stored on disk ?
No. That is completely incorrect. When you have ask for a transaction with getrawtransaction, you must have txindex enabled. The txindex means that Bitcoin Core's databases will have records with txids and the location of where the transaction data is stored in the blk*.dat files. When you request a transaction, it looks up the txid in the database and pulls it from the disk. Then it represents the binary data as a hex string.

sorry for confusion,
i meant txid.,

and looks like i got my answer.,
so there is db with
txid => txhex

and we can do
decoderawtransaction(tx_hex)
to get json data .

thanks ., this clears things up.

but i just checked i dont have
txindex=1
in my bitcoin configuration file ., but still i can do getrawtransaction .
how is that possible ?


Title: Re: is there a way i can get getRawTransaction without querying bitcoind/bitcoin-cli
Post by: btctousd81 on July 29, 2017, 07:34:44 PM
update: looks like it was in mempool

and found this answer https://bitcoin.stackexchange.com/questions/35707/what-are-pros-and-cons-of-txindex-option

Quote
By default -txindex=0 Bitcoin Core doesn't maintain any transaction-level data except for those

in the mempool or relay set
pertinent to addresses in your wallet
pertinent to your "watch-only" addresses


damn i am learning something new every day.
thanks