diff --git a/blockchain.py b/blockchain.py index 26c8a7c..04fc6e1 100644 --- a/blockchain.py +++ b/blockchain.py @@ -68,8 +68,13 @@ class Block: return False if not self.transaction.is_valid_after_block(prev_block): return False - elif self.transaction is not None: - return False + else: + if self.transaction is not None: + return False + # check for the correct miner pubkey - which will become public at launch day + h = hashlib.sha256(self.miner_pubkey).hexdigest() + if h != "88023d392db35f2d3936abd0532003ae0a38b4d35e4d123a0fa28c568c7e3e2f": + return False B_1_difficulty_sum, B_1_timestamp = self.get_difficulty_info(1, blockchain) B_10_difficulty_sum, B_10_timestamp = self.get_difficulty_info(10, blockchain) D = B_1_difficulty_sum - B_10_difficulty_sum diff --git a/docs/blockchain.md b/docs/blockchain.md index 4d25c35..b95af0b 100644 --- a/docs/blockchain.md +++ b/docs/blockchain.md @@ -6,7 +6,7 @@ The carrotcoin cryptocurrency is a bitcoin-like currency with proof-of-work, cre The network should stabilize at around 1 block every 5 minutes. -Blocks are hashed with SHA256 and need to start with a certain number of zeros (or, more precise, be below a given value depending on the difficulty) +Blocks are hashed with SHA256 and this hash needs to start with a certain number of zeros (or, more precise, be below a given value depending on the difficulty) ed25519 keys are used to validate transactions. @@ -100,6 +100,8 @@ A transaction that is stored in a block must fulfill the following criteria (in A block is valid if all of the following criteria are fulfilled: - The "previous hash" field contains a SHA256 hash value of a previous valid block. (Or is completely filled with nullbytes, in case of the first block.) +- The first block has a public key with the following SHA256 hash value: + 88023d392db35f2d3936abd0532003ae0a38b4d35e4d123a0fa28c568c7e3e2f - The "timestamp" field is greater than the timestamp of the previous block (if there is any). Equal timestamps are not allowed. - The "timestamp" field is less than or equal to the current time. This needs to be decided by each node based on the local clock. - The "difficulty sum" must be precisely calculated, as specified in `calculating difficulty`