Пример #1
0
def sign_transaction(tx: Transaction, privkey: str, network_id: int):
    # Implementing EIP 155.
    tx.v = network_id
    sig = sign(privkey, keccak256(rlp.encode(tx)), v=35 + 2 * network_id)
    v, r, s = sig[-1], sig[0:32], sig[32:-1]
    tx.v = v
    tx.r = int.from_bytes(r, byteorder='big')
    tx.s = int.from_bytes(s, byteorder='big')
Пример #2
0
def sign_transaction(tx: Transaction, privkey: str, network_id: int):
    # Implementing EIP 155.
    tx.v = network_id
    sig = sign(privkey, keccak256(rlp.encode(tx)), v=35 + 2 * network_id)
    v, r, s = sig[-1], sig[0:32], sig[32:-1]
    tx.v = v
    tx.r = int.from_bytes(r, byteorder='big')
    tx.s = int.from_bytes(s, byteorder='big')
Пример #3
0
def copy_transaction_signature(signed_transaction: SignedTransaction, transaction: Transaction) -> Transaction:
    """ Copy signature from SignedTransaction into Ethereum Transaction. """

    assert isinstance(signed_transaction, SignedTransaction)
    assert isinstance(transaction, Transaction)

    transaction.v = signed_transaction.v
    transaction.r = signed_transaction.r
    transaction.s = signed_transaction.s
Пример #4
0
def create_urs_tx(shard_id, gasprice=GASPRICE):
    bytecode = get_urs_bytecode(shard_id)
    tx = Transaction(0, gasprice, 2000000, to=b'', value=0, data=bytecode)
    tx.v = 27
    tx.r = 10000
    tx.s = shard_id + 1
    tx_rawhash = get_tx_rawhash(tx)
    urs_sender_addr = utils.sha3(
        utils.ecrecover_to_pub(tx_rawhash, tx.v, tx.r, tx.s))[-20:]
    urs_addr = utils.mk_contract_address(urs_sender_addr, 0)
    return tx, urs_addr, urs_sender_addr
Пример #5
0
def create_valmgr_tx(gasprice=GASPRICE):
    global _valmgr_sender_addr, _valmgr_addr, _valmgr_tx
    bytecode = get_valmgr_bytecode()
    tx = Transaction(0, gasprice, 4000000, to=b'', value=0, data=bytecode)
    tx.v = 27
    tx.r = 1000000000000000000000000000000000000000000000000000000000000000000000000000
    tx.s = 1000000000000000000000000000000000000000000000000000000000000000000000000000
    valmgr_sender_addr = extract_sender_from_tx(tx)
    valmgr_addr = utils.mk_contract_address(valmgr_sender_addr, 0)
    _valmgr_sender_addr = valmgr_sender_addr
    _valmgr_addr = valmgr_addr
    _valmgr_tx = tx