Пример #1
0
async def test_register_incoming_worker(monkeypatch):
    monkeypatch.setattr(register, 'INCOMING_WORKERS', dict())
    curlen = len(register.INCOMING_WORKERS.keys())
    a = object()
    register_incoming_worker('TEST', a)
    assert len(register.INCOMING_WORKERS.keys()) == curlen + 1
    assert register.INCOMING_WORKERS['TEST'] is a
Пример #2
0
        if (i < 10):  # if there was less than 10 items, not a busy time
            await asyncio.sleep(2)


async def binance_incoming_worker(config):
    if config.binancechain.enabled.value:
        while True:
            try:
                await check_incoming(config)

            except Exception:
                LOGGER.exception("ERROR, relaunching incoming in 10 seconds")
                await asyncio.sleep(10)


register_incoming_worker(CHAIN_NAME, binance_incoming_worker)


def prepare_transfer_tx(wallet, target_addr, memo_bytes):
    tx = TransferMsg(
        wallet=wallet,
        symbol='BNB',
        amount=0.0001,
        to_address=target_addr,  # send to target
        memo=memo_bytes)
    return tx


async def binance_packer(config):
    loop = asyncio.get_event_loop()
    # TODO: testnet perhaps? When we get testnet coins.
Пример #3
0
                                                last_stored_height+1):
                await incoming_chaindata(jdata, context)
            await asyncio.sleep(10)


async def nuls_incoming_worker(config):
    if config.nuls2.enabled.value:
        while True:
            try:
                await check_incoming(config)

            except Exception:
                LOGGER.exception("ERROR, relaunching incoming in 10 seconds")
                await asyncio.sleep(10)

register_incoming_worker(CHAIN_NAME, nuls_incoming_worker)


async def broadcast(server, tx_hex, chain_id=1):
    return await server.broadcastTx(chain_id, tx_hex)

async def get_balance(server, address, chain_id, asset_id):
    return await server.getAccountBalance(chain_id, chain_id,
                                          asset_id, address)
    
async def prepare_transfer_tx(address, targets, nonce, chain_id=1,
                              asset_id=1, remark=b"", raw_tx_data=None):
    """ Targets are tuples: address and value.
    """
    outputs = [
        {"address": add,
Пример #4
0
            await incoming_chaindata(jdata, context)
        await asyncio.sleep(10)


async def ethereum_incoming_worker(config):
    if config.ethereum.enabled.value:
        while True:
            try:
                await check_incoming(config)

            except Exception:
                LOGGER.exception("ERROR, relaunching incoming in 10 seconds")
                await asyncio.sleep(10)


register_incoming_worker(CHAIN_NAME, ethereum_incoming_worker)


def broadcast_content(config, contract, web3: Web3, account, gas_price, nonce,
                      content):
    # content = json.dumps(content)
    tx = contract.functions.doEmit(content).buildTransaction({
        "chainId":
        config.ethereum.chain_id.value,
        "gasPrice":
        gas_price,
        "nonce":
        nonce,
    })
    signed_tx = account.signTransaction(tx)
    return web3.eth.sendRawTransaction(signed_tx.rawTransaction)