Пример #1
0
    def post(self):
        user = self.get_current_user()
        try:
            new_address = self.get_argument('address')
        except tornado.web.MissingArgumentError:
            self.redirect('/')

        user.btc_address = new_address
        subscribe_to_address_webhook(
            callback_url='https://blockpop.xyz/btc/new-tx',
            subscription_address=new_address,
            event='confirmed-tx',
            api_key=BLOCK_CYPHER_KEY)
Пример #2
0
def set_webhook(from_address,
                to_address,
                transaction_id,
                coin_symbol,
                event='tx-confirmation'):

    domain = settings.DOMAIN_NAME

    signature = signing.dumps({
        'from_address': from_address,
        'to_addresses': to_address,
        'symbol': coin_symbol,
        'event': event,
        'transaction_id': transaction_id,
    })

    callback_url = 'https://{}{}'.format(
        domain, reverse('wallets:webhook', kwargs={'signature': signature}))

    webhook = blockcypher.subscribe_to_address_webhook(
        callback_url=callback_url,
        subscription_address=from_address,
        event=event,
        coin_symbol=coin_symbol,
        api_key=get_api_key())
    return webhook
Пример #3
0
 async def subscribe_webhook(self, address):
     hooks = blockcypher.list_webhooks(self.api_key,
                                       coin_symbol=self.coin_symbol)
     already_subscribed = False
     webhook_id = None
     for h in hooks:
         if address == h['address']:
             already_subscribed = True
             webhook_id = h['id']
     if not already_subscribed:
         webhook_id = blockcypher.subscribe_to_address_webhook(
             callback_url="{callback_url}".format(
                 callback_url=self.callback_url, ),
             # confirmations=7,
             event='confirmed-tx',
             subscription_address=address,
             api_key=self.api_key,
             coin_symbol=self.coin_symbol)
     return webhook_id
Пример #4
0
    def set_webhook(self,
                    to_addresses: List[str],
                    transaction: str,
                    obj: object = None,
                    invoice: object = None,
                    event: str = 'tx-confirmation') -> str:
        domain = settings.DOMAIN_NAME
        if obj:
            try:
                obj = signing.dumps({
                    'app_label': obj._meta.app_label,
                    'model': obj._meta.model_name,
                    'id': obj.id
                })
            except Exception:
                obj = None

        signature = signing.dumps({
            'from_address': self.address,
            'to_addresses': to_addresses,
            'symbol': self.coin_symbol,
            'event': event,
            'transaction_id': transaction,
            'invoice_id': invoice.id if invoice else None,
            'content_object': obj
        })
        callback_url = 'https://{}/wallets/webhook/{}/'.format(
            domain, signature)
        webhook = blockcypher.subscribe_to_address_webhook(
            callback_url=callback_url,
            subscription_address=self.address,
            event=event,
            coin_symbol=self.coin_symbol,
            api_key=get_api_key()  # settings.BLOCKCYPHER_API_KEY
        )
        return webhook
Пример #5
0
from blockcypher import subscribe_to_address_webhook

subscribe_to_address_webhook(
    callback_url='https://test-bitkye.ngrok.io/callback',
    subscription_address='tb1q0d72sjqutecj8wyuj5lg3ge3w5fwrvc2rkrvjw',
    event='confirmed-tx',
    api_key='b09ab54de88b480e9ee023d935527ba7')
Пример #6
0
def subscribe():
    subscribe_to_address_webhook(callback_url=' https://77b9a69d.ngrok.io',
                                 subscription_address='',
                                 event='confirmed-tx',
                                 api_key='')  #removed for privacy