Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
4739855
Merge branch 'release/0.1.6'
xeroc May 7, 2017
525f89d
Merge branch 'release/0.1.7'
xeroc Jul 4, 2017
ac9c4a6
Fix market symbol split regexp.
Zapata Jul 26, 2017
afc772b
Merge pull request #8 from Zapata/patch-1
xeroc Aug 1, 2017
d92cf3e
[fix] paths need to be escaped in doc
xeroc Jul 7, 2017
7771b11
[fix] account history with only_ops and exclude_ops
xeroc Jul 7, 2017
97ad50e
[improvements] do not look for keys multiple times when signing
xeroc Jul 7, 2017
e37aba5
[operations] create_worker_operation added
xeroc Jul 12, 2017
6592ab5
[docs+call] worker_create
xeroc Jul 12, 2017
cbdf824
[asset] list settlements and call positions of an asset
xeroc Aug 2, 2017
2a66c8b
[setup] update dependency on graphenelib
xeroc Aug 3, 2017
cd64add
version bump
xeroc Aug 3, 2017
4018815
[tests] fix worker_creation
xeroc Aug 3, 2017
b19aae1
pycryptodome & readme updates
grctest Oct 1, 2017
397098d
[peerplays] refresh consistency between libraries
xeroc Oct 11, 2017
105a161
[fund_fee_pool] new call
xeroc Oct 16, 2017
5b00f43
[worker] Allow to also list all workers
xeroc Nov 10, 2017
05a7779
[transactionbuilder] ensure that operations are also available when w…
xeroc Nov 10, 2017
6182f95
[fix] minor fixes and assertions
xeroc Nov 10, 2017
403d4b9
Merge pull request #17 from BTS-CM/pycryptodome
xeroc Nov 14, 2017
ff7178c
[blockchainobjects] improve testing for objects ids
xeroc Nov 14, 2017
e64523e
[price] fix multiplication of prices
xeroc Nov 14, 2017
5f129ed
[memo] linting fix
xeroc Nov 14, 2017
5faa4b4
[tests+consolidation] unit tests and consolidation with pypeerplays
xeroc Dec 7, 2017
4620379
[asset] ensure that assets are reloaded fully on requests
xeroc Dec 7, 2017
ab8722f
[wallet] store the wallet passphrase even if no key is inserted
xeroc Dec 12, 2017
cea86ad
Fix method call in Asset.calls property
SmileyChris Dec 22, 2017
8096f75
Add basic test for Asset.calls property
SmileyChris Dec 22, 2017
84d7cd9
Complete fix for market symbol split (started in #8)
SmileyChris Dec 22, 2017
efab4b1
[feeds] allow to specify a different cer when not having BTS as colla…
xeroc Dec 28, 2017
f75ff79
version bump
xeroc Dec 28, 2017
624a721
Merge branch 'release/0.1.9'
xeroc Dec 28, 2017
1c2b842
Merge tag '0.1.9' into develop
xeroc Dec 28, 2017
08376c9
fix apt command error
broncotc Jan 2, 2018
d4332e0
[block] Block Header for easier access to time etc.
xeroc Jan 4, 2018
85f46cd
[message] initial message signing support
xeroc Jan 5, 2018
e46c357
[txbuilder] do not raise exception if key not found
xeroc Jan 5, 2018
ce470e3
[message] setup separate class for message signing
xeroc Jan 8, 2018
7724362
[message] minor fixes to self calls
xeroc Jan 8, 2018
344f27a
minor cleanup
xeroc Jan 8, 2018
d501936
[setup] dependency of graphenelib pushed by one release
xeroc Jan 10, 2018
d8dcc7b
Reserve from proper account
xeroc Jan 12, 2018
abada9f
[wallet] locked() returns False if there are keys preloaded
xeroc Jan 19, 2018
7d590c0
Fix #36
xeroc Jan 19, 2018
0a85d8a
close #33
xeroc Jan 19, 2018
d87b583
Merge pull request #31 from BroncoTc/BroncoTc-patch-1
xeroc Jan 19, 2018
c526fe7
close #18
xeroc Jan 19, 2018
8c3a548
close #27
xeroc Jan 19, 2018
5d68b2d
Merge branch 'develop' into symbol_split
xeroc Jan 19, 2018
0861d9d
Merge pull request #24 from SmileyChris/symbol_split
xeroc Jan 19, 2018
c4e86a7
Fix #11
xeroc Jan 19, 2018
fa9b1f4
fix #21
xeroc Jan 19, 2018
7edc452
fix test
xeroc Jan 19, 2018
6922bed
version bump
xeroc Jan 19, 2018
4c81df4
Merge branch 'release/0.1.10'
xeroc Jan 19, 2018
c3c4579
Merge tag '0.1.10' into develop
xeroc Jan 19, 2018
5f0f806
cleanup makefile
xeroc Jan 19, 2018
118a55f
Comment about the magic `mocker` argument
SmileyChris Jan 20, 2018
00549ce
[operations] asset_* operations
xeroc Jan 22, 2018
3137f8b
bump dependency on python-graphene
xeroc Jan 22, 2018
0370796
[memo] simplify the use of bitshares.memo
xeroc Jan 23, 2018
4008070
[memo] improve interface of bitshares.memo
xeroc Jan 23, 2018
24903b5
[tests] fix test case for asset_issue
xeroc Jan 23, 2018
b46cd14
[docs] add worker.rst
xeroc Jan 23, 2018
223b274
[docs] fix intendation errors when building docs
xeroc Jan 23, 2018
b16d82f
[blockchain] fix 'stop' parameter in blocks()
xeroc Jan 23, 2018
a1cd2ef
bump dependency version
xeroc Jan 23, 2018
26fa540
[message] improvments to message parsing
xeroc Jan 24, 2018
8cd8d76
Merge branch 'master' of git://github.com/SmileyChris/python-bitshare…
xeroc Jan 25, 2018
a060565
Merge branch 'SmileyChris-master' into develop
xeroc Jan 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ target/

# Vim temp files
*.swp
.ropeproject/
*/.ropeproject/
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: python
python: "3.5"
python:
- 3.5
install:
- pip install tox codecov
script:
- tox
env:
- TOXENV=py35
after_success:
- codecov
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
.PHONY: clean-pyc clean-build docs

TAG := $(shell git describe master --abbrev=0)
TAGSTEEM := $(shell git describe master --abbrev=0 | tr "." "-")

#
clean: clean-build clean-pyc

clean-build:
Expand Down Expand Up @@ -43,7 +39,4 @@ dist:
python3 setup.py sdist upload -r pypi
python3 setup.py bdist_wheel upload

release: clean check dist bitshares-changelog git

bitshares-changelog:
git show -s --pretty=format: $(TAG) | tail -n +4 | piston post --file "-" --author chainsquad --permlink "python-bitshares-changelog-$(TAGSTEEM)" --category bitshares --title "[Changelog] python-bitshares $(TAG)" --tags python-bitshares changelog
release: clean check dist git
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
Python Library for BitShares
========================
# Python Library for BitShares

*placeholder*
---

## Documentation

Visit the [pybitshares website](http://docs.pybitshares.com/en/latest/) for in depth documentation on this Python library.

## Installation

### Install with pip:
```
$ sudo apt-get install libffi-dev libssl-dev python-dev python3-dev python3-pip
$ pip3 install bitshares
```

### Manual installation:
```
$ git clone https://github.com/xeroc/python-bitshares/
$ cd python-bitshares
$ python3 setup.py install --user
```

### Upgrade
```
$ pip3 install --user --upgrade
```
3 changes: 2 additions & 1 deletion bitshares/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"wallet",
"committee",
"vesting",
"proposal"
"proposal",
"message"
]
34 changes: 22 additions & 12 deletions bitshares/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class Account(BlockchainObject):
def __init__(
self,
account,
lazy=False,
full=False,
lazy=False,
bitshares_instance=None
):
self.full = full
super().__init__(
account,
lazy=False,
full=False,
bitshares_instance=None
lazy=lazy,
full=full,
bitshares_instance=bitshares_instance
)

def refresh(self):
Expand All @@ -59,9 +59,9 @@ def refresh(self):
else:
account = self.bitshares.rpc.lookup_account_names(
[self.identifier])[0]
self.identifier = account["id"]
if not account:
raise AccountDoesNotExistsException(self.identifier)
self.identifier = account["id"]

if self.full:
account = self.bitshares.rpc.get_full_accounts(
Expand Down Expand Up @@ -118,9 +118,7 @@ def call_positions(self):
def callpositions(self):
""" List call positions (collateralized positions :doc:`mpa`)
"""
if not self.full:
self.full = True
self.refresh()
self.ensure_full()
from .dex import Dex
dex = Dex(bitshares_instance=self.bitshares)
return dex.list_debt_positions(self)
Expand All @@ -130,10 +128,22 @@ def openorders(self):
""" Returns open Orders
"""
from .price import Order
if not self.full:
self.ensure_full()
return [
Order(o, bitshares_instance=self.bitshares)
for o in self["limit_orders"]
]

@property
def is_fully_loaded(self):
""" Is this instance fully loaded / e.g. all data available?
"""
return (self.full and "votes" in self)

def ensure_full(self):
if not self.is_fully_loaded:
self.full = True
self.refresh()
return [Order(o) for o in self["limit_orders"]]

def history(
self, first=None,
Expand Down Expand Up @@ -165,7 +175,7 @@ def history(
api="history"
)
if not mostrecent:
raise StopIteration
return

if not first:
# first = int(mostrecent[0].get("id").split(".")[2]) + 1
Expand All @@ -191,7 +201,7 @@ def history(
cnt += 1
yield i
if limit >= 0 and cnt >= limit:
raise StopIteration
return

if not txs:
break
Expand Down
6 changes: 4 additions & 2 deletions bitshares/amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, *args, amount=None, asset=None, bitshares_instance=None):

elif isinstance(amount, (int, float)) and asset and isinstance(asset, str):
self["amount"] = amount
self["asset"] = Asset(asset)
self["asset"] = Asset(asset, bitshares_instance=self.bitshares)
self["symbol"] = asset

else:
Expand Down Expand Up @@ -145,7 +145,7 @@ def __str__(self):
)

def __float__(self):
return self["amount"]
return float(self["amount"])

def __int__(self):
return int(self["amount"] * 10 ** self["asset"]["precision"])
Expand All @@ -171,6 +171,7 @@ def __sub__(self, other):
def __mul__(self, other):
a = self.copy()
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
a["amount"] *= other["amount"]
else:
a["amount"] *= other
Expand Down Expand Up @@ -228,6 +229,7 @@ def __isub__(self, other):

def __imul__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
self["amount"] *= other["amount"]
else:
self["amount"] *= other
Expand Down
62 changes: 48 additions & 14 deletions bitshares/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ def __init__(
self.full = full
super().__init__(
asset,
lazy=False,
full=False,
bitshares_instance=None
lazy=lazy,
full=full,
bitshares_instance=bitshares_instance
)

def refresh(self):
""" Refresh the data from the API server
"""
asset = self.bitshares.rpc.get_asset(self.identifier)
if not asset:
raise AssetDoesNotExistsException
super(Asset, self).__init__(asset)
raise AssetDoesNotExistsException(self.identifier)
super(Asset, self).__init__(asset, bitshares_instance=self.bitshares)
if self.full:
if "bitasset_data_id" in asset:
self["bitasset_data"] = self.bitshares.rpc.get_object(
Expand All @@ -66,6 +66,24 @@ def refresh(self):
except:
self["description"] = asset["options"]["description"]

@property
def is_fully_loaded(self):
""" Is this instance fully loaded / e.g. all data available?
"""
return (
self.full and
"bitasset_data_id" in self and
"bitasset_data" in self
)

@property
def symbol(self):
return self["symbol"]

@property
def precision(self):
return self["precision"]

@property
def is_bitasset(self):
""" Is the asset a :doc:`mpa`?
Expand All @@ -85,7 +103,7 @@ def flags(self):
return self["flags"]

def ensure_full(self):
if not self.full:
if not self.is_fully_loaded:
self.full = True
self.refresh()

Expand All @@ -97,19 +115,25 @@ def feeds(self):
return
r = []
for feed in self["bitasset_data"]["feeds"]:
r.append(PriceFeed(feed))
r.append(PriceFeed(
feed,
bitshares_instance=self.bitshares
))
return r

@property
def feed(self):
from .price import PriceFeed
assert self.is_bitasset
self.ensure_full()
return PriceFeed(self["bitasset_data"]["current_feed"])
return PriceFeed(
self["bitasset_data"]["current_feed"],
bitshares_instance=self.bitshares
)

@property
def calls(self):
return self.get_call_positions(10)
return self.get_call_orders(10)

def get_call_orders(self, limit=100):
from .price import Price
Expand All @@ -119,10 +143,16 @@ def get_call_orders(self, limit=100):
self.ensure_full()
r = list()
bitasset = self["bitasset_data"]
settlement_price = Price(bitasset["current_feed"]["settlement_price"])
settlement_price = Price(
bitasset["current_feed"]["settlement_price"],
bitshares_instance=self.bitshares
)
ret = self.bitshares.rpc.get_call_orders(self["id"], limit)
for call in ret[:limit]:
call_price = Price(call["call_price"])
call_price = Price(
call["call_price"],
bitshares_instance=self.bitshares
)
collateral_amount = Amount(
{
"amount": call["collateral"],
Expand Down Expand Up @@ -184,7 +214,10 @@ def get_settle_orders(self, limit=100):
def halt(self):
""" Halt this asset from being moved or traded
"""
nullaccount = Account("null-account") # We set the null-account
nullaccount = Account(
"null-account", # We set the null-account
bitshares_instance=self.bitshares
)
flags = {"white_list": True,
"transfer_restricted": True,
}
Expand Down Expand Up @@ -464,6 +497,7 @@ def set_market_fee(self, percentage_fee, max_market_fee):

:param float percentage_fee: Percentage of fee
:param bitshares.amount.Amount max_market_fee: Max Fee

"""
assert percentage_fee <= 100 and percentage_fee > 0
flags = {"charge_market_fee": percentage_fee > 0}
Expand All @@ -487,8 +521,8 @@ def set_market_fee(self, percentage_fee, max_market_fee):
def update_feed_producers(self, producers):
""" Update bitasset feed producers

:param list producers: List of accounts that are
allowed to produce a feed
:param list producers: List of accounts that are allowed to produce
a feed
"""
assert self.is_bitasset, \
"Asset needs to be a bitasset/market pegged asset"
Expand Down
Loading