Esempio n. 1
0
    def bc_portfel_getinfo_funkcja(self,event):
        try:
            wallet_adress = self.bc_portfel_nr_input.GetValue() 
            #wallet_adress = '1BTCorgHwCg6u2YSAWKgS17qUad6kHmtQW'
            #ltc LbtF3xpYFvocPqXjuYok8cahJ3GWeDA5w1
            #dodge DPHPoGQVKwgDsSG7r9329V45fLi7fpBWjA
            #dash XitN7K1KLTc6kd7MBZMSkzFH8XwejukXWz

            coin_symbol =  self.lista_krypto.GetStringSelection() 
            bc_wallet_details = blockcypher.get_address_details(wallet_adress,coin_symbol=coin_symbol)
            print('bc_wallet_details',bc_wallet_details)
            
            wallet_address = 'adres portfela: ' + str(bc_wallet_details['address'])
            print(wallet_address)
            if coin_symbol == 'btc':
                wallet_total_received = 'Otrzymane: ' + str(blockcypher.from_satoshis(bc_wallet_details['total_received'], coin_symbol)) + ' ' + coin_symbol.upper()
                wallet_total_sent = 'Wysłane: ' + str(blockcypher.from_satoshis(bc_wallet_details['total_sent'], coin_symbol)) + ' ' + coin_symbol.upper()
                wallet_balance = 'Saldo: ' + str(blockcypher.from_satoshis(bc_wallet_details['balance'], coin_symbol)) + ' ' + coin_symbol.upper()
                wallet_unconfirmed_balance = 'Saldo niepotwierdzone: ' + str(blockcypher.from_satoshis(bc_wallet_details['unconfirmed_balance'], coin_symbol)) + ' ' + coin_symbol.upper()
                wallet_final_balance = 'Saldo ostateczne: ' + str(blockcypher.from_satoshis(bc_wallet_details['final_balance'], coin_symbol)) + ' ' + coin_symbol.upper()

            else:
                wallet_total_received = 'Otrzymane: ' + str(bc_wallet_details['total_received']) + ' ' + coin_symbol.upper()
                wallet_total_sent = 'Wysłane: ' + str(bc_wallet_details['total_sent']) + ' ' + coin_symbol.upper()     
                wallet_balance = 'Saldo: ' + str(bc_wallet_details['balance']/100000000) + ' ' + coin_symbol.upper()
                wallet_unconfirmed_balance = 'Saldo niepotwierdzone: ' + str(bc_wallet_details['unconfirmed_balance']/100000000) + ' ' + coin_symbol.upper()
                wallet_final_balance = 'Saldo ostateczne: ' + str(bc_wallet_details['final_balance']/100000000) + ' ' + coin_symbol.upper()
    
            wallet_nr_transactions = 'Ilość transakcji: ' + str(bc_wallet_details['n_tx'])
            wallet_unconfirmed_nr_transactions = 'Ilość niepotwierdzonych transakcji: : '+str(bc_wallet_details['unconfirmed_n_tx'])
            wallet_final_nr_transactions = 'Ostateczna ilość transakcji: : '+str(bc_wallet_details['final_n_tx'])

            wx.MessageBox((str(wallet_address) +'\n' +'\n' +'\n'  + str(wallet_balance)+'\n'  + str(wallet_unconfirmed_balance)+'\n' + str(wallet_final_balance)+'\n'  + str(wallet_nr_transactions)+'\n'  + str(wallet_unconfirmed_nr_transactions)+'\n'  + str(wallet_final_nr_transactions)), 'Informacje o portfelu' ,wx.OK | wx.ICON_INFORMATION)  
        except:
            wx.MessageBox('Błąd - sprawdź adres i typ kryptowaluty. \nJeżeli błąd się powtarza spróbuj później lub skontaktuj się z IccI - support.', 'Informacje o bloku' ,wx.OK | wx.ICON_INFORMATION)
Esempio n. 2
0
def convert_from_satoshi(amount):
    """
    Convert a particular satoshi amount to btc
    :param amount: Amount in satoshi unit
    :return: converted btc amount
    """
    return blockcypher.from_satoshis(amount, "btc")
Esempio n. 3
0
 async def get_balance(wallet_address, coin_symbol):
     try:
         satoshi_balance = blockcypher.get_total_balance(
             wallet_address, coin_symbol=coin_symbol)
         btc_balance = blockcypher.from_satoshis(satoshi_balance, 'btc')
     except AssertionError:  # wrong wallet_address
         btc_balance = None
     return btc_balance
Esempio n. 4
0
def wallet_check(addr):

    values = {}
    '''
    Alternative URLs to try is stuff breaks
    #https://blockexplorer.com/api/addr/1GXazHVQUdJEtpe62UFozFibPa8ToDoUn3/balance
    #https://blockexplorer.com/api/addr/1GXazHVQUdJEtpe62UFozFibPa8ToDoUn3/totalReceived
    '''
    url = "https://blockchain.info/address/{}?format=json".format(addr)
    resp = requests.get(url).json()

    values['balance'] = '{:.10f}'.format(
        blockcypher.from_satoshis(resp['final_balance'], 'btc'))
    values['total'] = '{:.10f}'.format(
        blockcypher.from_satoshis(resp['total_received'], 'btc'))

    return values
Esempio n. 5
0
def get_address_txs(address):
    address_details = blockcypher.get_address_details(
        address,
        coin_symbol="btc-testnet",
        api_key="acb0b8a2fe3d479c8b05b415ded8021e")
    confirmed_txs = address_details['txrefs']
    unconfirmed_txs = address_details['unconfirmed_txrefs']
    address_txs = []
    for tx in confirmed_txs:
        address_txs.append([
            tx['confirmed'], tx['tx_hash'],
            blockcypher.from_satoshis(tx['value'], 'btc')
        ])
    for tx in unconfirmed_txs:
        address_txs.append([
            tx['received'], tx['tx_hash'],
            blockcypher.from_satoshis(tx['value'], 'btc')
        ])
    address_txs = list(reversed(sorted(address_txs, key=itemgetter(0))))
    return address_txs
Esempio n. 6
0
    def history(address):
        total_details = get_address_details(address, coin_symbol='btc-testnet')

        transaction_history = []
        if (total_details['unconfirmed_balance'] != 0):
            for tx in total_details['unconfirmed_txrefs']:
                transaction = {}
                transaction['tx_hash'] = tx['tx_hash']
                transaction['data'] = tx['received']
                transaction['confirmations'] = tx['confirmations']
                transaction['value'] = from_satoshis(tx['value'], 'btc')

                transaction_history.append(transaction)

        for tx in total_details['txrefs']:
            transaction = {}
            transaction['tx_hash'] = tx['tx_hash']
            transaction['data'] = tx['confirmed']
            transaction['confirmations'] = tx['confirmations']
            transaction['value'] = from_satoshis(tx['value'], 'btc')

            transaction_history.append(transaction)

        return transaction_history
Esempio n. 7
0
    def CheckWallets(self):
        print('%s  ---- Start WalletAddressChecker.CheckWallets ----' %
              (datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
        timer = Timer()
        timer.start()

        recent_data = {}
        dataFromDB = dict(self.dba.getWalletsTable())

        # Получить обновление балансов по проверяемым кошелькам
        for address, title in self.wallets.items():
            balance = blockcypher.get_total_balance(address)
            recent_data[address] = (title,
                                    blockcypher.from_satoshis(balance, 'btc'))

        isChange = 0
        text = ""
        for key, value in recent_data.items():
            walletTitle = value[0]
            balance = value[1]
            if dataFromDB.get(key) == None:
                isChange = 1
                continue
            if dataFromDB.get(key) > balance:
                isChange = 1
                text = '\n'.join([
                    text,
                    "С адреса {0:s} {1:s} отправлено {2:.8f} BTC ".format(
                        key, walletTitle, balance - dataFromDB[key])
                ])
            elif dataFromDB.get(key) < balance:
                isChange = 1
                text = '\n'.join([
                    text, "Адрес {0:s} {1:s} получил {2:.8f} BTC".format(
                        key, walletTitle, balance - dataFromDB[key])
                ])

        if isChange > 0:
            self.dba.refreshWalletsTable([(k, v[0], v[1])
                                          for k, v in recent_data.items()])
            self.messageSender.sendMessage(text)

        print(
            '----End process WalletAddressChecker.CheckWallets. Time is %s ----'
            % timer.stop())
Esempio n. 8
0
def get_latest_txs(address):
    address_details = blockcypher.get_address_details(
        address,
        coin_symbol="btc-testnet",
        api_key="acb0b8a2fe3d479c8b05b415ded8021e")
    confirmed_txs = address_details['unconfirmed_txrefs']
    unconfirmed_txs = address_details['txrefs']
    latest_txs = []
    for tx in unconfirmed_txs + confirmed_txs:
        if tx['confirmations'] <= 3:
            try:
                received = tx['received']
            except KeyError:
                received = tx['confirmed']
            amount = blockcypher.from_satoshis(tx['value'], 'btc')
            latest_txs.append([
                tx['tx_hash'],
                format_date(received),
                format_time(received), amount, tx['confirmations']
            ])
    return latest_txs[:1]
Esempio n. 9
0
def check_priv_key(priv_key):
    try:
        address = privkey_to_address(priv_key)
        print("try priv key {}".format(priv_key))
        print("generated public key {}".format(address))
        addr_overview = get_address_overview(address)  #getting address data
        for key, value in addr_overview.items(
        ):  #getting info from address overview
            #check past transactions
            if key == 'final_n_tx':  #check for any transactions in the past
                if value > 0:  #if exist, then address has been used
                    print("Address has been used {0} times in the past".format(
                        value))
                    print(priv_key)
                    print(address)
            #check balance
            if key == 'final_balance':  #check for funds in the address
                if value > 0:  #if any btc left on address, print details
                    print("Address has balance of {0}".format(
                        from_satoshis(value, 'btc')))
    except:
        #this happens if string doesn't generate valid key
        return None
Esempio n. 10
0
 def total_balance(address):
     total_details = get_address_details(address,
                                         coin_symbol='btc-testnet',
                                         confirmations=2)
     return from_satoshis(total_details['balance'], 'btc')
Esempio n. 11
0
def litecoin_balance(litecoin_public_key):
    litecoin_public_key = str(litecoin_public_key)
    sat_balance = blockcypher.get_total_balance(litecoin_public_key, 'ltc')
    ltc_balance = blockcypher.from_satoshis(sat_balance, 'btc')
    return ltc_balance
Esempio n. 12
0
def dash_balance(dash_public_key):
    dash_public_key = str(dash_public_key)
    sat_balance = blockcypher.get_total_balance(dash_public_key, 'dash')
    dash_balance = blockcypher.from_satoshis(sat_balance, 'btc')
    return dash_balance
Esempio n. 13
0
def bitcoin_balance(bitcoin_public_key):
    bitcoin_public_key = str(bitcoin_public_key)
    sat_balance = blockcypher.get_total_balance(bitcoin_public_key)
    btc_balance = blockcypher.from_satoshis(sat_balance, 'btc')
    return btc_balance
Esempio n. 14
0
#import only neccessary functions
from bitcoin import random_key,privkey_to_address
from blockcypher import get_latest_block_height, get_total_balance, get_address_overview, from_satoshis

#int("0x1", 16) #first private key
#int("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140", 16) #last private key

for i in range(35):
    #print(hex(i)) #show iterator in hex to reflect priv key format
    priv_key = i #generate priv_key from int anyway
    address = privkey_to_address(priv_key)
    addr_overview = get_address_overview(address) #getting address data
    #[print(key, value) for key, value in addr_overview.items()] #this would show dict with address info
    for key,value in addr_overview.items(): #getting info from address overview
        if key == 'final_balance': #check for funds in the address
            if value > 0: #if any btc left on address, print details
                print(priv_key)
                print(address)
                print(from_satoshis(value,'btc'))
Esempio n. 15
0
def address_current_balance(pub_key, ticker):
    key = str(pub_key)
    cur_bal = blockcypher.get_total_balance(key, ticker)
    bal = blockcypher.from_satoshis(cur_bal, 'btc')
    return bal
Esempio n. 16
0
def convert_to_btc(satoshis):
    '''converts the satoshis value into btc for easier reading)'''
    return from_satoshis(satoshis,'btc')
Esempio n. 17
0
 txs = []
 address_details = get_address_full(address=account_address,
                                    api_key=api_key)
 if len(address_details['txs']) == 0:
     row = cursor.fetchone()
     total_accounts += 1
     if total_accounts % 100 == 0:
         print("[*] Running {0}, processed {1} accounts".format(
             datetime.datetime.now() - startTime, total_accounts))
     time.sleep(0.4)
     continue
 for tx in address_details['txs']:
     if tx['outputs'][0]['addresses'][
             0] == '3CWicRKHQqcj1N6fT1pC9J3hUzHw1KyPv3':
         amount = round(
             float(from_satoshis(tx['inputs'][0]['output_value'],
                                 'btc')), 8)
         normalized_amount = round(
             float(amount * check_bonus(tx['received'])), 8)
         current_tx = {
             "hash": tx['hash'],
             "amount": amount,
             "date": tx['received'],
             "normalized_amount": normalized_amount
         }
         account_total_transactions += 1
         account_amount += amount
         account_amount = round(account_amount, 6)
         account_normalized_amount += normalized_amount
         account_normalized_amount = round(account_normalized_amount, 6)
         txs.append(current_tx)
 processed_txs += account_total_transactions
Esempio n. 18
0
    def bc_transakcja_getinfo_funkcja(self,event):
        try:
            transakcja_hash = self.bc_transakcja_nr_input.GetValue()
            #transakcja_hashbtc = '400f3daead6ce20f3b6e1639e041dff9f563ec8b87cfb33a95efd37b8883c6e4'
            #ltc 03ae8088de52d8073be112629dce77c588e34320ccc923630d60fc453b87b091
            coin_symbol =  self.lista_krypto.GetStringSelection()

            #transakcja
            bc_transaction_details = blockcypher.get_transaction_details(transakcja_hash,coin_symbol=coin_symbol)  # BTC unless specified 
            print('bc_transaction_details',bc_transaction_details)

            bc_trans_confirmed = 'Potwierdzone: ' + str(bc_transaction_details['confirmed'])
            bc_trans_received = 'Złożone: ' + str(bc_transaction_details['received'])

            #transakcja
            bc_number_of_confirmations = 'Ilość potwierdzeń: ' + str(blockcypher.get_num_confirmations(transakcja_hash,coin_symbol=coin_symbol))
            #print('\n\nbc_number_of_confirmations',bc_number_of_confirmations)

            if coin_symbol == 'btc':
                #transakcja
                bc_satoshis_transacted = blockcypher.get_satoshis_transacted(transakcja_hash,coin_symbol=coin_symbol)
                #print('\n\nbc_satoshis_transacted',bc_satoshis_transacted)

                transaction_from_satoshi = 'Kwota: ' + str(blockcypher.from_satoshis(bc_satoshis_transacted,coin_symbol)) + ' ' +coin_symbol.upper()
                #print('transaction_from_satoshi',transaction_from_satoshi)

            else:
                            #transakcja

                transaction_from_satoshi = 'Kwota: ' + str(bc_transaction_details['total']/100000000) + ' ' +coin_symbol.upper()
                #print('transaction_from_satoshi',transaction_from_satoshi)



            hash_transakcji = ('Hash_transakcji: '+str(transakcja_hash))

            if coin_symbol == 'btc-testnet':
                block_hash = ''
                block_height = ''
                block_index = ''


            else:
                block_hash = 'Hash bloku: ' + str(bc_transaction_details['block_hash'])
                block_height = 'Wysokość: ' + str(bc_transaction_details['block_height'])
                block_index = 'Indeks bloku: ' + str(bc_transaction_details['block_index'])
                
            adresy = bc_transaction_details['addresses']
            try:
                adres_zleceniodawcy = str(adresy[0])
                adres_odbiorcy = str(adresy[1])
            except:
                adres_zleceniodawcy = ''
                adres_odbiorcy = ''

            if coin_symbol == 'btc':
                transaction_fees = 'Opłaty: ' + str(blockcypher.from_satoshis(bc_transaction_details['fees'],coin_symbol)) + ' ' + coin_symbol.upper()
            else:
                transaction_fees = 'Opłaty: ' + str(bc_transaction_details['fees']/100000000) + ' ' + coin_symbol.upper()


            wx.MessageBox((str(hash_transakcji) +'\n\n'+ str(bc_number_of_confirmations) +'\n\n' + str(transaction_from_satoshi) + '\n' + transaction_fees +'\n\n' + bc_trans_confirmed+ '\n' + bc_trans_received +'\n\n'+ str(block_hash) +'\n\n' + str(block_height)+'\n' + str(block_index) +'\n\n' + 'Adres zleceniodawcy:'+ '\n'+ adres_zleceniodawcy +'\n\n' +'Adres odbiorcy:' + (adres_odbiorcy)+ '\n\n' ), 'Informacje o transakcji' ,wx.OK | wx.ICON_INFORMATION)  

        except:
            wx.MessageBox('Błąd - sprawdź adres i typ kryptowaluty. \nJeżeli błąd się powtarza spróbuj później lub skontaktuj się z IccI - support.', 'Informacje o bloku' ,wx.OK | wx.ICON_INFORMATION)
Esempio n. 19
0
def address_sent(pub_key, ticker):
    key = str(pub_key)
    overview = blockcypher.get_address_overview(key, ticker)
    received = overview['total_sent']
    rec = blockcypher.from_satoshis(received, 'btc')
    return rec