create account

Python Steem Libraries 0.1.1 by xeroc

View this thread on: hive.blogpeakd.comecency.com
· @xeroc ·
$62.92
Python Steem Libraries 0.1.1
**New:**

- [Docs] Added Transactions docs
- [Transactions] Python Processing and Signing of Transactions
- [Transactions] Allow for signing of Comments

**Bugs fixed:**

- [Examples] Update Examples
- [Account] Fixed missing prefix
- [Examples] Updates
- [API] Fix get_account
- [API] background cleanup and 'wallet'/'node' references

## Manual Constructing and Signing of Transactions

The new *transactions* feature allows to manually construct, sign and
broadcast transactions using python3. That means that no `cli_wallet` is
required any longer.

### Loading Transactions Class

We load the class for manual transaction construction via:

```python
from steembase import transactions
```

### Construction

Now we can use the predefined transaction formats, e.g. ``vote`` or
``comment`` as follows:

1. define the expiration time
2. define a JSON object that contains all data for that transaction
3. load that data into the corresponding **operations** class
4. collect multiple operations
5. get some blockchain parameters to prevent replay attack
6. Construct the actual **transaction** from the list of operations
7. sign the transaction with the corresponding private key(s)

#### Example A: Vote

```python
expiration = transactions.formatTimeFromNow(60)
op = transactions.Vote(
    **{"voter": voter,
       "author": message["author"],
       "permlink": message["permlink"],
       "weight": int(weight)}
)
ops    = [transactions.Operation(op)]
ref_block_num, ref_block_prefix = transactions.getBlockParams(rpc)
tx     = transactions.Signed_Transaction(ref_block_num=ref_block_num,
                                         ref_block_prefix=ref_block_prefix,
                                         expiration=expiration,
                                         operations=ops)
tx = tx.sign([wif])
```

#### Example A: Comment

```python
# Expiration time 60 seconds in the future
expiration = transactions.formatTimeFromNow(60)
op = transactions.Comment(
    **{"parent_author": parent_author,
       "parent_permlink": parent_permlink,
       "author": author,
       "permlink": postPermlink,
       "title": postTitle,
       "body": postBody,
       "json_metadata": ""}
)
ops    = [transactions.Operation(op)]
ref_block_num, ref_block_prefix = transactions.getBlockParams(rpc)
tx     = transactions.Signed_Transaction(ref_block_num=ref_block_num,
                                         ref_block_prefix=ref_block_prefix,
                                         expiration=expiration,
                                         operations=ops)
tx = tx.sign([wif])
```

### Broadcasting

For broadcasting, we first need to convert the transactions class into a
JSON object. After that, we can braodcast this to the network:

```python
# Convert python class to JSON
tx = transactions.JsonObj(tx)

# Broadcast JSON to network
rpc.broadcast_transaction(tx, api="network_broadcast"):
```
👍  , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorxeroc
permlinkpython-steem-v0-1-1
categorysteem
json_metadata{}
created2016-04-25 12:36:36
last_update2016-04-25 12:36:36
depth0
children3
last_payout2016-08-18 10:29:45
cashout_time1969-12-31 23:59:59
total_payout_value31.460 HBD
curator_payout_value31.458 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,907
author_reputation118,819,064,085,695
root_title"Python Steem Libraries 0.1.1"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id787
net_rshares26,139,251,018,212
author_curate_reward""
vote details (26)
@dercoco ·
I know it's been a long time, but  what exactly is expiration? I keep getting expiration errors...
👍  
properties (23)
authordercoco
permlinkre-xeroc-python-steem-v0-1-1-20160731t223802582z
categorysteem
json_metadata{"tags":["steem"]}
created2016-07-31 22:39:03
last_update2016-07-31 22:39:03
depth1
children2
last_payout2016-08-18 10:29:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length98
author_reputation2,425,825,242,028
root_title"Python Steem Libraries 0.1.1"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id521,778
net_rshares902,745,498
author_curate_reward""
vote details (1)
@xeroc ·
$1.31
The expiration is meant for the network to make sure a unconfirmed transactions is not added if it is expired.
I think should cannot use an expiration time larger than 30 seconds
👍  , , , ,
properties (23)
authorxeroc
permlinkre-dercoco-re-xeroc-python-steem-v0-1-1-20160802t073430189z
categorysteem
json_metadata{"tags":["steem"]}
created2016-08-02 07:34:30
last_update2016-08-02 07:34:30
depth2
children1
last_payout2016-08-18 10:29:45
cashout_time1969-12-31 23:59:59
total_payout_value1.312 HBD
curator_payout_value0.001 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length178
author_reputation118,819,064,085,695
root_title"Python Steem Libraries 0.1.1"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id554,226
net_rshares1,463,995,826,466
author_curate_reward""
vote details (5)
@dercoco ·
Thank you, I have figured out the problem now. I had use my own node to be able to go back in time for more than just 30 seconds.
properties (22)
authordercoco
permlinkre-xeroc-re-dercoco-re-xeroc-python-steem-v0-1-1-20160802t082916033z
categorysteem
json_metadata{"tags":["steem"]}
created2016-08-02 08:30:15
last_update2016-08-02 08:30:15
depth3
children0
last_payout2016-08-18 10:29:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length129
author_reputation2,425,825,242,028
root_title"Python Steem Libraries 0.1.1"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id554,826
net_rshares0