Пример #1
0
def ITTV():
    from pycoin import ecdsa as ecd
    key = sign.Key("62fbe2")
    obj, j = key.sign_transaction(
        **{
            "recipient_address": "053b3ebd1e15f06dfc7e125eadbd31cfec220895",
            "value": 10000000,
            "fee": 100
        })
    tx1 = Transaction(json.dumps(obj))
    tx2 = Transaction(tx1.jsontrans)
    obj['to'] = "1234567890"
    trans = Transaction(json.dumps(obj))

    hashes = [
        [trans.hash, "False"],  # Modified Recipient Hash
        [trans._d['transactionDataHash'], "True"],  # Valid Hash
        [
            "cfd713049033cffda22f25c399b182691716c2b68346d419d5b1edf62fc63740",
            "False"
        ],
        [tx1.hash, "True"],
        [tx2.hash, "True"]
    ]

    for _hash, exp_res in hashes:
        printer.print("======Testing=======")
        printer.print(f"HASH: {_hash}")
        result = ecd.verify(ecd.generator_secp256k1, key.pubkey,
                            int(_hash, base=16), trans.senderSignature)
        printer.print(f"VALID? {result}")
        printer.print(f"Expected result: {exp_res}")
Пример #2
0
def createAndMineTransaction():
    acc = {
        "Reg": sign.Key("1122334455a"),
        "Riko": sign.Key("1234567890b"),
        "Nanachi": sign.Key("1234567890c"),
        "Ozen": sign.Key("1234567890d"),
        "Lyza": sign.Key("1234567890e"),
        "Prushka": sign.Key("1234567890f")
    }

    faucet = sign.Key(
        "4a4c90c69cb27b07650d05763dcebb612fa414c3dd06284086deed464a0866d9")
    usera = None
    userb = None
    for i in range(10):
        usera = random.choice(list(acc.items()))
        userb = random.choice(list(acc.items()))
        while usera == userb:
            userb = random.choice(list(acc.items()))

        obj, tx_hash = usera[1].sign_transaction(
            **{
                "recipient_address": userb[1].address,
                "value": random.randint(5000, 10000),
                "fee": 100
            })

        obj.update({"origin": {"nodeid": "client-app"}})
        printer.print(
            f"Submitting Transaction: {userb[0]}@{obj['value']} -> {usera[0]}")

        printer.print(client.request("transaction.new", obj))
Пример #3
0
def TTV():
    key = sign.Key(
        "62fbe24314ed52de77e919196ff63348181b582773d6d82c56fe21e3e27ba111")
    obj, j = key.sign_transaction(
        **{
            "recipient_address": "053b3ebd1e15f06dfc7e125eadbd31cfec220895",
            "value": 10000000,
            "fee": 100
        })
    trans = Transaction(json.dumps(obj))
    printer.print(trans.jsontrans)
    printer.print(f"Wallet Pub Key: {key.pubkey}")
    printer.print(f"{trans.valid}")
Пример #4
0
def FST():
    key = sign.Key("1234567890")
    obj, json_hash = key.sign_transaction(
        **{
            "recipient_address": "053b3ebd1e15f06dfc7e125eadbd31cfec220895",
            "value": 10000000,
            "fee": 100
        })
    obj.update({"origin": {"nodeid": "client"}})
    obj['to'] = "1234567890"

    printer.print(client.request("transaction.new", obj))
    printer.print("OK!")
Пример #5
0
def printBalances():
    acc = {
        "Reg": sign.Key("1122334455a"),
        "Riko": sign.Key("1234567890b"),
        "Nanachi": sign.Key("1234567890c"),
        "Ozen": sign.Key("1234567890d"),
        "Lyza": sign.Key("1234567890e"),
        "Prushka": sign.Key("1234567890f")
    }
    print("==============")
    for user, wallet in acc.items():
        _balance = client.request("address.balance", wallet.address)
        printer.print(f"{user} Balance: {_balance}")
Пример #6
0
def getMineBlock():
    miner = sign.Key("aabbccddeeff")
    miner_balance = client.request("address.balance", miner.address)
    printer.print(f"Miner Balance: {miner_balance}")
    job = client.request("block.minejob.get", {"miner": miner.address})
    printer.print(
        f"Index: {job['blockdata']['index']}, Block hash: {job['datahash']}")
    dataHash = ""
    nonce = -1
    while not dataHash.startswith("0" * job['difficulty']):
        nonce += 1
        dataHash = ETH_misc.sha256(f"{job['datahash']}{nonce}")

    printer.print(f"Nonce: ND@{nonce}:{dataHash}")

    finished_job = {"datahash": job['datahash'], "nonce": nonce}
    result = client.request("block.minejob.submit", finished_job)
    printer.print(f"Result: {result}")
    miner_balance = client.request("address.balance", miner.address)
    printer.print(f"Miner Balance: {miner_balance}")
    return result
Пример #7
0
def distributeCoins():
    acc = {
        "Reg": sign.Key("1122334455a"),
        "Riko": sign.Key("1234567890b"),
        "Nanachi": sign.Key("1234567890c"),
        "Ozen": sign.Key("1234567890d"),
        "Lyza": sign.Key("1234567890e"),
        "Prushka": sign.Key("1234567890f")
    }

    faucet = sign.Key(
        "4a4c90c69cb27b07650d05763dcebb612fa414c3dd06284086deed464a0866d9")

    for user, wallet in acc.items():
        obj, tx_hash = faucet.sign_transaction(**{
            "recipient_address": wallet.address,
            "value": 50000,
            "fee": 100
        })
        printer.print(
            f"Submitting Transaction: Faucet@{obj['value']} -> {user}")
        obj.update({"origin": {"nodeid": "client-app"}})
        printer.print(client.request("transaction.new", obj))