"Bitcoin Holidays"

I'll clean this up later, but I wanted v1.0 live for my favorite Bitcoin Holiday on 5-22...

Show a banner on the homepage when "today" is a Bitcoin Holiday. Also show the full curated list at /holidays. This list began as an adaptation of the data on bitcoin.holiday.
This commit is contained in:
Dan Janosik 2022-05-21 23:53:53 -04:00
parent 7b2e1c55b9
commit 204f102ba2
No known key found for this signature in database
GPG key ID: 70C0B166321C0AF8
8 changed files with 221 additions and 3 deletions

View file

@ -6,7 +6,9 @@
* Homepage additions
* Show difficulty ATH comparison
* Show "Next Block" fullness
* Show a banner if 'today' is a Bitcoin 'Holiday' (see more below)
* Tweaks to API, see [/api/changelog](./api/changelog)
* New [/holidays](./holidays), a curated list of Bitcoin 'Holidays'
* Support for serving static assets via a configurable CDN
* Misc fixes for erroneous data display on non-mainnet nodes
* Switch from fontawesome to bootstrap-icons v1.8.0

26
app.js
View file

@ -90,6 +90,7 @@ const addressApi = require("./app/api/addressApi.js");
const electrumAddressApi = require("./app/api/electrumAddressApi.js");
const appStats = require("./app/appStats.js");
const btcQuotes = require("./app/coins/btcQuotes.js");
const btcHolidays = require("./app/coins/btcHolidays.js");
const auth = require('./app/auth.js');
const sso = require('./app/sso.js');
const markdown = require("markdown-it")();
@ -368,6 +369,29 @@ function loadHistoricalDataForChain(chain) {
}
}
function loadHolidays(chain) {
debugLog(`Loading holiday data`);
global.btcHolidays = btcHolidays;
global.btcHolidays.byDay = {};
global.btcHolidays.sortedDays = [];
global.btcHolidays.items.forEach(function(item) {
let day = item.date.substring(5);
if (!global.btcHolidays.sortedDays.includes(day)) {
global.btcHolidays.sortedDays.push(day);
global.btcHolidays.sortedDays.sort();
}
if (global.btcHolidays.byDay[day] == undefined) {
global.btcHolidays.byDay[day] = [];
}
global.btcHolidays.byDay[day].push(item);
});
}
function verifyRpcConnection() {
if (!global.activeBlockchain) {
debugLog(`Verifying RPC connection...`);
@ -453,6 +477,8 @@ async function onRpcConnectionVerified(getnetworkinfo, getblockchaininfo) {
// load historical/fun items for this chain
loadHistoricalDataForChain(global.activeBlockchain);
loadHolidays();
if (global.activeBlockchain == "main") {
loadDifficultyHistory(getblockchaininfo.blocks);

View file

@ -164,8 +164,8 @@ module.exports = {
chain: "main",
txid: "a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d",
blockHeight: 57043,
summary: "The 'Bitcoin Pizza' transaction.",
alertBodyHtml: "This is the famous 'Bitcoin Pizza' transaction, one of the earliest 'real-world' transactions, in which 10,000 BTC was paid for 2 large pizzas worth ~41 USD (at an effective exchange rate of ~$0.004/BTC).",
summary: "The \"Bitcoin Pizza\" transaction.",
alertBodyHtml: "This is the famous \"Bitcoin Pizza\" transaction, one of the earliest real-world transactions, in which 10,000 BTC was paid for 2 large pizzas worth ~41 USD (at an effective exchange rate of ~$0.004/BTC).",
referenceUrl: "https://bitcointalk.org/index.php?topic=137.0"
},
{

115
app/coins/btcHolidays.js Normal file
View file

@ -0,0 +1,115 @@
module.exports = {
desc: "A curated list of unofficial Bitcoin 'Holidays'. Adapted from https://bitcoin.holiday, and elsewhere.",
items: [
{
name: "Bitcoin Pizza Day",
date: "2010-05-22",
desc: "On this day in 2010, Lazlo Hanyecz, paid Jeremy Sturdivant 10,000 BTC for two pizzas costing ~41 USD. The famous <a href='./tx/a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d@57043'>\"Bitcoin Pizza\" transaction</a> was one of the earliest real-world BTC transactions and is celebrated as helping start the Bitcoin economy."
},
{
name: "Shitcoin Day",
date: "2013-07-03",
desc: "This day marks the beginning of the first ever \"utility token\" ICO, called Mastercoin (later rebranded as Omni)."
},
{
name: "SegWit Lock-In Day",
date: "2017-08-08",
desc: "Segregated Witness is officially locked in by the UASF client on the Bitcoin network."
},
{
name: "Bitcoin Infinity Day",
date: "2021-08-21",
desc: "8/21 is playfully celebrated as representing the meme \"Everything there is divided by 21,000,000\" (∞/21M)."
},
{
name: "SegWit Activation Day",
date: "2017-08-23",
desc: "On this day in 2017, at 1:57 UTC, SegWit activated on the Bitcoin mainnet in <a href='./block-height/481824'>Block #481,824</a>."
},
{
name: "Bitcoin Legal Tender Day",
date: "2021-09-07",
desc: "On this day in 2021, BTC became legal tender in El Salvador, 90 days after the publication of the law in the official gazette, making El Salvador the first country to enact BTC as legal tender through legistlation."
},
{
name: "Free Ross Day",
date: "2013-10-01",
desc: "On this day in 2013, Ross Ulbricht was captured and imprisoned for his role in creating The Silk Road website. He was given two life sentences for non-violent crimes. Fighting for Ross's freedom is a cause supported by many Bitcoiners."
},
{
name: "BearWhale Slay Day",
date: "2014-10-06",
desc: "On this day in 2014, a bitcoin whale posted a 30,000 BTC sell wall, resulting in an epic skirmish between hodlers and the BearWhale. Over the course of six hours, the price stalled at 300 USD until all of the coins sold off and the BearWhale was defeated. You can watch the battle <a href='https://twitter.com/DocumentingBTC/status/1364230687105167362?s=20The'>here</a>."
},
{
name: "This is Gentlemen! Day",
date: "2014-11-11",
desc: "On this day in 2014, an over-excited Reddit user accidentally omitted a word and unknowingly earned a bizarre place in Bitcoin culture and lore. Read the Reddit daily discussion on Bitcoin Markets <a href='https://www.reddit.com/r/BitcoinMarkets/comments/2lxkqk/daily_discussion_tuesday_november_11_2014/'>here</a>."
},
{
name: "HODL Day",
date: "2013-12-18",
desc: "On this day in 2013, a user on the bitcointalk.org declared <a href='https://bitcointalk.org/index.php?topic=375643.0'>I AM HODLING</a> (!), rather than selling, despite the falling price. This \"whisky\"-facilitated post spawned one of Bitcoin's great memes."
},
{
name: "Bitcoin's Birthday",
date: "2009-01-03",
desc: "On this day in 2009, the <a href='./block-height/0'>Genesis Block</a> was mined by Satoshi Nakamoto, officially starting the Bitcoin blockchain."
},
{
name: "Proof of Keys Day",
date: "2019-01-03",
desc: "On this day in 2019, to celebrate Bitcoin's 10th Birthday, Trace Mayer started an annual Proof-of-Keys Celebration. Participats declare monetary sovereignty by withdrawing their BTC into their own custory. Not your keys, not your bitcoin! You can read Trace Mayer's original tweet <a href='https://twitter.com/TraceMayer/status/1071870548421066753'>here</a>."
},
{
name: "Genesis Transaction Day",
date: "2009-01-11",
desc: "On this day in 2009, the first transaction ever broadcast over the Bitcoin network was sent by Satoshi Nakamoto to Hal Finney. View the genesis transaction <a href='./tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16@170'>here</a>."
},
{
name: "Lightning Pizza Day",
date: "2018-02-25",
desc: "Eight years after buying pizza with the famous <a href='./tx/a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d@57043'>\"Bitcoin Pizza\" transaction</a>, Lazlo Hanyecz returned to buy pizza over the Lightning Network."
},
{
name: "Mt. Gox Death Day",
date: "2013-02-24",
desc: "On this day in 2013, Mt. Gox, the largest Bitcoin exchange in the world, went offline due to insolvency, after losing 640,000 BTC."
},
{
name: "Gold Parity Day",
date: "2017-03-03",
desc: "On this day in 2017, 1 BTC surpassed the price of 1 ounce of gold for the first time."
},
{
name: "Billion Dollar Day",
date: "2013-03-28",
desc: "On this day in 2013, the market cap of all BTC surpassed 1 billion USD for the first time."
},
{
name: "Trillion Dollar Day",
date: "2021-02-19",
desc: "On this day in 2021, the market cap of all BTC surpassed 1 trillion USD for the first time, ~8 years after surpassing 1 billion USD for the first time."
},
{
name: "Bitcoin ATM Day",
date: "2013-05-02",
desc: "On this day in 2013, the first-ever Bitcoin ATM was installed at a Vancouver coffee shop. It included a built-in palm scanner designed to prevent users from processing more than 3,000 CAD per day."
},
{
name: "Bitcoin Whitepaper Day",
date: "2008-10-31",
desc: "On this day in 2008, Satoshi Nakamoto released the Bitcoin white paper to the cryptography mailing list, marking its official introduction into the world. Satoshi introduced Bitcoin as an electronic cash system with several important properties: double-spending prevention, no trusted parties, anonymous participation, and Hashcash style Proof-of-Work. The Bitcoin Whitepaper can be viewed <a href='./bitcoin-whitepaper'>here</a>. "
},
{
name: "Bitcoin Logo Day",
date: "2011-11-04",
desc: "On this day in 2010, an unknown artist under the username \"bitboy\" offered the Bitcoin community its iconic logo for free on the Bicointalk forum. You can view the original post <a href='https://bitcointalk.org/index.php?topic=1631.0%3Ball'>here</a>."
},
{
name: "Diffe-Hellman Day",
date: "1976-11-01",
desc: "On this day in 1976, Whitfield Diffie and Martin E. Hellman released their proposal for a breakthrough in cryptographic communication: the first implementation of public/private key pairs for secure communication over public channels. This cryptographic building block is one of the key underpinnings of the Bitcoin network. Read their 1976 paper titled \"New Directions in Cryptography\" <a href='https://ee.stanford.edu/~hellman/publications/24.pdf'>here</a>."
}
]
};

View file

@ -229,7 +229,7 @@ module.exports = {
{name: "Mempool", items: [4, 16, 5]},
{name: "Analysis", items: [9, 18, 10, 11, 12, 3]},
{name: "Technical", items: [15, 6, 7, 1]},
{name: "Fun", items: [8, 17, 13]},
{name: "Fun", items: [8, 17, 19, 13]},
]
},
@ -265,6 +265,8 @@ module.exports = {
/* 17 */ {name:"Quotes", url:"./quotes", desc:"Curated list of Bitcoin-related quotes.", iconClass:"bi-chat-quote"},
/* 18 */ {name:"UTXO Set", url:"./utxo-set", desc:"View the latest UTXO Set.", iconClass:"bi-list-columns"},
/* 19 */ {name:"Holidays", url:"./holidays", desc:"Curated list of Bitcoin 'Holidays'.", iconClass:"bi-calendar-heart"},
]
};

View file

@ -2280,6 +2280,14 @@ router.get("/quotes", function(req, res, next) {
next();
});
router.get("/holidays", function(req, res, next) {
res.locals.btcHolidays = global.btcHolidays;
res.render("holidays");
next();
});
router.get("/quote/:quoteIndex", function(req, res, next) {
res.locals.quoteIndex = parseInt(req.params.quoteIndex);
res.locals.btcQuotes = btcQuotes.items;

39
views/holidays.pug Normal file
View file

@ -0,0 +1,39 @@
extends layout
block headContent
title #{coinConfig.name} Holidays
block content
+pageTitle(`${coinConfig.name} Holidays`)
+dismissableInfoAlert("holidaysNoteDismissed", "About Bitcoin Holidays...")
h6.mb-2 About Bitcoin Holidays
| This is a curated list of Bitcoin 'Holidays' that commemorate key moments in Bitcoin's history. Suggestions are welcome via an issue or PR on <a href='https://github.com/janoside/btc-rpc-explorer' target='_blank'>GitHub</a>.
- var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
- var currentMonth = -1;
each day in btcHolidays.sortedDays
- var month = parseInt(day.substring(0, 2)) - 1;
if (currentMonth != month)
- currentMonth = month;
h2.mt-5 #{months[currentMonth]}
each item in btcHolidays.byDay[day]
- var dom = parseInt(day.substring(3));
.mb-2
+contentSection
h6 #{months[currentMonth]} #{dom}, #{item.date.substring(0, 4)}
h6.fs-6.text-uppercase.fw-light.text-card-highlight #{item.name}
.mb-0 !{item.desc}
if (false)
pre
code.json #{JSON.stringify(item, null, 4)}

View file

@ -4,6 +4,32 @@ block headContent
title Bitcoin Explorer
block content
- var tzDiff = -parseFloat(browserTzOffset);
if (userTzOffset != "unset")
- tzDiff = parseFloat(userTzOffset);
- var tzMoment = moment.utc(new Date()).add(tzDiff, "hours");
- var tzDay = tzMoment.format("MM-DD");
if (global.btcHolidays.byDay[tzDay])
- var day = tzDay;
- var dom = parseInt(day.substring(3));
- var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
- var currentMonth = parseInt(day.substring(0, 2)) - 1;
.mb-2
+contentSection
h4
i.bi-star-fill.text-warning
span.ms-2 Today is...
each item in global.btcHolidays.byDay[tzDay]
h6.fs-6.text-uppercase.fw-light.text-card-highlight #{item.name}!
.mb-0 !{item.desc}
if (getblockchaininfo == null)
div.alert.alert-danger
h5.mb-3 Unable to get basic blockchain data