from eth_account._utils.transactions import serializable_unsigned_transaction_from_dict, encode_transaction
from web3 import Web3, HTTPProvider


def get_signature_prefix( signature_rs, address, transaction_hash, chainId, web3 ):
    try:
        r, s = signature_rs
    except:
        print( "Invalid signature argument!" )
        raise SystemExit()

    v = chainId * 2 + 35
    if web3.eth.account._recover_hash( bytes( transaction_hash ), vrs=( v, r, s ) ) != address:
        v = chainId * 2 + 36
