Accepting offer by buyer

		Function accepts:
			- cid
			- buyer access string
			- buyer public key
			- seller public key
327651
async def post(self, public_key):
		
		logging.debug("[+] -- Deal debugging. ")
		if settings.SIGNATURE_VERIFICATION:
			super().verify()

		# Check if message contains required data
		try:
			body = json.loads(self.request.body)
		except:
			self.set_status(400)
			self.write({"error":400, "reason":"Unexpected data format. JSON required"})
			raise tornado.web.Finish
		logging.debug("\n         Body")
		logging.debug(body)
			
		if isinstance(body["message"], str):
			message = json.loads(body["message"])
		elif isinstance(body["message"], dict):
			message = body["message"]

		cid = message.get("cid")
		buyer_pubkey = message.get("buyer_pubkey")
		buyer_access_string = message.get("buyer_access_string")

		seller_access_string = message.get("seller_access_string")
		access_type = message.get("access_type")

		coinid = message.get("coinid")
		# check passes data
		if not all([buyer_access_string, cid, buyer_pubkey, coinid]):
			self.set_status(400)
			self.write({"error":400, "reason":"Missed required fields"})
			raise tornado.web.Finish

		if coinid in settings.bridges.keys():
			self.account.blockchain.setendpoint(settings.bridges[coinid])

		else:
			self.set_status(400)
			self.write({"error":400, "reason":"Invalid coin ID"})
			raise tornado.web.Finish 

		# Sellcontent
		buyer_address = self.account.validator[coinid](buyer_pubkey)

		# Check if accounts exists
		seller_account = await self.account.getaccountdata(public_key=public_key)
		logging.debug("\n          Seller account")
		logging.debug(seller_account)

		try:
			error_code = seller_account["error"]
		except:
			pass
		else:
			self.set_status(error_code)
			self.write(seller_account)
			raise tornado.web.Finish

		buyer_account = await self.account.getaccountdata(public_key=buyer_pubkey)
		logging.debug("\n           Buyer account")
		logging.debug(buyer_account)
		try:
			error_code = buyer_account["error"]
		except:
			pass
		else:
			self.set_status(error_code)
			self.write(buyer_account)
			raise tornado.web.Finish

		# Check if content belongs to current account
		owneraddr = await self.account.blockchain.ownerbycid(cid=cid)
		
		
		if owneraddr != self.account.validator[coinid](public_key):
			self.set_status(403)
			self.write({"error":403, "reason":"Forbidden. Profile owner does not match."})
			raise tornado.web.Finish

		#Get buyers balance
		balances = await self.account.balance.get_wallets(coinid=coinid, 
														uid=buyer_account["id"])
		if isinstance(balances, dict):
			if "error" in balances.keys():
				self.set_status(balances["error"])
				self.write(balances)
				raise tornado.web.Finish 


		# Get difference with balance and price
		get_price = await self.account.blockchain.getoffer(buyer_address=buyer_address,
															cid=cid)
		price = get_price["price"]
		logging.debug("\n          Price")
		logging.debug(price)

		for w in balances["wallets"]:
			if "PUT" in w.values() or "PUTTEST" in w.values():
				balance = w

		difference = int(balance["amount_frozen"]) - int(price)

		if difference >= 0:

			if access_type == "write_access":
				logging.debug("\n          Write access")
				# Fee
				fee = await billing.change_owner_fee(cid=cid, new_owner=buyer_pubkey)
				if "error" in fee.keys():
					self.set_status(fee["error"])
					self.write(fee)
					raise tornado.web.Finish
			
				# Change content owner
				chownerdata = {
					"cid":cid,
					"new_owner": buyer_address,
					"access_string": buyer_access_string,
					"seller_public_key": public_key
				}

				response = await self.account.blockchain.changeowner(**chownerdata)
				logging.debug("\n         Bridge change owner")
				logging.debug(response)

				new_owner = await self.account.changeowner(cid=cid, 
										public_key=buyer_account["public_key"], 
										coinid=coinid)
				logging.debug("\n Database new owner")
				logging.debug(new_owner)

			elif access_type == "read_access":
				logging.debug("\n          Read access")

				# Fee
				fee = await billing.sell_content_fee(cid=cid, new_owner=buyer_pubkey)

				if "error" in fee.keys():
					self.set_status(fee["error"])
					self.write(fee)
					raise tornado.web.Finish

				selldata = {
					"cid":cid,
					"buyer_address":buyer_address,
					"access_string":buyer_access_string,
					"seller_public_key":public_key
				}

				response = await self.account.blockchain.sellcontent(**selldata)
				logging.debug("\n        Bridge sell content")

				# Write cid to database
				check = await self.account.setuserscontent(public_key=buyer_account["public_key"], 
											hash=None,coinid=coinid, cid=cid,
											txid=response["result"]["txid"],
											access="deal")
				logging.debug(check)

			
			# Increment and decrement balances of seller and buyer
			coinid = "PUT"
			unfreeze = await self.account.balance.unfreeze(uid=buyer_account["id"],
													amount=price, coinid=coinid)
			logging.debug("\n          Unfreeze buyer")
			logging.debug(unfreeze)

			sub_active = await self.account.balance.sub_active(uid=buyer_account["id"], 
												coinid=coinid, amount=price)
			logging.debug("\n            Sub active")
			logging.debug(sub_active)
			add_frozen = await self.account.balance.add_frozen(uid=seller_account["id"], 
												amount=price, coinid=coinid)
			logging.debug("\n               Add frozen")
			logging.debug(add_frozen)
			# Write entry with txid to database
			new_deal = await self.account.balance.registerdeal(uid=seller_account["id"],
													public_key=seller_account["public_key"], 
													txid=response["result"]["txid"],
													coinid=coinid, cid=cid)

			del response["result"]
			del response["contract_owner_hex"]
			self.write(response)
		else:
			# If Insufficient funds
			self.set_status(402)
			self.write({"error":402, "reason":"Insufficient funds of buyer"})
			raise tornado.web.Finish
844178
function(validBidRequests, bidderRequest) {
    // Do we need to group by bidder? i.e. to make multiple requests for
    // different endpoints.

    let ret = {
      method: 'POST',
      url: '',
      data: '',
      bidRequest: []
    };

    if (validBidRequests.length < 1) {
      return ret;
    }

    let ENDPOINT_URL;

    const data = Object.assign({
      placements: [],
      time: Date.now(),
      user: {},
      url: utils.getTopWindowUrl(),
      enableBotFiltering: true,
      includePricingData: true,
      parallel: true
    }, validBidRequests[0].params);

    if (bidderRequest && bidderRequest.gdprConsent) {
      data.consent = {
        gdprVendorId: 150,
        gdprConsentString: bidderRequest.gdprConsent.consentString,
        // will check if the gdprApplies field was populated with a boolean value (ie from page config).  If it's undefined, then default to true
        gdprConsentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true
      };
    }

    validBidRequests.map(bid => {
      let config = CONFIG[bid.bidder];
      ENDPOINT_URL = config.BASE_URI;

      const placement = Object.assign({
        divName: bid.bidId,
        adTypes: bid.adTypes || getSize(bid.sizes),
        eventIds: [40, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295]
      }, bid.params);

      placement.adTypes.push(5, 9, 163, 2163, 3006);

      if (placement.networkId && placement.siteId) {
        data.placements.push(placement);
      }
    });

    ret.data = JSON.stringify(data);
    ret.bidRequest = validBidRequests;
    ret.url = ENDPOINT_URL;

    return ret;
  }
73914
async def insert_offer(self, **params):
		
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		# Check if required fields exists
		cid = int(params.get("cid", 0))
		txid = params.get("txid")
		coinid = params.get("coinid")
		public_key = params.get("public_key")

		database = client[coinid]
		offer_collection = database[settings.OFFER]
		await offer_collection.insert_one({"cid":cid, "txid":txid, 
											"confirmed":None, "coinid":coinid, 
											"public_key":public_key})

		return {"result":"ok"}
301738
async def get_offers(self, **params):
		
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		cid = params.get("cid")
		public_key = params.get("public_key")
		coinid = params.get("coinid")


		# Get all input offers by cid
		if cid and coinid:
			cid = int(cid)
			database = client[coinid]
			offer_collection = database[settings.OFFER]
			content_collection = database[settings.CONTENT]

			offers = [{i:document[i] for i in document if i == "confirmed"} 
						async for document in offer_collection.find({"cid":cid, "confirmed":None})]

		# Get all output users offers
		elif not cid:
			database = client[coinid]
			offer_collection = database[settings.OFFER]
			offers = [{i:document[i] for i in document if i == "confirmed"} 
						async for document in offer_collection.find({"public_key":public_key, 
																	"confirmed":None})]

		# Return list with offers
		return offers
785039
@Override
  public final void process(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    OnlineBuyer buyer = this.buySr.getBuyr(pRqVs, pRqDt);
    if (buyer == null) {
      buyer = this.buySr.createBuyr(pRqVs, pRqDt);
    }
    String nm = pRqDt.getParameter("nm");
    String em = pRqDt.getParameter("em");
    String pw = pRqDt.getParameter("pw");
    String pwc = pRqDt.getParameter("pwc");
    long now = new Date().getTime();
    String tbn = OnlineBuyer.class.getSimpleName();
    pRqDt.setAttribute("buyr", buyer);
    if (buyer.getRegEmail() == null) { //unregistered:
      if (nm != null && pw != null && pwc != null && em != null) {
        //creating:
        if (nm.length() > 2 && pw.length() > 7 && pw.equals(pwc)
          && em.length() > 5) {
          Set<String> ndFl = new HashSet<String>();
          ndFl.add("itsId");
          pRqVs.put(tbn + "neededFields", ndFl);
          List<OnlineBuyer> brs = getSrvOrm().retrieveListWithConditions(pRqVs,
            OnlineBuyer.class, "where REGEMAIL='" + em + "'");
          pRqVs.remove(tbn + "neededFields");
          if (brs.size() == 0) {
            buyer.setItsName(nm);
            buyer.setRegisteredPassword(pw);
            buyer.setRegEmail(em);
            buyer.setLsTm(now);
            UUID buseid = UUID.randomUUID();
            buyer.setBuSeId(buseid.toString());
            if (buyer.getIsNew()) {
              this.srvOrm.insertEntity(pRqVs, buyer);
            } else {
              this.srvOrm.updateEntity(pRqVs, buyer);
            }
            pRqDt.setCookieValue("cBuyerId", buyer.getItsId().toString());
            pRqDt.setCookieValue("buSeId", buyer.getBuSeId());
          } else if (brs.size() == 1) {
            pRqDt.setAttribute("errMsg", "emBusy");
          } else {
            getLog().error(pRqVs, PrLog.class,
              "Several users with same email!: " + em);
          }
        } else {
          pRqDt.setAttribute("errMsg", "buyCrRul");
        }
      } else if (pw != null && em != null) {
        //login from new browser
        pRqVs.put(tbn + "regCustomerdeepLevel", 1);
        pRqVs.put(tbn + "taxDestplacedeepLevel", 1);
        List<OnlineBuyer> brs = getSrvOrm().retrieveListWithConditions(
          pRqVs, OnlineBuyer.class, "where REGISTEREDPASSWORD='" + pw
            + "' and REGEMAIL='" + em + "'");
        pRqVs.remove(tbn + "regCustomerdeepLevel");
        pRqVs.remove(tbn + "taxDestplacedeepLevel");
        if (brs.size() == 1) {
          //free buyer and moving its cart by fast updates:
          mkFreBuyr(pRqVs,  pRqDt, buyer, brs.get(0));
        } else if (brs.size() == 0) {
          pRqDt.setAttribute("errMsg", "wrong_em_password");
        } else {
          getLog().error(pRqVs, PrLog.class,
            "Several users with same password and email!: " + em);
        }
      } else {
        spam(pRqVs, pRqDt);
      }
    } else { //registered:
      if (now - buyer.getLsTm() < 1800000L && buyer.getBuSeId() != null) {
        //there is opened session:
        String buSeId = pRqDt.getCookieValue("buSeId");
        if (buyer.getBuSeId().equals(buSeId)) {
          //authorized requests:
          String zip = pRqDt.getParameter("zip");
          String adr1 = pRqDt.getParameter("adr1");
          if (nm != null && zip != null  && adr1 != null) {
            //change name, shipping address:
            String cnt = pRqDt.getParameter("cnt");
            String cit = pRqDt.getParameter("cit");
            String adr2 = pRqDt.getParameter("adr2");
            String phn = pRqDt.getParameter("phn");
            if (nm.length() > 2 && zip.length() > 2 && adr1.length() > 2) {
              buyer.setItsName(nm);
              buyer.setRegZip(zip);
              buyer.setRegAddress1(adr1);
              buyer.setRegAddress2(adr2);
              buyer.setRegCountry(cnt);
              buyer.setRegCity(cit);
              buyer.setRegPhone(phn);
              buyer.setLsTm(now);
              this.srvOrm.updateEntity(pRqVs, buyer);
            } else {
              pRqDt.setAttribute("errMsg", "buyEmRul");
            }
          } else if (pw != null && pwc != null) {
            //change password:
            if (pw.length() > 7 && pw.equals(pwc)) {
              buyer.setRegisteredPassword(pw);
              buyer.setLsTm(now);
              this.srvOrm.updateEntity(pRqVs, buyer);
            } else {
              pRqDt.setAttribute("errMsg", "buyPwdRul");
            }
          } else {
            //logout action:
            buyer.setLsTm(0L);
            this.srvOrm.updateEntity(pRqVs, buyer);
          }
        } else { //either spam or buyer login from other browser without logout
          spam(pRqVs, pRqDt);
        }
      } else {
        //unauthorized requests:
        if (pw != null) {
          //login action:
          if (pw.equals(buyer.getRegisteredPassword())) {
            buyer.setLsTm(now);
            UUID buseid = UUID.randomUUID();
            buyer.setBuSeId(buseid.toString());
            pRqDt.setCookieValue("buSeId", buyer.getBuSeId());
            this.srvOrm.updateEntity(pRqVs, buyer);
          } else {
            pRqDt.setAttribute("errMsg", "wrong_password");
          }
        } else {
          spam(pRqVs, pRqDt);
        }
      }
    }
    String procNm = pRqDt.getParameter("nmPrcRed");
    IProcessor proc = this.procFac.lazyGet(pRqVs, procNm);
    proc.process(pRqVs, pRqDt);
  }
515438
def partially_valid_public_key?(point)
      return false if point.group != self
      return false if point.infinity?
      point_satisfies_equation?(point)
    end
1116678
def commit_sell(self, sell_id, **params):
        """"""
        return self.api_client.commit_sell(self.id, sell_id, **params)
1296005
def accept(source_port, destination_port, protocol, raw_addresses):
    '''
    
    '''

    protocol = protocol or 'tcp'

    if not isinstance(raw_addresses, list):
        raw_addresses = [raw_addresses]

    addresses = []
    for a in raw_addresses:
        if a is None:
            addresses.append(None)
        else:
            addresses += a.split(',')

    rules = []
    for address in addresses:
        parts = ['-A', CHAIN]

        if address:
            address, _, mask = address.partition('/')
            mask = mask or '32'
            parts.append('-s %s/%s' % (address, mask))

        if source_port:
            parts.append('-p %s -m %s --sport %s' % (protocol, protocol, source_port))

        if destination_port:
            parts.append('-p %s -m %s --dport %s' % (protocol, protocol, destination_port))

        parts += ['-j', 'RETURN']

        rules.append(' '.join(parts))

    return rules
707761
function(bidRequests, bidderRequest) {
    const userId = find(bidRequests, hasUserId);
    const pubcid = find(bidRequests, hasPubcid);
    const publisherId = find(bidRequests, hasPublisherId);
    const auctionId = find(bidRequests, hasAuctionId);
    let bidUrl = find(bidRequests, hasBidUrl);
    let url = find(bidRequests, hasUrl);
    let test = find(bidRequests, hasTestParam);
    const seats = find(bidRequests, hasSeatsParam);
    const deviceId = find(bidRequests, hasDeviceIdParam);
    const ifa = find(bidRequests, hasIfaParam);
    const tid = find(bidRequests, hasTidParam);
    bidUrl = bidUrl ? bidUrl.params.bidUrl : URL;
    url = url ? url.params.url : (config.getConfig('pageUrl') || utils.getTopWindowUrl());
    test = test ? test.params.test : undefined;
    var adRequests = bidRequests.map(bidToAdRequest);

    const payload = {
      auctionId: auctionId ? auctionId.auctionId : undefined,
      publisherId: publisherId ? publisherId.params.publisherId : undefined,
      userId: userId ? userId.params.userId : (pubcid ? pubcid.crumbs.pubcid : undefined),
      url: url,
      test: test,
      seats: seats ? seats.params.seats : undefined,
      deviceId: deviceId ? deviceId.params.deviceId : undefined,
      ifa: ifa ? ifa.params.ifa : undefined,
      tid: tid ? tid.params.tid : undefined,
      version: VERSION,
      gdprApplies: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.gdprApplies : undefined,
      gdprConsent: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.consentString : undefined,
      cookieSupport: !utils.isSafariBrowser() && utils.cookiesAreEnabled(),
      rcv: getAdblockerRecovered(),
      adRequests: [...adRequests]
    };
    const payloadString = JSON.stringify(payload);
    return {
      method: 'POST',
      url: bidUrl,
      data: payloadString,
    };
  }
1001648
@Override
  public final void process(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    OnlineBuyer buyer = this.buySr.getAuthBuyr(pRqVs, pRqDt);
    if (buyer == null) {
      String procNm = pRqDt.getParameter("nmPrcRed");
      IProcessor proc = this.procFac.lazyGet(pRqVs, procNm);
      proc.process(pRqVs, pRqDt);
      return;
    }
    SettingsAdd setAdd = (SettingsAdd) pRqVs.get("setAdd");
    String purIdStr = pRqDt.getParameter("pur");
    Long.parseLong(purIdStr);
    try {
      this.srvDb.setIsAutocommit(false);
      this.srvDb.setTransactionIsolation(setAdd.getBkTr());
      this.srvDb.beginTransaction();
      String tbn = CustOrder.class.getSimpleName();
      String whePuBr = "where PUR=" + purIdStr + " and BUYER="
        + buyer.getItsId();
      Set<String> ndFlNm = new HashSet<String>();
      ndFlNm.add("itsId");
      ndFlNm.add("itsName");
      pRqVs.put("PickUpPlaceneededFields", ndFlNm);
      pRqVs.put(tbn + "buyerdeepLevel", 1);
      List<CustOrder> ords = this.srvOrm.retrieveListWithConditions(pRqVs,
        CustOrder.class, whePuBr);
      pRqVs.remove(tbn + "buyerdeepLevel");
      tbn = CuOrSe.class.getSimpleName();
      Set<String> ndFlDc = new HashSet<String>();
      ndFlDc.add("seller");
      pRqVs.put("DebtorCreditorneededFields", ndFlNm);
      pRqVs.put("SeSellerneededFields", ndFlDc);
      pRqVs.put(tbn + "seldeepLevel", 3);
      pRqVs.put(tbn + "buyerdeepLevel", 1);
      List<CuOrSe> sords = this.srvOrm.retrieveListWithConditions(pRqVs,
        CuOrSe.class, whePuBr);
      pRqVs.remove(tbn + "buyerdeepLevel");
      pRqVs.remove("DebtorCreditorneededFields");
      pRqVs.remove("SeSellerneededFields");
      pRqVs.remove(tbn + "seldeepLevel");
      pRqVs.remove("PickUpPlaceneededFields");
      retLines(pRqVs, buyer, ords, sords);
      Purch pur = new Purch();
      pur.setOrds(ords);
      pur.setSords(sords);
      pRqDt.setAttribute("pur",  pur);
      this.srvDb.commitTransaction();
    } catch (Exception ex) {
      if (!this.srvDb.getIsAutocommit()) {
        this.srvDb.rollBackTransaction();
      }
      throw ex;
    } finally {
      this.srvDb.releaseResources();
    }
  }
1063240
def accept(self):
        '''
        
        '''
        result = dict(self.python_data)
        for field in self.fields:
            if field.writable:
                result.update(field.accept())
            else:
                # readonly field
                field.set_raw_value(self.form.raw_data,
                                    field.from_python(result[field.name]))
        self.clean_value = self.conv.accept(result)
        return {self.name: self.clean_value}
877763
async def write_deal(self, **params):
		
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		cid = int(params.get("cid", 0))
		access_type = params.get("access_type")
		buyer = params.get("buyer")
		seller = params.get("seller")
		price = params.get("price")
		coinid = params.get("coinid")

		try:
			coinid = coinid.replace("TEST", "")
		except:
			pass

		if not all([cid, access_type, buyer, seller, price]):
			return {"error":400, "reason":"Missed required fields"}

		database = client[coinid]
		collection = database[settings.DEAL]
		await collection.insert_one({
				"cid":cid,
				"access_type": access_type,
				"buyer":buyer,
				"seller":seller,
				"price":price,
				"coinid":coinid
			})
		result = await collection.find_one({"cid":cid, "buyer":buyer})

		return {i:result[i] for i in result if i != "_id"}
820736
async def get_offer(self, **params):
		
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		# Check if required fields exists
		cid = int(params.get("cid", 0))
		coinid = params.get("coinid")
		buyer_address = params.get("buyer_address")
		
		# Check if required fileds 
		if not all([cid, buyer_address, coinid]):
			return {"error":400, "reason":"Missed required fields"}
		
		# Get buyer address row from database
		database = client[coinid]
		wallet_collection = database[settings.WALLET]
		wallet = await wallet_collection.find_one({"wallet":buyer_address})
		if not wallet:
			return {"error":404, "reason":"Buyer address not found"}
		
		# Try to find offer with account id and cid
		offer_collection = database[settings.OFFER]
		offer = await offer_collection.find_one(
							{"account_id":int(wallet["account_id"]),
							"cid":int(cid)})

		# If current offer exists avoid creating a new one
		if not offer:
			return {"error":404, "reason": "Current offer not found"}
		else:
			offer["coinid"] = coinid
			return {i:offer[i] for i in offer if i != "_id"}
1083659
def accept(self):
        
        while 1:
            try:
                sock, addr = self._sock.accept()
                return (type(self)(sock,
                    keyfile=self.keyfile,
                    certfile=self.certfile,
                    server_side=True,
                    cert_reqs=self.cert_reqs,
                    ssl_version=self.ssl_version,
                    ca_certs=self.ca_certs,
                    do_handshake_on_connect=self.do_handshake_on_connect,
                    suppress_ragged_eofs=self.suppress_ragged_eofs,
                    ciphers=self.ciphers), addr)
            except socket.error, exc:
                if exc.args[0] not in (errno.EAGAIN, errno.EWOULDBLOCK):
                    raise
                sys.exc_clear()
                self._wait_event(self.gettimeout())
1232198
function(bidRequests, bidderRequest) {
    const tags = bidRequests.map(bidToTag);
    const userObjBid = find(bidRequests, hasUserInfo);
    let userObj;
    if (userObjBid) {
      userObj = {};
      Object.keys(userObjBid.params.user)
        .filter(param => includes(USER_PARAMS, param))
        .forEach(param => userObj[param] = userObjBid.params.user[param]);
    }

    const memberIdBid = find(bidRequests, hasMemberId);
    const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0;

    const payload = {
      tags: [...tags],
      user: userObj,
      sdk: {
        source: SOURCE,
        version: '$prebid.version$'
      }
    };
    if (member > 0) {
      payload.member_id = member;
    }

    if (bidderRequest && bidderRequest.gdprConsent) {
      // note - objects for impbus use underscore instead of camelCase
      payload.gdpr_consent = {
        consent_string: bidderRequest.gdprConsent.consentString,
        consent_required: bidderRequest.gdprConsent.gdprApplies
      };
    }

    const payloadString = JSON.stringify(payload);
    return {
      method: 'POST',
      url: URL,
      data: payloadString,
      bidderRequest
    };
  }
182511
async def update_offer(self, **params):
		
		logging.debug("\n\n -- Update offer. ")
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		# Check if required fields exists
		txid = params.get("txid")
		coinid = params.get("coinid").upper()

		try:
			coinid = coinid.replace("TEST", "")
		except:
			pass

		# Try to find offer with account id and cid
		database = client[coinid]
		offer_db = database[settings.OFFER]
		offer = await offer_db.find_one({"txid":txid})
		logging.debug("\n\n -- Try to get offer. ")
		logging.debug(offer)
		if not offer:
			return {"error":404, 
					"reason":"Offer with txid %s not found" % txid }

		# Update offer
		await offer_db.find_one_and_update(
							{"txid":txid}, {"$set":{"confirmed":1}})

		# Get updated offer
		updated = await offer_db.find_one({"txid":txid})

		return {i:updated[i] for i in updated if i != "_id"}
876878
def accept_all(self):
        '''
        
        '''
        keys = self.list_keys()
        for key in keys[self.PEND]:
            try:
                shutil.move(
                        os.path.join(
                            self.opts['pki_dir'],
                            self.PEND,
                            key),
                        os.path.join(
                            self.opts['pki_dir'],
                            self.ACC,
                            key)
                        )
                eload = {'result': True,
                         'act': 'accept',
                         'id': key}
                self.event.fire_event(eload,
                                      salt.utils.event.tagify(prefix='key'))
            except (IOError, OSError):
                pass
        return self.list_keys()