Пример #1
0
def create_god_transaction(to_pk):
    """Creates first ("God") transaction in chain history using seed coins"""

    god_pk, god_sk = signature.generate_keys()
    tx = Transaction(god_pk, to_pk, SEED_COIN_SUPPLY)
    tx.sign(god_sk)
    return tx
Пример #2
0
    print("Your public key is:")
    print(pk)

    print("Your secret key is:")
    print(sk)

    # Generate God keys to create seed transaction
    god_pk, god_sk = signature.generate_keys()

    # Create two blockchains and implement fork choice
    new_blockchain = None
    for i in range(4):
        if not new_blockchain:  # Must mine the Genesis node
            tx = Transaction(god_pk, pk, SEED_COIN_SUPPLY)
            tx.sign(god_sk)
            new_blockchain = Blockchain([tx])
        else:
            to_pk = input("Give seed money to:")
            amount = int(input("Amount:"))
            tx = Transaction(pk, to_pk, amount)  # All transactions sent from God node
            tx.sign(sk)
            new_blockchain.add_transactions([tx])

    print("Creating second blockchain...")

    new_blockchain_2 = None
    for i in range(3):
        if not new_blockchain_2:  # Must mine the Genesis node
            tx = Transaction(god_pk, pk, SEED_COIN_SUPPLY)
            tx.sign(god_sk)