Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: lhartikk/GenesisH0
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: RazerStvH/GenesisH0
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 6 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 18, 2024

  1. Add files via upload

    RazerStvH authored Nov 18, 2024
    Copy the full SHA
    236fa52 View commit details
  2. Add files via upload

    RazerStvH authored Nov 18, 2024
    Copy the full SHA
    56463b1 View commit details
  3. Add files via upload

    RazerStvH authored Nov 18, 2024
    Copy the full SHA
    df4dbfb View commit details

Commits on Nov 19, 2024

  1. Delete genesis1.py

    RazerStvH authored Nov 19, 2024
    Copy the full SHA
    d6623fc View commit details
  2. Add files via upload

    RazerStvH authored Nov 19, 2024
    Copy the full SHA
    067c69c View commit details
  3. Update README.md

    RazerStvH authored Nov 19, 2024
    Copy the full SHA
    f81c4fe View commit details
Showing with 28 additions and 19 deletions.
  1. +2 −0 README.md
  2. +26 −19 genesis.py
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# GenesisH0
A python script for creating the parameters required for a unique genesis block. SHA256/scrypt/X11/X13/X15.

Fixed working with Python3

### Dependencies
sudo pip install scrypt construct==2.5.2

45 changes: 26 additions & 19 deletions genesis.py
Original file line number Diff line number Diff line change
@@ -54,19 +54,26 @@ def get_algorithm(options):
sys.exit("Error: Given algorithm must be one of: " + str(supported_algorithms))

def create_input_script(psz_timestamp):
psz_prefix = ""
timestamp_bytes = psz_timestamp.encode('utf-8')
psz_prefix = ''
#use OP_PUSHDATA1 if required
if len(psz_timestamp) > 76: psz_prefix = '4c'
if len(timestamp_bytes) > 76: psz_prefix = '4c'

script_prefix = '04ffff001d0104' + psz_prefix + chr(len(psz_timestamp)).encode('hex')
print (script_prefix + psz_timestamp.encode('hex'))
return (script_prefix + psz_timestamp.encode('hex')).decode('hex')
length_in_hex = hex(len(timestamp_bytes))[2:]

if len(length_in_hex) == 1:
length_in_hex = "0" + length_in_hex

script_prefix = '04ffff001d0104' + psz_prefix + length_in_hex
input_script_hex = script_prefix + timestamp_bytes.hex()
print(input_script_hex)
return bytes.fromhex(input_script_hex)


def create_output_script(pubkey):
script_len = '41'
OP_CHECKSIG = 'ac'
return (script_len + pubkey + OP_CHECKSIG).decode('hex')
return bytes.fromhex(script_len + pubkey + OP_CHECKSIG)


def create_transaction(input_script, output_script,options):
@@ -84,7 +91,7 @@ def create_transaction(input_script, output_script,options):
Bytes('output_script', 0x43),
UBInt32('locktime'))

tx = transaction.parse('\x00'*(127 + len(input_script)))
tx = transaction.parse(b'\x00'*(127 + len(input_script)))
tx.version = struct.pack('<I', 1)
tx.num_inputs = 1
tx.prev_output = struct.pack('<qqqq', 0,0,0,0)
@@ -110,7 +117,7 @@ def create_block_header(hash_merkle_root, time, bits, nonce):
Bytes("bits", 4),
Bytes("nonce", 4))

genesisblock = block_header.parse('\x00'*80)
genesisblock = block_header.parse(b'\x00'*80)
genesisblock.version = struct.pack('<I', 1)
genesisblock.hash_prev_block = struct.pack('<qqqq', 0,0,0,0)
genesisblock.hash_merkle_root = hash_merkle_root
@@ -122,7 +129,7 @@ def create_block_header(hash_merkle_root, time, bits, nonce):

# https://en.bitcoin.it/wiki/Block_hashing_algorithm
def generate_hash(data_block, algorithm, start_nonce, bits):
print 'Searching for genesis hash..'
print('Searching for genesis hash..')
nonce = start_nonce
last_updated = time.time()
# https://en.bitcoin.it/wiki/Difficulty
@@ -169,7 +176,7 @@ def generate_hashes_from_block(data_block, algorithm):


def is_genesis_hash(header_hash, target):
return int(header_hash.encode('hex_codec'), 16) < target
return int(header_hash.hex(), 16) < target


def calculate_hashrate(nonce, last_updated):
@@ -185,18 +192,18 @@ def calculate_hashrate(nonce, last_updated):


def print_block_info(options, hash_merkle_root):
print "algorithm: " + (options.algorithm)
print "merkle hash: " + hash_merkle_root[::-1].encode('hex_codec')
print "pszTimestamp: " + options.timestamp
print "pubkey: " + options.pubkey
print "time: " + str(options.time)
print "bits: " + str(hex(options.bits))
print("algorithm: " + (options.algorithm))
print("merkle hash: " + hash_merkle_root[::-1].hex())
print("pszTimestamp: " + options.timestamp)
print("pubkey: " + options.pubkey)
print("time: " + str(options.time))
print("bits: " + str(hex(options.bits)))


def announce_found_genesis(genesis_hash, nonce):
print "genesis hash found!"
print "nonce: " + str(nonce)
print "genesis hash: " + genesis_hash.encode('hex_codec')
print("genesis hash found!")
print("nonce: " + str(nonce))
print("genesis hash: " + genesis_hash.hex())


# GOGOGO!