Skip to content

Commit

Permalink
added confirmtions estimator, added bs4 to requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
priestc committed May 2, 2017
1 parent 8de203f commit e3f3402
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions moneywagon/services.py
Expand Up @@ -4,6 +4,9 @@
from bitcoin import deserialize
import arrow

from bs4 import BeautifulSoup
import re

class Bitstamp(Service):
service_id = 1
supported_cryptos = ['btc']
Expand Down Expand Up @@ -2448,9 +2451,6 @@ class Bcoin(Service):
service_id = 76

def get_balance(self, crypto, address, confirmations=1):
from bs4 import BeautifulSoup
import re

url = "https://bchain.info/%s/addr/%s" % (crypto.upper(), address)
doc = BeautifulSoup(self.get_url(url).content, "html.parser")
info_script_body = doc.find_all("script")[4].string
Expand Down
5 changes: 5 additions & 0 deletions moneywagon/supply_estimator.py
Expand Up @@ -150,6 +150,11 @@ def estimate_date_from_height(self, block_height):

return self.genesis_date + datetime.timedelta(minutes=minutes)

def estimate_confirmations(self, confirmed_at_time):
confirmed_block = self.estimate_height_from_date(confirmed_at_time)
current_block = self.estimate_height_from_date(datetime.datetime.now())
return current_block - confirmed_block

def calculate_supply(self, block_height=None, at_time=None):
if at_time:
block_height = self.estimate_height_from_date(at_time)
Expand Down
3 changes: 2 additions & 1 deletion setup_template.py
Expand Up @@ -35,6 +35,7 @@
'base58',
'pytz',
'arrow',
'bitcoin'
'bitcoin',
'beautifulsoup4'
] + extra_install
)

0 comments on commit e3f3402

Please sign in to comment.