Skip to content
Snippets Groups Projects
Commit 255f2521 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt
Browse files

Fix bug in Vote and added authorperm property

Tutorial about Transactionbuilder fixed
parent 95fc301b
No related branches found
No related tags found
No related merge requests found
......@@ -119,6 +119,18 @@ class Vote(BlockchainObject):
def voter(self):
return self["voter"]
@property
def authorperm(self):
if "authorperm" in self:
return self["authorperm"]
elif "authorpermvoter" in self:
[author, permlink, voter] = resolve_authorpermvoter(self["authorpermvoter"])
return construct_authorperm(author, permlink)
elif "author" in self and "permlink" in self:
return construct_authorperm(self["author"], self["permlink"])
else:
return ""
@property
def votee(self):
votee = ''
......@@ -284,9 +296,9 @@ class VotesObject(list):
authorperm = item
return (
any([name == x["voter"] for x in self]) or
any([name == x.voter for x in self]) or
any([name == x.votee for x in self]) or
any([authorperm == x["authorperm"] for x in self])
any([authorperm == x.authorperm for x in self])
)
def __str__(self):
......
......@@ -267,35 +267,53 @@ Lets display all Posts from an account:
Transactionbuilder
------------------
Sign transactions with beem without using the wallet and build the transaction by hand.
Example without using the wallet:
Example with one operation with and without the wallet:
.. code-block:: python
from beem import Steem
from beem.transactionbuilder import TransactionBuilder
from beembase import operations
stm = Steem()
# Uncomment the following when using a wallet:
# stm.wallet.unlock("secret_password")
tx = TransactionBuilder(steem_instance=stm)
tx.appendOps(Transfer(**{"from": 'user_a',
"to": 'user_b',
"amount": '1.000 SBD',
"memo": 'test 2'}))
op = operations.Transfer(**{"from": 'user_a',
"to": 'user_b',
"amount": '1.000 SBD',
"memo": 'test 2'}))
tx.appendOps(op)
# Comment appendWif out and uncomment appendSigner when using a stored key from the wallet
tx.appendWif('5.....') # `user_a`
# tx.appendSigner('user_a', 'active')
tx.sign()
tx.broadcast()
Example with using the wallet:
Example with signing and broadcasting two operations:
.. code-block:: python
from beem.transactionbuilder import TransactionBuilder
from beem import Steem
from beem.transactionbuilder import TransactionBuilder
from beembase import operations
stm = Steem()
stm.wallet.unlock("secret_password")
# Uncomment the following when using a wallet:
# stm.wallet.unlock("secret_password")
tx = TransactionBuilder(steem_instance=stm)
tx.appendOps(Transfer(**{"from": 'user_a',
"to": 'user_b',
"amount": '1.000 SBD',
"memo": 'test 2'}))
tx.appendSigner('user_a', 'active')
ops = []
op = operations.Transfer(**{"from": 'user_a',
"to": 'user_b',
"amount": '1.000 SBD',
"memo": 'test 2'}))
ops.append(op)
op = operations.Vote(**{"voter": v,
"author": author,
"permlink": permlink,
"weight": int(percent * 100)})
ops.append(op)
tx.appendOps(ops)
# Comment appendWif out and uncomment appendSigner when using a stored key from the wallet
tx.appendWif('5.....') # `user_a`
# tx.appendSigner('user_a', 'active')
tx.sign()
tx.broadcast()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment