#!/bin/bash
#
# ____ _ _ _ ____ _
# | __ ) (_) | |_ ___ ___ (_) _ __ / ___| __ _ ___ | |__
# | _ \ | | | __| / __| / _ \ | | | '_ \ | | / _` | / __| | '_ \
# | |_) | | | | |_ | (__ | (_) | | | | | | | | |___ | (_| | \__ \ | | | |
# |____/ |_| \__| \___| \___/ |_| |_| |_| \____| \__,_| |___/ |_| |_|
#
# ___ _ _
# |_ _| _ __ __| | ___ _ __ ___ _ __ __| | ___ _ __ ___ ___
# | | | '_ \ / _` | / _ \ | '_ \ / _ \ | '_ \ / _` | / _ \ | '_ \ / __| / _ \
# | | | | | | | (_| | | __/ | |_) | | __/ | | | | | (_| | | __/ | | | | | (__ | __/
# |___| |_| |_| \__,_| \___| | .__/ \___| |_| |_| \__,_| \___| |_| |_| \___| \___|
# |_|
# ____ _ _
# | __ ) | | ___ ___ | | __
# | _ \ | | / _ \ / __| | |/ /
# | |_) | | | | (_) | | (__ | <
# |____/ |_| \___/ \___| |_|\_\
#
# The revolution will not be centralized!
#
# Bitcoin is the title of a whitepaper, name of the invention!
# Bitcoin cannot be uninvented, it will live on in this or that blockchain.
# The Bitcoin experiment became multi-threaded in 2017.
# Evolution of sound money is subject to free market forces.
# Humanity never settled on "the one" anything.
# Others will grow their own network effect.
# Others will age and benefit from the Lindy effect.
# Evolve and compete, or become irrelevant.
#
# What will it be, anon?
#
# - Bitcoin Core: a hub-to-hub electronic settlement system
# - Bitcoin Cash: a peer-to-peer electronic cash system
# - Bitcoin SV: a datacenter-to-datacenter electronic storage system
# - Bitcoin Ord: a collector-to-collector electronic art system
#
# Bitcoin Cash (BCH) is a code and blockchain fork of the first Bitcoin blockchain.
# Blocks 0 to 478558 are exactly the same on both blockchains.
# Block 478559 is the first block that differs.
# Bitcoin Cash block 478559 has a size of 1,915,175 bytes.
# It is here inscribed and labeled "Bitcoin Cash Independence Block".
#
# Until now, Bitcoin Cash has had 5.5 years of independence.
# During those years it did the following upgrades to consensus specification:
#
# - **2017** Malleability fixes
# - [Mandatory use of SCRIPT_VERIFY_STRICTENC](https://documentation.cash/protocol/forks/bch-uahf#req-6-4-mandatory-use-of-script_verify_strictenc)
# - [Enforcement of LOW_S signatures and NULLFAIL (BIP-0146)](https://documentation.cash/protocol/forks/hf-20171113#summary)
# - **2018**
# - [OP_CAT, OP_SPLIT, OP_AND, OP_OR, OP_XOR, OP_DIV, OP_MOD, OP_BIN2NUM, OP_NUM2BIN](https://documentation.cash/protocol/forks/may-2018-reenabled-opcodes)
# - [OP_CHECKDATASIG, OP_CHECKDATASIGVERIFY, and more malleabiliy fixes ("push only" and "clean stack" rules)](https://documentation.cash/protocol/forks/hf-20181115#summary). This made the precedent of allowing Script to "look" at other inputs & outputs in the same transaction, which enabled first covenants.
# - **2019**
# - [Schnorr signatures](https://documentation.cash/protocol/forks/hf-20190515#summary)
# - [Schnorr multisig, and more malleability fixes (minimal push and minimal number encoding)](https://documentation.cash/protocol/forks/hf-20191115#summary)
# - **2020**
# - [OP_REVERSEBYTES](https://documentation.cash/protocol/forks/hf-20200515#op_reversebytes)
# - **2021**
# - [Allow multiple OP_RETURNs](https://documentation.cash/protocol/forks/chips/2021-05-multiple-op-returns-for-bitcoin-cash)
# - **2022**
# - [SriptVM 64-byte integer support, enabled OP_MUL](https://documentation.cash/protocol/forks/chips/2022-05-bigger-script-integers#summary)
# - [Native introspection opcodes](https://documentation.cash/protocol/forks/chips/2022-05-native-introspection-opcodes): OP_INPUTINDEX, OP_ACTIVEBYTECODE, OP_TXVERSION, OP_TXINPUTCOUNT, OP_TXOUTPUTCOUNT, OP_TXLOCKTIME, OP_UTXOVALUE, OP_UTXOBYTECODE, OP_OUTPOINTTXHASH, OP_OUTPOINTINDEX, OP_INPUTBYTECODE, OP_INPUTSEQUENCENUMBER, OP_OUTPUTVALUE, OP_OUTPUTBYTECODE
# - **2023 (These upgrades will activate on MTP 1684152000 - May 15, 2023 12:00:00 UTC)**
# - [CashTokens](https://github.com/bitjson/cashtokens) - native consensus-enforced UTXO token primitives and ScriptVM opcodes (OP_UTXOTOKENCATEGORY, OP_UTXOTOKENCOMMITMENT, OP_UTXOTOKENAMOUNT, OP_OUTPUTTOKENCATEGORY, OP_OUTPUTTOKENCOMMITMENT, OP_OUTPUTTOKENAMOUNT) to integrate them with contracts
# - [P2SH32](https://gitlab.com/0353F40E/p2sh32/-/blob/main/CHIP-2022-05_Pay-to-Script-Hash-32_(P2SH32)_for_Bitcoin_Cash.md) - address the hash collision problem by enabling a 32-byte BIP-0016 output pattern
#
# With these L1 building blocks enabled, scalable UTXO DeFi on L1 Bitcoin-tech is becoming a reality!
#
# It's right there in the title: a peer-to-peer electronic **cash system**.
# Not just cash, a cash system. Cash is always exchanged for something: a good, a service, a promise.
# With native tokens, that something can be exchanged as trustlessly, uncensorably, securely, and cheaply as the cash!
#
# >I see Bitcoin as a foundation and first step if you want to implement
# >programmable P2P social currencies like Marc's ideas and others
# >discussed here. First you need normal, basic P2P currency working.
# >Once that is established and proven out, dynamic smart money is an easy
# >next step.
#
# -- [Satoshi Nakamoto](https://www.bitcoin.com/satoshi-archive/emails/p2p-research/3/#selection-25.6-25.37)
#
# How can it scale?
#
# - Unlike EVM, Bitcoin-tech UTXO blockchain model allows easy parallelization of transaction validation.
# - A single GPU can validate 60M signatures per second.
# - Pruned nodes don't need the entire history to stay in sync.
# - With consensus-enforced UTXO commitments, history won't be needed for initial blockchain download, either.
# - Currently 100MBit/s connection is widely accessible. That could sustain roughly 2000 TPS. At the same time, 10G Internet is coming.
# - Layer 2s possble. CashTokens smart contract primitives enable Drivechain-like sidechains, where a pool of mainchain BCH would be staked to secure the sidechain.
#
# Run me as Bash script to:
#
# 1. Save the above text as markdown into `independence.md` file.
# 2. Decode the start of Bitcoin Cash independence block and append its hash, header, and coinbase transaction to `independence.md`.
# 3. Download other parts and assemble the Bitcoin Cash independence block as `independence.bin` file.
#
# Usage: ./this-file
head -n 90 $0 | tail -n 89 | sed -e 's/^#\ //g' > independence.md
echo '```' >> independence.md
tail -n +117 $0 | grep -v -e '-.' | base64 --decode | dd bs=1 count=80 status=none | sha256sum | xxd -r -p | sha256sum | cut -b1-64 | tac -rs '..' >> independence.md; echo >> independence.md; echo >> independence.md
tail -n +117 $0 | grep -v -e '-.' | base64 --decode | dd bs=1 count=232 status=none | xxd >> independence.md
echo '```' >> independence.md
cat \
<(curl -s https://ordinals.com/preview/a31b8e3e279a6e28ef49fa4dca54f820abf266223976b778833e8c47991ad403i0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
<(curl -s https://ordinals.com/preview/9bb82d96abbef61854b3524f167371cc65d0bb9a089f716e6c1981014269dc02i0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
<(curl -s https://ordinals.com/preview/97e4fbe87d50eb3852b7814d470633926f735edf556a761c46b584e9617868d0i0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
<(curl -s https://ordinals.com/preview/8ae4f4b93d8e3bb4b53b8dd437d8d360930f0e9733f437d67d465daf2a57fdabi0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
<(curl -s https://ordinals.com/preview/2fd2b489f17e48907c76577300945d7a17f284421af2b4b198ed4fc9a8a3aa32i0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
<(curl -s https://ordinals.com/preview/a2ec351bf2c050e5d6b6a543940437d7e16c5568ba0a6052c051d1cc996b1e63i0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
<(curl -s https://ordinals.com/preview/8f40f7bed3d20bd7f8c226646be130beda9f19f52fe4c025b4f24e47553dfe04i0 | sed -n '/--BEGIN/,/--END/p' | grep -v -e '-B' | base64 --decode 2>/dev/null) \
> independence.bin
sha256sum -c <(echo 'cdcd863681ef0f8855b6738a83fb1ab6486439b4cec35322788fb1373d58b1eb independence.md')
sha256sum -c <(echo '453b68a7975938525b8eb02807740f8334534dae1344146862cc197aa0d99bab independence.bin')
exit
-----BEGIN BITCOIN CASH INDEPENDENCE BLOCK HEADER AND COINBASE-----
AAAAIEMtNQdB+/KPLhSG6r4sThQ7/iJBr2UYAQAAAAAAAAAAq6pL2KSMHGvAjuObZgZeXpSEMEyr
i1bV7tPkCxrJlsiZxIBZNUcBGCLKSuj9SRsBAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA/////0ADX00HKi9WaWFCVEMvV2VsY29tZSB0byB0aGUgd29ybGQsIFNodXlhIFlhbmch
LxBxAcsAlbnUM+GZ2M0wYwAA/////wFmq9BVAAAAABl2qRRTb/qZJJFQjcoDVOUvMqOnpnmlOois
AAAAAA==
-----END BITCOIN CASH INDEPENDENCE BLOCK HEADER AND COINBASE-----