def save(self, *args, **kwargs): if not self.pk: first48 = "{}{}".format(uuid.uuid4(), uuid.uuid4()).replace("-", "")[:48] md5 = hashlib.md5() md5.update("{}{}".format(settings.SECRET_KEY, first48)) reverse_track = reverse('betting_track', kwargs={ 'secret': md5.hexdigest(), 'first48': first48 }) try: recv = receive.receive( settings.BITCOIN_JACKPOT_ADDRESS, '{}{}'.format(settings.BASE_DOMAIN, reverse_track)) except Exception, e: LogUtils().error('bcjp.file', 'models', 'BitcoinAddressSession', e) raise e LogUtils().info('bcjp.file', 'models', 'BitcoinAddressSession', "{}".format(recv.callback_url)) self.address = recv.input_address self.alias = random.choice(settings.ALIAS_WORDS).title() super(BitcoinAddressSession, self).save(*args, **kwargs) self.session = "{}-{}".format(self.pk, first48)
def save(self, *args, **kwargs): if not self.pk: first48 = "{}{}".format(uuid.uuid4(), uuid.uuid4()).replace("-", "")[:48] md5 = hashlib.md5() md5.update("{}{}".format(settings.SECRET_KEY, first48)) reverse_track = reverse('betting_track', kwargs={'secret': md5.hexdigest(), 'first48': first48}) try: recv = receive.receive(settings.BITCOIN_JACKPOT_ADDRESS, '{}{}'.format(settings.BASE_DOMAIN, reverse_track)) except Exception, e: LogUtils().error('bcjp.file', 'models', 'BitcoinAddressSession', e) raise e LogUtils().info('bcjp.file', 'models', 'BitcoinAddressSession', "{}".format(recv.callback_url)) self.address = recv.input_address self.alias = random.choice(settings.ALIAS_WORDS).title() super(BitcoinAddressSession, self).save(*args, **kwargs) self.session = "{}-{}".format(self.pk, first48)
def receive(dest_addr=BLOCKCHAIN_DESTINATION_ADDRESS, cb_url=BLOCKCHAIN_RECEIVE_API_ENDPOINT, api_code=None): """Wrap the receive function here instead of the manager or wherever XXX: This method should be allowed to fail cleanly! """ utils.check_addr(dest_addr) utils.check_cb_url(cb_url) res = bc_receive.receive(dest_addr, cb_url, api_code=api_code) new = ReceiveResponse() for field in ReceiveResponse._meta.get_all_field_names(): if field == 'id': continue setattr(new, field, getattr(res, field)) new.save() return new
###blockchain python api recieve module: https://github.com/blockchain/api-v1-client-python/blob/master/docs/receive.md### from blockchain import receive response = receive.receive('input_address : str', 'destination_address : str')
###blockchain python api recieve module: https://github.com/blockchain/api-v1-client-python/blob/master/docs/receive.md### from blockchain import receive response = receive.receive('input_address : str','destination_address : str')