I'm trying to write software in Elixir to do it. I have the source code for BitcoinJ, but it's quite laborious figuring out what it does. If I look on bitcoin.info, I can see this block


has transactions including 2c1a83d5a511399f151571ff26925764ef73081251c239dd2eb6904304d7bcba

from which blockchain.info has deduced

1PSfpNCcY9uNh1QEitLLLGaDX5LicnBJhx sent 12 BTC to

3PK9abqzd2oK3yWgESSZ6Ps1wPBBu222VW and 0.0789 BTC to


I want to find out how it deduced it. Thanks for any information.

  • Happy to see that my answer helped :) If you could mark it as 'answered' that would be great! May 19 '18 at 14:09

Bitcoin transactions are serialized into a hex string that contains all the necessary information to execute the transaction such as input and output values and origin and destination addresses. Blockchain.info decodes transaction hex strings to show this information.'

We can take the transaction you listed as an example and decode it:

Starting with the transaction hash: 2c1a83d5a511399f151571ff26925764ef73081251c239dd2eb6904304d7bcba

We get the hex string using blockchain.info's api:


Which gives us the hex:


Almost all bitcoin libraries (in whatever language) have functions to decode hex strings. Here's an online service that lets you decode the hex:


Pasting the hex from above will give you information about the transaction.

  • Happy to see that my answer helped :) If you could mark it as 'answered' that would be great! May 19 '18 at 14:09
  • Um - how do you mark it as 'answered'? May 21 '18 at 13:45
  • There should be a tick/check that you can press on the left hand side of my answer :) May 21 '18 at 16:19

I'd like to just add to the answer above. I'm writing a Phoenix/Elixir app. I found that I can do all of the above using Blockchain RPC commands.


      def getrawtransaction( trans ), do: bitcoin_rpc( "getrawtransaction", [trans] )

      def decoderawtransaction( hex ), do: bitcoin_rpc( "decoderawtransaction", [hex] )


transaction is a string like this: "79895513e10d92fee5be47ec11c02bb29078ee0f7f3ca29e16afe113ff94c3d3"

      def mark_up_transaction( transaction ) do
        result = get_transaction( transaction )
        case elem( result, 0 ) do
          :ok -> Poison.encode!( elem( result, 1 ), pretty: true )
          :error -> Poison.encode!( String.downcase( elem( result, 1 )[ "message" ] ), pretty: true )
          _ -> Poison.encode!( "unknown error", pretty: true )

      defp get_hex( transaction ) do
        result = Blockchain.getrawtransaction transaction
        case result do
          {:ok, hex } -> hex
          {:invalid, {:ok, hex }} -> hex # Why it does this I don't know, but it did
          {_, {:ok, hex }} -> hex
          _ -> nil

      defp get_transaction( transaction ) do
        hex = get_hex transaction
        Blockchain.decoderawtransaction( hex )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.