Redeem an HTLC contract
165317
def redeem(ctx, htlc_id, secret, account):
    
    print_tx(ctx.blockchain.htlc_redeem(htlc_id, secret, account=account))
235901
def parse_multisig_redeemscript( redeem_script_hex ):
    
    script_parts = []
    redeem_script_hex = str(redeem_script_hex)

    try:
        script_parts = btc_script_deserialize(redeem_script_hex)
    except:
        if os.environ.get("BLOCKSTACK_TEST") == "1":
            traceback.print_exc()

        log.error("Invalid redeem script %s" % redeem_script_hex)
        return None, None

    try:
        assert len(script_parts) > 2
        assert script_parts[-1] == OPCODE_VALUES['OP_CHECKMULTISIG']
        script_parts.pop(-1)

        # get n
        n = script_parts.pop(-1)
        pubkeys = []

        # get m
        m = script_parts.pop(0)

        for i in xrange(0, n):
            pubk = script_parts.pop(0)
            
            # must be a public key
            BitcoinPublicKey(pubk)
            pubkeys.append(pubk)

        assert len(script_parts) == 0, "script_parts = %s" % script_parts
        return (m, pubkeys)
    except Exception, e:
        if os.environ.get("BLOCKSTACK_TEST") == "1":
            traceback.print_exc()

        log.error("Invalid redeem script %s (parses to %s)" % (redeem_script_hex, script_parts))
        return (None, None)
864919
def transact(
            self,
            contract_method: ContractFunction,
    ):
        
        txhash = contract_method.transact(self.transaction)
        LOG.debug(f'Sending txHash={encode_hex(txhash)}')
        (receipt, _) = check_successful_tx(
            web3=self.web3,
            txid=txhash,
            timeout=self.wait,
        )
        return receipt
209582
def reqRealTimeBars(self, id, contract, barSize, whatToShow, useRTH, realTimeBarsOptions):
        """"""
        return _swigibpy.EClientSocketBase_reqRealTimeBars(self, id, contract, barSize, whatToShow, useRTH, realTimeBarsOptions)
375734
def _ttl(self):
        """"""
        return self.hlim if isinstance(self, scapy.layers.inet6.IPv6) else self.ttl
600943
def cancelTickByTickData(self, contract: Contract, tickType: str):
        
        ticker = self.ticker(contract)
        reqId = self.wrapper.endTicker(ticker, tickType)
        if reqId:
            self.client.cancelTickByTickData(reqId)
        else:
            self._logger.error(
                f'cancelMktData: No reqId found for contract {contract}')
232704
def get_tx(tx_id, api_code=None):
    

    resource = 'rawtx/' + tx_id
    if api_code is not None:
        resource += '?api_code=' + api_code
    response = util.call_api(resource)
    json_response = json.loads(response)
    return Transaction(json_response)
1351867
def load_contract
      req = { "jsonrpc" => "2.0", "id" => "1", "method" => "barrister-idl" }
      resp = @trans.request(req)
      if resp.key?("result")
        @contract = Contract.new(resp["result"])
      else
        raise RpcException.new(-32000, "Invalid contract response: #{resp}")
      end
    end
499653
def to_h
      {}.tap do |h|
        ALLOWED_PARAMS.each { |p| h[p] = send(p) }
        h[:txn_status_message] = txn_status_message
        h[:txn_type_message] = txn_type_message
      end
    end
34550
def pack_req(cls, code, trd_env, acc_id, trd_mkt, conn_id):
        """"""
        from futuquant.common.pb.Trd_GetOrderFillList_pb2 import Request
        req = Request()
        req.c2s.header.trdEnv = TRD_ENV_MAP[trd_env]
        req.c2s.header.accID = acc_id
        req.c2s.header.trdMarket = TRD_MKT_MAP[trd_mkt]

        if code:
            req.c2s.filterConditions.codeList.append(code)

        return pack_pb_req(req, ProtoId.Trd_GetOrderFillList, conn_id)
611617
def cancelMarketDepth(self, contracts=None):
        
        if contracts == None:
            contracts = list(self.contracts.values())
        elif not isinstance(contracts, list):
            contracts = [contracts]

        for contract in contracts:
            tickerId = self.tickerId(self.contractString(contract))
            self.ibConn.cancelMktDepth(tickerId=tickerId)
856100
def tmsiReallocationCommand():
    """"""
    a = TpPd(pd=0x5)
    b = MessageType(mesType=0x1a)  # 00011010
    c = LocalAreaId()
    d = MobileId()
    packet = a / b / c / d
    return packet
410371
def lock_reward(self, agreement_id, amount, account):
        
        return self._keeper.lock_reward_condition.fulfill(
            agreement_id, self._keeper.escrow_reward_condition.address, amount, account
        )
1346910
def activate(self, timeout=None, **options):
        """"""

        if timeout is None:
            timeout = 1.0
        gbt = options.get('gbt', '')[0:47]
        lrt = min(max(0, options.get('lrt', 3)), 3)
        rwt = min(max(0, options.get('rwt', 8)), 14)

        pp = (lrt << 4) | (bool(gbt) << 1) | int(bool(self.nad))
        nfcid3t = bytearray.fromhex("01FE") + os.urandom(6) + "ST"
        atr_res = ATR_RES(nfcid3t, 0, 0, 0, rwt, pp, gbt)
        atr_res = atr_res.encode()

        target = nfc.clf.LocalTarget(atr_res=atr_res)
        target.sens_res = bytearray.fromhex("0101")
        target.sdd_res = bytearray.fromhex("08") + os.urandom(3)
        target.sel_res = bytearray.fromhex("40")
        target.sensf_res = bytearray.fromhex("01") + nfcid3t[0:8]
        target.sensf_res += bytearray.fromhex("00000000 00000000 FFFF")

        target = self.clf.listen(target, timeout)

        if target and target.atr_req and target.dep_req:
            log.debug("activated as " + str(target))

            atr_req = ATR_REQ.decode(target.atr_req)
            self.lrt = lrt
            self.gbt = gbt
            self.gbi = atr_req.gb
            self.miu = atr_req.lr - 3
            self.rwt = 4096/13.56E6 * pow(2, rwt)
            self.did = atr_req.did if atr_req.did > 0 else None
            self.acm = not (target.sens_res or target.sensf_res)
            self.cmd = chr(len(target.dep_req)+1) + target.dep_req
            if target.brty == "106A":
                self.cmd = b"\xF0" + self.cmd
            self.target = target

            self.pcnt.rcvd["ATR"] += 1
            self.pcnt.sent["ATR"] += 1
            log.info("running as " + str(self))

            return self.gbi
396479
def index
      # Check if search param is present
      if params[:search].blank?
        @admin_redeem_codes = DealRedemptions::RedeemCode.page(params[:page]).order(:code).includes(:company)
      else
        query = DealRedemptions::Redemption.find_by_sql(build_search_query)
        @admin_redeem_codes = Kaminari.paginate_array(query).page(params[:page])
      end
    end
978553
def applyVoucherCodesFinal(sender,**kwargs):
    '''
    
    '''
    logger.debug('Signal fired to mark voucher codes as applied.')

    finalReg = kwargs.pop('registration')
    tr = finalReg.temporaryRegistration

    tvus = TemporaryVoucherUse.objects.filter(registration=tr)

    for tvu in tvus:
        vu = VoucherUse(voucher=tvu.voucher,registration=finalReg,amount=tvu.amount)
        vu.save()
        if getConstant('referrals__enableReferralProgram'):
            awardReferrers(vu)
350347
def acquire(self):
        """"""
        self.lease = self.client.lease(self.ttl)

        base64_key = _encode(self.key)
        base64_value = _encode(self._uuid)
        txn = {
            'compare': [{
                'key': base64_key,
                'result': 'EQUAL',
                'target': 'CREATE',
                'create_revision': 0
            }],
            'success': [{
                'request_put': {
                    'key': base64_key,
                    'value': base64_value,
                    'lease': self.lease.id
                }
            }],
            'failure': [{
                'request_range': {
                    'key': base64_key
                }
            }]
        }
        result = self.client.transaction(txn)
        if 'succeeded' in result:
            return result['succeeded']
        return False