Exemplo n.º 1
0
def create_address(web3: Web3, dbsession: Session, opid: UUID):
    """User requests new hosted address.

    We create a hosted wallet contract. The contract id is associated with the user in the database. We hold the the only owner address of the wallet.

    The wallet code is based on https://github.com/ethereum/meteor-dapp-wallet/blob/master/Wallet.sol
    """

    assert isinstance(opid, UUID)

    @retryable(tm=dbsession.transaction_manager)
    def finish_op():
        op = dbsession.query(CryptoOperation).get(opid)
        txid = wallet.initial_txid
        receipt = web3.eth.getTransactionReceipt(txid)

        op.txid = txid_to_bin(txid)
        op.block = receipt["blockNumber"]
        op.address.address = eth_address_to_bin(wallet.address)
        op.external_address = op.address.address

        # There is no broadcast wait, so we can close this right away
        op.mark_performed()
        op.mark_broadcasted()
        op.mark_complete()

    logger.info("Starting wallet creation for %s", opid)
    wallet = HostedWallet.create(web3)
    logger.info("Updating db for wallet creation for %s", opid)
    finish_op()
Exemplo n.º 2
0
def create_address(web3: Web3, dbsession: Session, opid: UUID):
    """User requests new hosted address.

    We create a hosted wallet contract. The contract id is associated with the user in the database. We hold the the only owner address of the wallet.

    The wallet code is based on https://github.com/ethereum/meteor-dapp-wallet/blob/master/Wallet.sol
    """

    assert isinstance(opid, UUID)

    @retryable(tm=dbsession.transaction_manager)
    def finish_op():
        op = dbsession.query(CryptoOperation).get(opid)
        txid = wallet.initial_txid
        receipt = web3.eth.getTransactionReceipt(txid)

        op.txid = txid_to_bin(txid)
        op.block = receipt["blockNumber"]
        op.address.address = eth_address_to_bin(wallet.address)
        op.external_address = op.address.address

        # There is no broadcast wait, so we can close this right away
        op.mark_performed()
        op.mark_broadcasted()
        op.mark_complete()

    logger.info("Starting wallet creation for %s", opid)
    wallet = HostedWallet.create(web3)
    logger.info("Updating db for wallet creation for %s", opid)
    finish_op()
Exemplo n.º 3
0
def hosted_wallet(web3: Web3, coinbase: str) -> HostedWallet:
    """Deploy a smart contract to local private blockchain so test functions can stress it out.

    :param client: py.test fixture to create RPC client to call geth node

    :param geth_node: py.test fixture to spin up geth node with test network parameters

    :param coinbase: Ethereum account number for coinbase account where our mined ETHs appear

    :return: 0x prefixed hexadecimal address of the deployed contract
    """

    return HostedWallet.create(web3)
Exemplo n.º 4
0
def hosted_wallet(web3: Web3, coinbase: str) -> HostedWallet:
    """Deploy a smart contract to local private blockchain so test functions can stress it out.

    :param client: py.test fixture to create RPC client to call geth node

    :param geth_node: py.test fixture to spin up geth node with test network parameters

    :param coinbase: Ethereum account number for coinbase account where our mined ETHs appear

    :return: 0x prefixed hexadecimal address of the deployed contract
    """

    return HostedWallet.create(web3, contract_name="Wallet2")