GithubHelp home page GithubHelp logo

timucindusunur / using-api-to-check-bitcoin-address-balance Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jayantna/using-api-to-check-bitcoin-address-balance

0.0 0.0 0.0 944 KB

Python 100.00%

using-api-to-check-bitcoin-address-balance's Introduction

We are using data provided by someone who has scraped the top 2.5 million Reddit posts and then placed them on GitHub. Now we can figure out (with data!) just how much Redditors love BITCOIN. Or how about a data backed equivalent of r/bitcoin?

Steps:

We are using data of bitcoin.csv provided in the github link Using the data we are going to extract all the possible bitcoin addresses posted by Redditors, extracting using regex '[13][a-km-zA-HJ-NP-Z1-9]{25,34}' Now we have all the btc addresses from the data including the invalid one To exclude invalid btc address we are going to perform SHA256 checksum in all addresses Now we have only valid bitcoin addresses from which we can extract account details like transactions, hashes, block details, balance etc. Here we are only extracting Account's Bitcoin holding balance import sys sys.path.append("base58-2.0.0") #base58 module library

import re import binascii, base58, hashlib import ssl import urllib.request, urllib.parse, urllib.error import json

fh=open("Bitcoin.csv", encoding="utf8").read() x=re.findall('[13][a-km-zA-HJ-NP-Z1-9]{25,34}',fh) validAdd=[]

#performing SHA256 checksum for bitcoinAddress in x: #print("Bitcoin Address: ", bitcoinAddress) base58Decoder = base58.b58decode(bitcoinAddress).hex() prefixAndHash = base58Decoder[:len(base58Decoder)-8] checksum = base58Decoder[len(base58Decoder)-8:] hash = prefixAndHash for x in range(1,3): hash = hashlib.sha256(binascii.unhexlify(hash)).hexdigest()
if(checksum == hash[:8]): #print("[TRUE] checksum is valid!") validAdd.append(bitcoinAddress) else: continue

#obtaining bitcoin account details using btc.com api for adds in validAdd: url='https://chain.api.btc.com/v3/address/'+adds data=urllib.request.urlopen(url).read().decode() js=json.loads(data) #print(json.dumps(js,indent=6)) try: print(js['data']['address'], '{:.8f}'.format(js['data']['balance']/10**8,8)) except: continue

using-api-to-check-bitcoin-address-balance's People

Contributors

jayantna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.