Title: How to get information about a transaction (bitcoin qt rpc) Post by: Mcoroklo on June 20, 2013, 08:45:39 PM 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? Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: DannyHamilton on June 20, 2013, 11:24:05 PM 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?
Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: Mcoroklo on June 21, 2013, 06:18:39 AM Danny:
Unfortunately, yes. Should it be working by the TX-id like i've described? Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: Mcoroklo on June 21, 2013, 04:18:29 PM Ok, my experience:
I cannot get transactions OUTSIDE my wallet... Any ideas how to do that? Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: DannyHamilton on June 21, 2013, 04:25:43 PM 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 - Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: Mcoroklo on June 21, 2013, 04:39:27 PM 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) Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: DannyHamilton on June 21, 2013, 05:11:42 PM 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. Title: Re: How to get information about a transaction (bitcoin qt rpc) Post by: Mcoroklo on June 21, 2013, 08:01:37 PM Great! Thanks so much - it worked :-)
I hope this will be found in Google and help people in the future! |