Skip to content

Commit 1a9cb23

Browse files
christophersanbornxeroc
authored andcommitted
Add method voting_ticket_create() to class BitShares
1 parent 35b20f7 commit 1a9cb23

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

bitshares/bitshares.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,3 +1689,36 @@ def htlc_redeem(self, htlc_id, preimage, encoding="utf-8", account=None, **kwarg
16891689
}
16901690
)
16911691
return self.finalizeOp(op, account, "active", **kwargs)
1692+
1693+
1694+
def voting_ticket_create(self, target_type, amount_to_lock, account=None, **kwargs):
1695+
""" Create a voting ticket
1696+
1697+
:param int,str target_type: Lock period target. Should be a string from
1698+
operations.ticket_type_strings or the index of the intended
1699+
string.
1700+
1701+
:param Amount amount_to_lock: Amount to lock up for the duration
1702+
selected in target_type.
1703+
"""
1704+
1705+
if not account:
1706+
if "default_account" in self.config:
1707+
account = self.config["default_account"]
1708+
if not account:
1709+
raise ValueError("You need to provide an account")
1710+
account = Account(account, blockchain_instance=self)
1711+
1712+
if not isinstance(amount_to_lock, (Amount)):
1713+
raise ValueError("'amount_to_lock' must be of type Amount")
1714+
1715+
op = operations.Ticket_create_operation(
1716+
**{
1717+
"fee": {"amount": 0, "asset_id": "1.3.0"},
1718+
"account": account["id"],
1719+
"target_type": target_type,
1720+
"amount": amount_to_lock.json(),
1721+
"extensions": [],
1722+
}
1723+
)
1724+
return self.finalizeOp(op, account, "active", **kwargs)

0 commit comments

Comments
 (0)