Author Topic: Convert account history (transactions) object to JSON  (Read 2295 times)

0 Members and 1 Guest are viewing this topic.

Offline runestone

Br, Rune
~ Please vote on blockbasis-witness
~ https://www.blockbasis.com

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc

Offline runestone

Thanks, I got it working now. One more question.

When running this:
Code: [Select]
from bitshares.account import Account
account = Account("xeroc")
history = account.history(exclude_ops=[6])
data = [trans for trans in history]
return data

The following is returned:
Code: [Select]
[
    {
        "id": "1.11.158994520",
        "op": [
            6,
            {
                "fee": {
                    "amount": 1666,
                    "asset_id": "1.3.0"
                },
                "account": "1.2.282",
                "new_options": {
                    "memo_key": "BTS5TPTziKkLexhVKsQKtSpo4bAv5RnB8oXcG4sMHEwCcTf3r7dqE",
                    "voting_account": "1.2.5",
                    "num_witness": 21,
...SNIPPET...

It seems like the exclude_ops dosen't work. The same thing applies to only_ops, or what am I doing wrong?
Br, Rune
~ Please vote on blockbasis-witness
~ https://www.blockbasis.com

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
that call returns a *generator*:

Code: [Select]
for h in accout.history(limit=10):
   print(h)

Offline runestone

Hi, can someone help me convert the generator object returned by history() to JSON?

Code: [Select]
>>from bitshares.account import Account
>>account = Account("test")
>>history = account.history()
>>print(history)
<bound method Account.history of <Account 1.2.1516>>

Reference: http://docs.pybitshares.com/en/latest/bitshares.account.html
Br, Rune
~ Please vote on blockbasis-witness
~ https://www.blockbasis.com