def is_connected_to_blockcypher(): try: get_blockchain_overview() return True except Exception as e: verbose_print(e) return False
def get_block_height(): """ Return block height (currently uses BlockCypher API) """ resp = None try: data = get_blockchain_overview() if 'height' in data: resp = data['height'] except Exception as e: log.debug("ERROR: block height") log.debug(e) return resp
def get_block_height(): """ Return block height (currently uses BlockCypher API) """ resp = None try: data = get_blockchain_overview() if "height" in data: resp = data["height"] except Exception as e: log.debug("ERROR: block height") log.debug(e) return resp
def get_mining_fee_per_kb(coin_symbol, api_key, condidence): """ return mining fee per kb according to the confidence """ assert condidence in { 'high', 'medium', 'low' }, str(condidence) + "isn't in {'high','medium','low'} " bc = get_blockchain_overview(coin_symbol, api_key) if condidence == 'high': return bc['high_fee_per_kb'] elif condidence == 'medium': return bc['medium_fee_per_kb'] elif condidence == 'low': return bc['low_fee_per_kb']
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 fetch_blockchain_from_blockcypher(coin): response = get_blockchain_overview(coin) 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
if choice == 2 or choice == 9 or choice == 11: haash = input( "Enter Hash (sample: 43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9): " ) 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)
async def get_current_transaction_fees(self): overview = get_blockchain_overview(coin_symbol=self.coin_symbol) high_fee_per_kb = overview['high_fee_per_kb'] medium_fee_per_kb = overview['medium_fee_per_kb'] low_fee_per_kb = overview['low_fee_per_kb'] return low_fee_per_kb, medium_fee_per_kb, high_fee_per_kb