Dispatch a raw hex transaction to the network.
776037
def broadcast_transaction(hex_tx, blockchain_client):
    
    if not isinstance(blockchain_client, BlockcypherClient):
        raise Exception('A BlockcypherClient object is required')

    url = '%s/txs/push' % (BLOCKCYPHER_BASE_URL)
    payload = json.dumps({'tx': hex_tx})
    r = requests.post(url, data=payload)

    try:
        data = r.json()
    except ValueError:
        raise Exception('Received non-JSON from blockcypher.com.')

    if 'tx' in data:
        reply = {}
        reply['tx_hash'] = data['tx']['hash']
        reply['success'] = True
        return reply
    else:
        err_str = 'Tx hash missing from blockcypher response: ' + str(data)
        raise Exception(err_str)
950020
public static SendRequest forTx(Transaction tx) {
        SendRequest req = new SendRequest();
        req.tx = tx;
        return req;
    }
1260112
def _sendReply(self, destination, fid, *args):
        """"""
        # Try to send the result directly to its parent
        self.addPeer(destination)

        try:
            self.direct_socket.send_multipart([
                destination,
                REPLY,
            ] + list(args),
                flags=zmq.NOBLOCK)
        except zmq.error.ZMQError as e:
            # Fallback on Broker routing if no direct connection possible
            scoop.logger.debug(
                "{0}: Could not send result directly to peer {1}, routing through "
                "broker.".format(scoop.worker, destination)
            )
            self.socket.send_multipart([
                REPLY, 
                ] + list(args) + [
                destination,
            ])

        self.socket.send_multipart([
            STATUS_DONE,
            fid,
        ])
460962
def send(term, stream):
    """"""
    payload = erlang.term_to_binary(term)
    header = struct.pack('!I', len(payload))
    stream.write(header)
    stream.write(payload)
    stream.flush()
1359094
def call(self, method, *args, **params):
        """"""

        transaction_id = params.get("transaction_id")

        if not transaction_id:
            self.transaction_id += 1
            transaction_id = self.transaction_id

        obj = params.get("obj")

        args = [method, transaction_id, obj] + list(args)
        args_encoded = map(lambda x: encode_amf(x), args)
        body = b"".join(args_encoded)

        format = params.get("format", PACKET_SIZE_MEDIUM)
        channel = params.get("channel", 0x03)

        packet = RTMPPacket(type=PACKET_TYPE_INVOKE,
                            format=format, channel=channel,
                            body=body)

        self.send_packet(packet)

        return RTMPCall(self, transaction_id)
162416
def broadcast_transaction(hex_tx, blockchain_client):
    
    if isinstance(blockchain_client, BlockcypherClient):
        return blockcypher.broadcast_transaction(hex_tx, blockchain_client)
    elif isinstance(blockchain_client, BlockchainInfoClient):
        return blockchain_info.broadcast_transaction(hex_tx, blockchain_client)
    elif isinstance(blockchain_client, ChainComClient):
        return chain_com.broadcast_transaction(hex_tx, blockchain_client)
    elif isinstance(blockchain_client, (BitcoindClient, AuthServiceProxy)):
        return bitcoind.broadcast_transaction(hex_tx, blockchain_client)
    elif hasattr(blockchain_client, "broadcast_transaction"):
        return blockchain_client.broadcast_transaction( hex_tx )
    elif isinstance(blockchain_client, BlockchainClient):
        raise Exception('That blockchain interface is not supported.')
    else:
        raise Exception('A BlockchainClient object is required')
597191
def forward_packet(self, writer, packet, raw_packet):
        """"""
        peer = writer.get_extra_info('peername')
        log.debug(' %s:%s: forwarding data: %s', peer[0], peer[1], packet)
        if 'command' in packet:
            packet_id = serialize_packet_id(packet)
            command = packet['command']
            ack = yield from self.protocol.send_command_ack(
                packet_id, command)
            if ack:
                writer.write("20;00;OK;".encode() + CRLF)
            for _ in range(DEFAULT_SIGNAL_REPETITIONS-1):
                yield from self.protocol.send_command_ack(
                    packet_id, command)
        else:
            self.protocol.send_raw_packet(raw_packet)
76175
def send_raw(self, string):
        
        log.debug('RAW: {}'.format(string))
        if self.transport is None:
            raise ServerNotConnectedError("Not connected.")

        self.transport.write(self._prep_message(string))
84620
def send(token_hex, message, **kwargs):
    
    is_enhanced = kwargs.pop('is_enhanced', False)
    identifier = kwargs.pop('identifier', 0)
    expiry = kwargs.pop('expiry', 0)

    alert = {
        "title": kwargs.pop("event"),
        "body": message,
        "action": kwargs.pop(
            'apns_action', defaults.APNS_PROVIDER_DEFAULT_ACTION)
    }

    data = {
        "aps": {
            'alert': alert,
            'content-available': kwargs.pop('content_available', 0) and 1
        }
    }
    data['aps'].update(kwargs)
    payload = dumps(data, separators=(',', ':'))

    token = a2b_hex(token_hex)
    if is_enhanced is True:
        fmt = '!BIIH32sH%ds' % len(payload)
        expiry = expiry and time() + expiry
        notification = pack(
            fmt, 1, identifier, expiry,
            32, token, len(payload), payload)
    else:
        token_length_bin = pack('>H', len(token))
        payload_length_bin = pack('>H', len(payload))
        zero_byte = bytes('\0', 'utf-8') if PY3 is True else '\0'
        payload = bytes(payload, 'utf-8') if PY3 is True else payload
        notification = (
            zero_byte + token_length_bin + token +
            payload_length_bin + payload)

    sock = socket(AF_INET, SOCK_STREAM)
    sock.settimeout(3)
    sock.connect((settings.APNS_GW_HOST, settings.APNS_GW_PORT))
    ssl = wrap_socket(
        sock, settings.APNS_KEY_FILE,
        settings.APNS_CERT_FILE,
        do_handshake_on_connect=False)

    result = ssl.write(notification)

    sock.close()
    ssl.close()

    if not result:
        raise APNsError

    return True
559766
def hexedit(x):
    """"""
    x = bytes(x)
    fname = get_temp_file()
    with open(fname,"wb") as f:
      f.write(x)
    subprocess.call([conf.prog.hexedit, fname])
    with open(fname, "rb") as f:
      x = f.read()
    return x
1154430
def sign(self, key, network_id=None):
        
        if network_id is None:
            rawhash = utils.sha3(rlp.encode(unsigned_tx_from_tx(self), UnsignedTransaction))
        else:
            assert 1 <= network_id < 2**63 - 18
            rlpdata = rlp.encode(rlp.infer_sedes(self).serialize(self)[
                                 :-3] + [network_id, b'', b''])
            rawhash = utils.sha3(rlpdata)

        key = normalize_key(key)

        v, r, s = ecsign(rawhash, key)
        if network_id is not None:
            v += 8 + network_id * 2

        ret = self.copy(
            v=v, r=r, s=s
        )
        ret._sender = utils.privtoaddr(key)
        return ret
1259367
def add_transaction(self,
                        block_header: BlockHeader,
                        index_key: int,
                        transaction: 'BaseTransaction') -> Hash32:
        
        transaction_db = HexaryTrie(self.db, root_hash=block_header.transaction_root)
        transaction_db[index_key] = rlp.encode(transaction)
        return transaction_db.root_hash
477404
def sendVX(self, vx):
        '''
        

        '''
        self.lock.acquire()
        self.data.vx = vx
        self.lock.release()
791591
function signTransaction(priKeyBytes, transaction) {

  if (typeof priKeyBytes === 'string') {
    priKeyBytes = hexStr2byteArray(priKeyBytes);
  }

  let raw = transaction.getRawData();
  let rawBytes = raw.serializeBinary();
  let hashBytes = SHA256(rawBytes);
  let signBytes = ECKeySign(hashBytes, priKeyBytes);
  let uint8Array = new Uint8Array(signBytes);
  let count = raw.getContractList().length;
  for (let i = 0; i < count; i++) {
    transaction.addSignature(uint8Array);
  }

  return transaction;
}
1164911
private void forwardCommandRemotely(RemoteTransaction remoteTx) {
      Set<Object> affectedKeys = remoteTx.getAffectedKeys();
      if (trace)
         log.tracef("Invoking forward of TxCompletionNotification for transaction %s. Affected keys: %s", gtx,
               toStr(affectedKeys));
      stateTransferManager.forwardCommandIfNeeded(this, affectedKeys, remoteTx.getGlobalTransaction().getAddress());
   }
674411
def do_raw_dispatch(participant, msg)

      workitem = Ruote::Workitem.new(msg['workitem'])

      workitem.fields['dispatched_at'] = Ruote.now_to_utc_s

      Ruote.participant_send(
        participant, [ :on_workitem, :consume ], 'workitem' => workitem)

      @context.storage.put_msg(
        'dispatched',
        'fei' => msg['fei'],
        'participant_name' => workitem.participant_name,
        'workitem' => msg['workitem'])
          # once the consume is done, asynchronously flag the
          # participant expression as 'dispatched'
    end
1192833
def raw_command(self, lun, netfn, raw_bytes):
        
        return self.interface.send_and_receive_raw(self.target, lun, netfn,
                                                   raw_bytes)