Get non-wallet transactions using bitcoin rpc (gettransaction) I am playing around with Bitcoin-qt. I want to iterate all blocks and all their transactions.

So far I've been able to get a list of all tx's in the blocks I want to. Now I want to get information about the transaction: Amount, confirmations and so forth.

However, when I use the gettransaction method of the Bitcoin-qt API, it seems I can only get transactions from my own wallet.

For instance, I cannot say, because I get the error "Invalid or non-wallet transaction id (code -5) ":

gettransaction 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098


However, when I have a TX of one of my own transactions, I get a correct response.

My code

public void AddBtcTransaction(string hash)
        {
            List&lt;string&gt; parameters = new List&lt;string&gt;();
            parameters.Add(hash);

            var data = RequestServer("gettransaction", parameters);
            int i = 0;
        }

        public string RequestServer(string methodName, List&lt;string&gt; parameters)
        {
            string respVal = string.Empty;

            var rawRequest = GetRawRequest();
            JObject joe = new JObject();
            joe.Add(new JProperty("jsonrpc", "1.0"));
            joe.Add(new JProperty("id", "1"));
            joe.Add(new JProperty("method", methodName));

            JArray props = new JArray();
            foreach (var parameter in parameters)
            {
                props.Add(parameter);
            }

            joe.Add(new JProperty("params", props));

            // serialize json for the request
            string s = JsonConvert.SerializeObject(joe);
            byte[] byteArray = Encoding.UTF8.GetBytes(s);
            rawRequest.ContentLength = byteArray.Length;
            Stream dataStream = rawRequest.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            StreamReader streamReader = null;
            try
            {
                WebResponse webResponse = rawRequest.GetResponse();

                streamReader = new StreamReader(webResponse.GetResponseStream(), true);

                respVal = streamReader.ReadToEnd();
                var data = JsonConvert.DeserializeObject(respVal).ToString();
                return data;
            }
            catch (Exception exp)
            {

            }
            finally
            {
                if (streamReader != null)
                {
                    streamReader.Close();        
                }

            }
            return string.Empty;
        }

        private HttpWebRequest GetRawRequest()
        {

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(ServerIp);
            webRequest.Credentials = new NetworkCredential(UserName, Password);
            /// important, otherwise the service can't desirialse your request properly
            webRequest.ContentType = "application/json-rpc";
            webRequest.Method = "POST";

            return webRequest;
        }


Any idea about how I would get information about transactions outside my wallet?
Enable txindex=1 in your bitcoin.conf (You'll need to rebuild the database as the transaction index is normally not maintained, start using -reindex to do so), and use the getrawtransaction call to request information about any transaction (it won't work for the genesis block's coinbase transaction though, it's a special case).

Note that this will only give you raw transaction data (you can add a 1 argument after the call to have it decoded instead of in hexadecimal notation), but it cannot know the payment amount or fees, for example.