diff --git a/lib/zcash_explorer_web/controllers/transaction_controller.ex b/lib/zcash_explorer_web/controllers/transaction_controller.ex index 186ec6e..ca7cddb 100644 --- a/lib/zcash_explorer_web/controllers/transaction_controller.ex +++ b/lib/zcash_explorer_web/controllers/transaction_controller.ex @@ -6,4 +6,13 @@ defmodule ZcashExplorerWeb.TransactionController do tx_data = Zcashex.Transaction.from_map(tx) render(conn, "tx.html", tx: tx_data, page_title: "Zcash Transaction #{txid}") end + + def get_raw_transaction(conn, %{"txid" => txid}) do + {:ok, tx} = Zcashex.getrawtransaction(txid, 1) + data = Poison.encode!(tx, pretty: true) + + conn + |> put_resp_content_type("application/json") + |> send_resp(200, data) + end end diff --git a/lib/zcash_explorer_web/router.ex b/lib/zcash_explorer_web/router.ex index 6fc4cfc..6467a68 100644 --- a/lib/zcash_explorer_web/router.ex +++ b/lib/zcash_explorer_web/router.ex @@ -53,6 +53,7 @@ defmodule ZcashExplorerWeb.Router do pipe_through :api get "/api/v1/blockchain-info", PageController, :blockchain_info_api post "/api/vk/:hostname", PageController, :vk_from_zecwalletcli + get "/transactions/:txid/raw", TransactionController, :get_raw_transaction end # Other scopes may use custom stacks. diff --git a/lib/zcash_explorer_web/templates/transaction/tx.html.heex b/lib/zcash_explorer_web/templates/transaction/tx.html.heex index 20d8615..7ca685a 100644 --- a/lib/zcash_explorer_web/templates/transaction/tx.html.heex +++ b/lib/zcash_explorer_web/templates/transaction/tx.html.heex @@ -197,6 +197,19 @@ +
+
+ Raw TX +
+
+ + + JSON + + + +
+