Bitcoin Forum
May 22, 2024, 08:53:00 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Getting tx data from tx hash, and getting all unconfirmd txs (mempool) from API?  (Read 705 times)
Kazimir (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1003



View Profile
July 07, 2015, 12:57:05 PM
 #1

I'm looking for two functionalities in particular. Is there a Bitcoin web API (like blocktrail, blockcypher, etc) that lets me:

1. Get a tx's complete data (hex) from its hash? Especially for unconfirmed txs, but preferably for any tx.

2. Get a list of all unconfirmed txs currently in mempool? (obviously this would vary somewhat from node to node)

Haven't been able to find these functions in any online API yet, or am I misunderstanding the documentation?

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
Coef
Hero Member
*****
Offline Offline

Activity: 882
Merit: 1000


Exhausted


View Profile
July 07, 2015, 01:10:11 PM
 #2

For part 1: You could use Blockr API to get the hex raw transaction.

Check https://btc.blockr.io/documentation/api for the details.

Quote
Raw transaction data

Returns raw transaction data in the bitcoin format.
http://btc.blockr.io/api/v1/tx/raw/60c1f1a3160042152114e2bba45600a5045711c3a8a458016248acec59653471
will return raw data for a given transaction.

Kazimir (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1003



View Profile
July 07, 2015, 01:31:29 PM
 #3

Nice, I missed that. Thanks!

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
halftimepad
Newbie
*
Offline Offline

Activity: 20
Merit: 1


View Profile
July 07, 2015, 09:19:38 PM
 #4

If you use bitcoin-qt you can use the command line.

https://en.bitcoin.it/wiki/Running_Bitcoin#Command-line_arguments

Most clients have a version. With the interface you can find the console under ->Help. You can also launch a server:
bitcoind -server
and then use bitcoin-cli

The commands you want are:

bitcoin-cli getrawtransaction  HASH
(gets hexadecimal byte sequence in hexadecimal)
bitcoin-cli getrawtransaction  HASH 1
(gets the JSON-parsed version)

bitcoin-cli getrawmempool
(gives the mempool at your local node)

If you access the console from bitcoin-qt, drop bitcoin-cli.

You can also find an online mempool explorer in:

http://webbtc.com/mempool
Kazimir (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1003



View Profile
July 10, 2015, 07:17:39 AM
 #5

If you use bitcoin-qt you can use the command line.
Yes, I understand, but I'm typically using APIs in situations where I don't have (or want to) access one of my full nodes.

Besides, even with running your own Bitcoin-QT, you generally can't retrieve stats for any address, just your own wallet.

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
Coef
Hero Member
*****
Offline Offline

Activity: 882
Merit: 1000


Exhausted


View Profile
July 11, 2015, 07:06:49 PM
 #6

If you use bitcoin-qt you can use the command line.
Yes, I understand, but I'm typically using APIs in situations where I don't have (or want to) access one of my full nodes.

Besides, even with running your own Bitcoin-QT, you generally can't retrieve stats for any address, just your own wallet.

Regarding the last line in your post, you can run your bitcoin core with -txindex (you may also need to run it with -reindex but I am not 100% sure) and it will build a tx index for all the transactions.
You will be able to use getrawtransaction on any transactions then.

FYR: https://en.bitcoin.it/wiki/Running_Bitcoin#Command-line_arguments

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!