Add genesis coinbase transaction

This commit is contained in:
Mononaut 2022-04-25 15:56:38 -06:00
parent 34d991a998
commit 96a250d21c
2 changed files with 13 additions and 1 deletions

View File

@ -49,7 +49,7 @@ $: {
let confirmations = 0
$: {
if ($detailTx && $detailTx.block && $detailTx.block.height && $latestBlockHeight != null) {
if ($detailTx && $detailTx.block && $detailTx.block.height != null && $latestBlockHeight != null) {
confirmations = (1 + $latestBlockHeight - $detailTx.block.height)
}
}

View File

@ -113,6 +113,18 @@ defmodule BitcoinStream.Router do
{:ok, payload} <- Jason.encode(%{tx: inflated_txn, blockheight: height, blockhash: blockhash, time: time}) do
{:ok, payload}
else
{:ok, 500, nil} ->
# specially handle the genesis coinbase transaction
with true <- (txid == "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"),
rawtx <- Base.decode16!("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000", [case: :lower]),
{:ok, txn } <- BitcoinTx.decode(rawtx),
inflated_txn <- BitcoinTx.inflate(txn, false),
{:ok, payload} <- Jason.encode(%{tx: inflated_txn, blockheight: 0, blockhash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", time: 1231006505}) do
{:ok, payload}
else
_ -> :err
end
err ->
IO.inspect(err);
:err