Bitcoin Forum
November 09, 2024, 08:01:38 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get information about a transaction (bitcoin qt rpc)  (Read 2320 times)
Mcoroklo (OP)
Jr. Member
*
Offline Offline

Activity: 77
Merit: 1


View Profile WWW
June 20, 2013, 08:45:39 PM
 #1

I am a newbie when it comes to Bitcoin qt, so the question might show that :-)

I am iterating blocks in the blockchain, and builds up a list of transactions. I do this by reading the JSON response of a block:

var transactions = response["result"]["tx"];

So a tx example is:
4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b

Now I want to find information about this transaction (how many Bitcoins was transfered).

I am trying to call the "gettransaction" function with the tx above as a parameter.. However I get a "Invalid or non-wallet transaction id (code -5)".

So I guess there is something very obvious I've missed? :-) Any guesses?


DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4832



View Profile
June 20, 2013, 11:24:05 PM
 #2

That looks like the transactionID of the genesis transaction.  I'm not sure, but I don't think the Bitcoin-Qt wallet allows you to get that transaction. Have you tried with other transactionID and had the same issue?
Mcoroklo (OP)
Jr. Member
*
Offline Offline

Activity: 77
Merit: 1


View Profile WWW
June 21, 2013, 06:18:39 AM
 #3

Danny:
Unfortunately, yes. Should it be working by the TX-id like i've described? 
Mcoroklo (OP)
Jr. Member
*
Offline Offline

Activity: 77
Merit: 1


View Profile WWW
June 21, 2013, 04:18:29 PM
 #4

Ok, my experience:
I cannot get transactions OUTSIDE my wallet... Any ideas how to do that?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4832



View Profile
June 21, 2013, 04:25:43 PM
 #5

I think you need to use getrawtransaction to get transactions that are not to or from addresses in your wallet.dat.

See here (emphasis added by me):

- snip -
in version 0.6.3 and earlier, gettransaction would only return information about transactions in your wallet, and would not return all of the information about the transaction.

A month or two ago Pieter and Luke wrote code to modify gettransaction/getblock to return information about any transaction in the blockchain
- snip -

- snip -
"get any transaction, even transactions that aren't in your wallet" functionality will be moved from gettransaction to a new 'getrawtransaction' API call
- snip -
Mcoroklo (OP)
Jr. Member
*
Offline Offline

Activity: 77
Merit: 1


View Profile WWW
June 21, 2013, 04:39:27 PM
 #6

I can use the getrawtransaction and get a response. My result for the 2nd transaction made:

01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec1 1600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf6 21e73a82cbf2342c858eeac00000000

How would I go around and convert that to useful information? :-) There might be some relevant method, but I have been looking for some time now.

(Thanks A LOT for helping by the way)
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4832



View Profile
June 21, 2013, 05:11:42 PM
 #7

Try decoderawtransaction.

https://en.bitcoin.it/wiki/Raw_Transactions

Quote
getrawtransaction <txid> [verbose=0]
If verbose=0, returns serialized, hex-encoded data for transaction txid. If verbose is non-zero, returns a JSON Object containing information about the transaction. Returns an error if <txid> is unknown.

decoderawtransaction <hex string>
Returns JSON object with information about a serialized, hex-encoded transaction.
Mcoroklo (OP)
Jr. Member
*
Offline Offline

Activity: 77
Merit: 1


View Profile WWW
June 21, 2013, 08:01:37 PM
 #8

Great! Thanks so much - it worked :-)

I hope this will be found in Google and help people in the future!
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!