Repository
https://github.com/holgern/beem
beem is a python library for steem. beem has now 494 unit tests and a coverage of 70 %. The current version is 0.20.17.
I created a discord channel for answering a question or discussing beem: https://discord.gg/4HM592V
The newest beem version can be installed by:
pip install -U beem
or when using conda:
conda install beem
beem can be updated by:
conda update beem
New Features
Signing can be speed up by installing secp256k1prp
The python package secp256k1prp is now supported to speed up signing all broadcasted transaction.
Before, secp256k1 was supported which is not maintained and I'm not able to install it anymore.
The following benchmark works only when secp256k1prp and cryptography is installed. The library which should be used for sign/verify can be specified with ecda.SECP256K1_MODULE.
from beemgraphenebase.account import PrivateKey, PublicKey
import beemgraphenebase.ecdsasig as ecda
from beemgraphenebase.py23 import py23_bytes
import time
ecda.SECP256K1_MODULE = "ecdsa"
wif = "5J4KCbg1G3my9b9hCaQXnHSm6vrwW9xQTJS6ZciW2Kek7cCkCEk"
for lib in ["cryptography", "secp256k1", "ecdsa"]:
ecda.SECP256K1_MODULE = lib
start_time = time.time()
for i in range(30):
pub_key = py23_bytes(repr(PrivateKey(wif).pubkey), "latin")
signature = ecda.sign_message("Foobar", wif)
pub_key_sig = ecda.verify_message("Foobar", signature)
print("%s: sign and verify took %.2f seconds." % (lib, (time.time() - start_time)/30))
| library | duration [s] |
|---|---|
| secp256k1prp | 1.63 |
| cryptography | 1.80 |
| ecsdsa | 3.90 |
The benchmark shows that secp256k1prp is slightly faster than cryptography for sign/verify a transaction.
Bug fixes
get_account_votes works again with api.steemit.com
get_account_votes stoped working for api.steemit.com (post). The get_account_votes uses now list_votes with "order": "by_voter_comment" when get_account_votes returns a dict with a error field.
from beem.account import Account
from beem import Steem
stm = Steem("https://steemd.minnowsupportproject.org")
account = Account("holger80", steem_instance=stm)
votes = account.get_account_votes()
print(len(votes))
print(votes[-1])
returns
7772
{'authorperm': 'steemcleaners/steemcleaners-report-for-december-29-2018', 'weight': 13434, 'rshares': '56347337681', 'percent': 1000, 'time': '2019-01-12T07:44:30'}
Due to the changes, the function works again for api.steemit.com:
from beem.account import Account
from beem import Steem
stm = Steem("https://api.steemit.com")
account = Account("holger80", steem_instance=stm)
votes = account.get_account_votes()
print(len(votes))
print(votes[-1])
returns
7772
{'id': 361753207, 'voter': 'holger80', 'author': 'steemcleaners', 'permlink': 'steemcleaners-report-for-december-29-2018', 'weight': 13434, 'rshares': '56347337681', 'vote_percent': 1000, 'last_update': '2019-01-12T07:44:30', 'num_changes': 0}
The returned dict of a vote is slightly different.
percent->vote_percenttime->last_update
Fix rounding error in transfer broadcasting
The Amount class in beembase is used to calculate the signature of a transfer transaction. Inside this function, a rounding error occured, which prevents sending of 1.013 STEEM.
It was caused by:
(float(1.013) * 10 ** 3)
which is
1012.9999999999999
and was round with the int() function to
1012
This had prevented broadcasting.
A round function is now used:
round(float(1.013) * 10 ** 3) = 1013
which returns 1013.
Function test:
Unit tests fixed
Due to the some changes and the not working testnet, some unit tests were broken. They are all fixed now.