示例#1
0
def step_impl(context):
    first_user_bcy_wallet = context.first_user.bcy_wallets.first()
    second_user_bcy_wallet = context.second_user.bcy_wallets.first()
    context.test.assertNotEqual(first_user_bcy_wallet, None)
    context.test.assertNotEqual(second_user_bcy_wallet, None)

    blockcypher.send_faucet_coins(
        address_to_fund=first_user_bcy_wallet.address,
        satoshis=100000,
        api_key=settings.BLOCKCYPHER_API_KEY,
        coin_symbol='bcy')
    time.sleep(60)
    signature = mock.MagicMock(
        return_value=
        'eyJldmVudCI6ImNvbmZpcm1lZC10eCIsInN5bWJvbCI6ImJjeSIsInRvX2FkZHJlc3MiOiJDN3FtQlN1dTlMTFF3RHhpZ0ZiMTRMeGRTSFBOVW9mbWtiIiwiZnJvbV9hZGRyZXNzIjoiQnZlU2lDdERkOGIyTVFnbkRCRTlkWWgyOTlNZGNzZXg1MyIsInRyYW5zYWN0aW9uX2lkIjoiYTc3NmZiNmIxZWY2NTZkZDBiNmI4ZTUyOGIzMTA3ZWM5NWY5Njc0ZWQ1ZDMyMWM2YTgzOTY3YjhkNzE0MGJjOCJ9:1f3nBn:5zSoXFPi8SKut2mHrTn9FDZMTYw'
    )

    context.transaction = first_user_bcy_wallet.spend_with_webhook(
        address=second_user_bcy_wallet.address, amount=from_satoshi(1000))

    context.test.assertNotEqual(context.transaction, None)

    blockcypher.list_webhooks = mock.MagicMock(return_value=[{
        'address':
        'BuHUupxf4UdHStZvhtrjmncFa8NhFCLB1x',
        'event':
        'confirmed-tx',
        'callback_errors':
        0,
        'token':
        '75ada547a1524310971733088eb068ec',
        'url':
        'https://localhost/wallets/webhook/eyJ0cmFuc2FjdGlvbl9pZCI6IjA5N2YzNjQ2NDVlZjExYWNlNTE1MjQ0ZmUyMGM4ZDdhNGUxZGFiYjRiNGE2ZDNlNTQyMDMwNzQyYTA5MmEzYzgiLCJmcm9tX2FkZHJlc3MiOiJCdUhVdXB4ZjRVZEhTdFp2aHRyam1uY0ZhOE5oRkNMQjF4Iiwic3ltYm9sIjoiYmN5IiwidG9fYWRkcmVzcyI6IkMxQ2FNVmh4VHlpRm01ZW1DamdqV0htNUNzdG9pb1pMcFUiLCJldmVudCI6ImNvbmZpcm1lZC10eCJ9:1f3n8X:ZofyAC2ihv1WN86PXYwAh-ZqM0E/',
        'id':
        'b8224122-28bf-47cf-be3c-48677acb9fd5'
    }, {
        'address':
        'BveSiCtDd8b2MQgnDBE9dYh299Mdcsex53',
        'event':
        'confirmed-tx',
        'callback_errors':
        0,
        'token':
        '75ada547a1524310971733088eb068ec',
        'url':
        'https://localhost/wallets/webhook/eyJldmVudCI6ImNvbmZpcm1lZC10eCIsInN5bWJvbCI6ImJjeSIsInRvX2FkZHJlc3MiOiJDN3FtQlN1dTlMTFF3RHhpZ0ZiMTRMeGRTSFBOVW9mbWtiIiwiZnJvbV9hZGRyZXNzIjoiQnZlU2lDdERkOGIyTVFnbkRCRTlkWWgyOTlNZGNzZXg1MyIsInRyYW5zYWN0aW9uX2lkIjoiYTc3NmZiNmIxZWY2NTZkZDBiNmI4ZTUyOGIzMTA3ZWM5NWY5Njc0ZWQ1ZDMyMWM2YTgzOTY3YjhkNzE0MGJjOCJ9:1f3nBm:19f0N3vJNNRADNtBNeszrruc0BA/',
        'id':
        'dbe0bd20-9e25-4649-b2ae-d6e388d94e74'
    }])

    def handler(sender, kwargs):
        print('KWARGS: ' + str(kwargs))

    context.response = context.test.client.post(
        reverse('wallets:webhook', kwargs={'signature': signature}))

    get_webhook.connect(handler)
    time.sleep(10)
    get_webhook.disconnect(handler)
示例#2
0
def show_me_the_money(money=400000,addr=myaddr1):
    '''
    :param money: everytime < 500,000, total < 100,000,000
    :return:
    '''
    # addr="mgN94Z7hRWy4UfZHTj2T8hZd1BctusLkps"
   # addr="mzPnKxCTMF3Dx9Nx9ktZ6n72LFheEX3MpQ"
    token=mytoken
    send_faucet_coins(address_to_fund=addr,\
                  api_key=token,\
                  coin_symbol='btc-testnet',\
                  satoshis=money)
    print 'money is done !'
示例#3
0
 def testnet_coin_submit(self):
     """
     Metodo para envio de coins na rede testnet
     :return: Hash da transacao realizada
     :rtype: str
     """
     if self.satoshi <= 0:
         raise ValidationError('O valor para Satoshis deve ser maior que zero.')
     try:
         datas = send_faucet_coins(address_to_fund=self.address,
                                   satoshis=self.satoshi,
                                   api_key=self.token)
     except:
         raise ValidationError('Coins nao enviados. Verifique o endereco '
                               'e/ou token informados.')
     tx_hash = datas.get('tx_ref')
     self.write({'name': tx_hash, 'state': 'D',
                 'date_time': time.strftime('%Y-%m-%d %H:%M:%S')})
     return tx_hash
 async def send_faucet_money(self, satoshis: int, address_to_fund: str):
     send_faucet_coins(api_key=self.api_key,
                       satoshis=satoshis,
                       address_to_fund=address_to_fund)
示例#5
0
 def showmethemoney(self):
     print send_faucet_coins(address_to_fund=self.address["address"],
                             satoshis=100000000,
                             api_key=Token,
                             coin_symbol='bcy')