upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp103
1 files changed, 82 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6fd8c82..5d266ff 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -41,12 +41,30 @@ unsigned int nTransactionsUpdated = 0;
41map<COutPoint, CInPoint> mapNextTx; 41map<COutPoint, CInPoint> mapNextTx;
42 42
43map<uint256, CBlockIndex*> mapBlockIndex; 43map<uint256, CBlockIndex*> mapBlockIndex;
44// Bitflash genesis -- mined under RandomX PoW on 2026-07-22 44// Bitflash mainnet genesis -- mined under RandomX PoW for the 2026 stable
45// (nTime 1753142400, nBits 0x1f0fffff, RandomX key "Bitflash/RandomX/v1/...") 45// relaunch. Testnet gets its own resettable genesis below so block indexes,
46// Bitflash 2026 stable relaunch genesis (2-min blocks, RandomX). Mined values. 46// headers, and wallet scans cannot be accidentally mixed across networks.
47unsigned int GENESIS_NONCE = 3141; 47static const unsigned int MAINNET_GENESIS_TIME = 1753315200; // 2026-07-24 00:00:00 UTC
48uint256 hashGenesisBlock("0x5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169"); 48static const unsigned int MAINNET_GENESIS_NONCE = 3141;
49uint256 hashGenesisMerkleRoot("0x1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325"); 49static const char* MAINNET_GENESIS_TIMESTAMP =
50 "Bitflash 24/Jul/2026 Fair launch: one CPU one vote, no premine";
51static const char* MAINNET_GENESIS_HASH =
52 "0x5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169";
53static const char* MAINNET_GENESIS_MERKLE =
54 "0x1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325";
55
56static const unsigned int TESTNET_GENESIS_TIME = 1787184000; // 2026-08-20 00:00:00 UTC
57static const unsigned int TESTNET_GENESIS_NONCE = 3199;
58static const char* TESTNET_GENESIS_TIMESTAMP =
59 "Bitflash testnet 20/Aug/2026: resettable public test chain";
60static const char* TESTNET_GENESIS_HASH =
61 "0xa9d11c6d697bcb7aea0653bc088b12dcf9f44e732df205162cf085fd9d9963eb";
62static const char* TESTNET_GENESIS_MERKLE =
63 "0x510b293105e3ff85b8d4c3920e357f85d1a86bf199eb4e7d11f04f380030ec5c";
64
65unsigned int GENESIS_NONCE = MAINNET_GENESIS_NONCE;
66uint256 hashGenesisBlock(MAINNET_GENESIS_HASH);
67uint256 hashGenesisMerkleRoot(MAINNET_GENESIS_MERKLE);
50CBlockIndex* pindexGenesisBlock = NULL; 68CBlockIndex* pindexGenesisBlock = NULL;
51int nBestHeight = -1; 69int nBestHeight = -1;
52uint256 hashBestChain = 0; 70uint256 hashBestChain = 0;
@@ -117,6 +135,63 @@ static std::atomic<uint64> gParticipantHashRateX1000{0};
117static std::mutex gParticipantStatusMutex; 135static std::mutex gParticipantStatusMutex;
118static std::string gParticipantStatus; 136static std::string gParticipantStatus;
119 137
138void SelectGenesisParams(bool fTestNetIn)
139{
140 static bool fGenesisParamsSelected = false;
141 static bool fGenesisParamsTestNet = false;
142 if (fGenesisParamsSelected && fGenesisParamsTestNet == fTestNetIn)
143 return;
144
145 fGenesisParamsSelected = true;
146 fGenesisParamsTestNet = fTestNetIn;
147
148 if (fTestNetIn)
149 {
150 GENESIS_NONCE = TESTNET_GENESIS_NONCE;
151 hashGenesisBlock = uint256(TESTNET_GENESIS_HASH);
152 hashGenesisMerkleRoot = uint256(TESTNET_GENESIS_MERKLE);
153 }
154 else
155 {
156 GENESIS_NONCE = MAINNET_GENESIS_NONCE;
157 hashGenesisBlock = uint256(MAINNET_GENESIS_HASH);
158 hashGenesisMerkleRoot = uint256(MAINNET_GENESIS_MERKLE);
159 }
160}
161
162void SelectChainParams(bool fTestNetIn)
163{
164 SelectNetworkParams(fTestNetIn);
165 SelectGenesisParams(fTestNetIn);
166}
167
168static CBlock BuildGenesisBlock()
169{
170 const char* pszTimestamp = IsTestNet() ?
171 TESTNET_GENESIS_TIMESTAMP : MAINNET_GENESIS_TIMESTAMP;
172
173 CTransaction txNew;
174 txNew.vin.resize(1);
175 txNew.vout.resize(1);
176 txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) <<
177 vector<unsigned char>((unsigned char*)pszTimestamp,
178 (unsigned char*)pszTimestamp + strlen(pszTimestamp));
179 txNew.vout[0].nValue = 50 * COIN;
180 txNew.vout[0].scriptPubKey = CScript() <<
181 CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") <<
182 OP_CHECKSIG;
183
184 CBlock block;
185 block.vtx.push_back(txNew);
186 block.hashPrevBlock = 0;
187 block.hashMerkleRoot = block.BuildMerkleTree();
188 block.nVersion = 1;
189 block.nTime = IsTestNet() ? TESTNET_GENESIS_TIME : MAINNET_GENESIS_TIME;
190 block.nBits = 0x1f0fffff; // = bnProofOfWorkLimit (Bitflash RandomX floor)
191 block.nNonce = GENESIS_NONCE;
192 return block;
193}
194
120void SetParticipantMiningStatus(const std::string& status) 195void SetParticipantMiningStatus(const std::string& status)
121{ 196{
122 // Updates the GUI status string only. Logging is done at each call site 197 // Updates the GUI status string only. Logging is done at each call site
@@ -2664,21 +2739,7 @@ bool LoadBlockIndex(bool fAllowNew)
2664 // vMerkleTree: 4a5e1e 2739 // vMerkleTree: 4a5e1e
2665 2740
2666 // Bitflash genesis block -- own header (fair launch, 2026 stable relaunch) 2741 // Bitflash genesis block -- own header (fair launch, 2026 stable relaunch)
2667 char* pszTimestamp = "Bitflash 24/Jul/2026 Fair launch: one CPU one vote, no premine"; 2742 CBlock block = BuildGenesisBlock();
2668 CTransaction txNew;
2669 txNew.vin.resize(1);
2670 txNew.vout.resize(1);
2671 txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((unsigned char*)pszTimestamp, (unsigned char*)pszTimestamp + strlen(pszTimestamp));
2672 txNew.vout[0].nValue = 50 * COIN;
2673 txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG;
2674 CBlock block;
2675 block.vtx.push_back(txNew);
2676 block.hashPrevBlock = 0;
2677 block.hashMerkleRoot = block.BuildMerkleTree();
2678 block.nVersion = 1;
2679 block.nTime = 1753315200; // 2026-07-24 00:00:00 UTC (stable relaunch)
2680 block.nBits = 0x1f0fffff; // = bnProofOfWorkLimit (Bitflash RandomX floor)
2681 block.nNonce = GENESIS_NONCE;
2682 2743
2683 // If the nonce has not been found yet, mine the genesis once (RandomX) 2744 // If the nonce has not been found yet, mine the genesis once (RandomX)
2684 // and print the values to be hardcoded in the constants above. 2745 // and print the values to be hardcoded in the constants above.