def bc_blok_getinfo_funkcja(self,event): try: blok_hash = self.bc_blok_nr_input.GetValue() #blok_hash = '12345' coin_symbol = self.lista_krypto.GetStringSelection() bc_block_info = blockcypher.get_block_overview(blok_hash,coin_symbol=coin_symbol) print('\n\nbc_block_info',bc_block_info) block_hash = str('Blok hash: ' + '\n' + bc_block_info['hash']) block_height = str('Wysokość: ' + str(bc_block_info['height'])) block_chain = str('Łańcuch: ' + str(bc_block_info['chain'])) block_total = str('Wolumen transakcji: ' + str(bc_block_info['total']/100000000)+ ' ' + coin_symbol.upper()) block_fees = str('Opłaty transakcyjne: ' + str(bc_block_info['fees'])) block_time = str('Czas: ' + str(bc_block_info['time'])) block_nonce = str('Nonce: ' + str(bc_block_info['nonce'])) block_prev = str('Poprzedni blok: '+ '\n' + str(bc_block_info['prev_block'])) wx.MessageBox((str(block_hash) +'\n\n'+ str(block_height) +'\n' + str(block_chain)+'\n\n' + str(block_total)+'\n' + str(block_fees)+'\n\n' + str(block_time)+'\n'+ block_nonce+'\n\n'+ block_prev), 'Informacje o bloku' ,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)
def query(request, argument): """ query view returns the result of the user query about btc, domain, email, device, ip etc. """ if request.method == "POST": form = SearchForm(request.POST) if form.is_valid(): arg = form.cleaned_data.get('query') response = None if argument == "btc_block_overview": try: response = get_block_overview(arg) except AssertionError: response = {'error': 'invalid input'} elif argument == "btc_address": try: response = get_address_details(arg) except AssertionError: response = {'error': 'invalid input'} elif argument == "domain": response = get_company_detail(arg) elif argument == "email": response = fetch_email(arg) elif argument == "device": response = get_device(arg) elif argument == "ip": response = ip_details(arg) return render(request, 'search/random.html', {'response': response}) else: if argument == "btc_block": response = get_blockchain_overview() return render(request, 'search/random.html', {'response': response}) form = SearchForm() return render(request, 'search/osint.html', {'form': form})
def search_blockchain(search): try: # Try addresss category = 'address' search_id = search data = blockcypher.get_address_overview( search, coin_symbol="btc-testnet", api_key="acb0b8a2fe3d479c8b05b415ded8021e") except (AssertionError, TypeError): try: # Try block height category = 'block' block_height = blockcypher.get_block_height( search, coin_symbol='btc-testnet', api_key="acb0b8a2fe3d479c8b05b415ded8021e") search_id = block_height data = blockcypher.get_block_overview( block_height, coin_symbol="btc-testnet", api_key="acb0b8a2fe3d479c8b05b415ded8021e") except (AssertionError, TypeError): try: # Try block hash category = 'block' search_id = search data = blockcypher.get_block_overview( search, coin_symbol="btc-testnet", api_key="acb0b8a2fe3d479c8b05b415ded8021e") except (AssertionError, TypeError): try: # Try tx category = 'tx' search_id = search data = blockcypher.get_transaction_details( search, coin_symbol="btc-testnet", api_key="acb0b8a2fe3d479c8b05b415ded8021e") except (AssertionError, TypeError): category = None search_id = search data = None print(category) print(search_id) print(data) """ try: # address ??? data = get_from_bitcoind('getblock', [search]) data['message'] try: height_to_hash = get_from_bitcoind('getblockhash', [search]) data = get_from_bitcoind('getblock', [height_to_hash]) data['message'] try: data = get_from_bitcoind('getrawtransaction', [search, 1]) data['message'] category = None search_id = None except KeyError: category = 'tx' search_id = search except KeyError: category = 'block' search_id = search except KeyError: category = 'block' search_id = data['height'] # print('category: ', category) # print('search_id: ', search_id) # print('data: ', data) """ return category, search_id, data
def fetch_blockinfo_from_blockcypher(block_info): response = get_block_overview(block_info, coin_symbol=BLOCK_CHAIN) print(response) #The JSON module is mainly used to convert the python dictionary above into a JSON string that can be written into a file. response = json.dumps(response, default=myconverter) return response
) elif choice == 4 or choice == 5 or choice == 6 or choice == 12: address = input( "Enter Address (sample: 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD): ") elif choice == 3: block_height = input("Enter Block Height (sample: 671142): ") elif choice == 7 or choice == 8: wallet_Name = input("Enter Wallet Name (sample: alice): ") else: print() if choice == 1: result = get_blockchain_overview() print("Block Height: ", result['height']) elif choice == 2: result = get_block_overview(haash) print("Block Height: ", result['height']) print("Number of Transactions: ", len(result['txids'])) elif choice == 3: result = get_block_overview(block_height, txn_limit=1, txn_offset=1) print("Number of Transactions: ", len(result['txids'])) elif choice == 4: result = get_address_overview(address) print("Received: ", result['total_received'], " sat") print("Sent: ", result['total_sent'], " sat") print("Balance: ", result['balance'], " sat") elif choice == 5: result = get_address_details(address) print("Received: ", result['total_received'], " sat") print("Sent: ", result['total_sent'], " sat") print("Balance: ", result['balance'], " sat")
tx = get_transaction_details(txid) file = open("blockchain/txs/%s" % txid, "w") json.dump(tx, file, default=json_serial) file.close() processedTxs = processedTxs + 1 except: pendingTxsToFetch.append(txid) else: if processedTxs == nTxs: # I have already fetched everything from the current block processedTxs = 0 start = processedTxs limit = 500 try: block = get_block_overview(blockHash, txn_offset=start, txn_limit=limit) file = open("blockchain/blocks/%s" % blockHash, "w") json.dump(block, file, default=json_serial) file.close() nTxs = block['n_tx'] pendingTxsToFetch = block['txids'] if (start + limit) >= nTxs: # If I can fetch the reminder of txs in the current block, then the next block will the parent of this one blockHash = block['prev_block'] except: pass if numberOfRequests == 200: sleep(60 * 60 + 10) numberOfRequests = 0 elif numberOfRequests % 3 == 0:
from blockcypher import simple_spend import blockcypher print(blockcypher.get_block_overview('12345'))
except: return adr def satoshi_to_BTC(sval): return sval / 100000000 api_key= "a5eff945993d52cf8fce0cb1a7eda4a7" if os.path.exists("data.txt"): file = open("data.txt", mode="rb") blockData = pickle.load(file) file.close() else: blockData = {} #range of blocks to download for i in range(375000, 380000): block = blockcypher.get_block_overview(i, api_key=api_key) blockData[i] = block if i % 1000 == 0: print('1000 done') file = open("data.txt", mode = "wb") pickle.dump(blockData,file) file.close()