Skip to content

Commit

Permalink
Release 0.24.2
Browse files Browse the repository at this point in the history
* New UnknownTransaction exception that is raised when using get_transaction with an unkown trx_id
* New function is_transaction_existing which returns false, when a trx_id does not exists
* beempy info does not show information for a trx_id
* broadcast from TransactionBuilder can now return a trx_id, when set trx_id to True (default)
* sign and finalizeOp from Hive and Steem return now the trx_id in a field
* add export parameter to all broadcast commands in beempy
* When setting unsigned in beempy, the default value of expires is changed to 3600
  • Loading branch information
holgern committed Jun 21, 2020
1 parent 7db2731 commit 2d7ee64
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 63 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Changelog
=========
0.24.2
------
* New UnknownTransaction exception that is raised when using get_transaction with an unkown trx_id
* New function is_transaction_existing which returns false, when a trx_id does not exists
* beempy info does not show information for a trx_id
* broadcast from TransactionBuilder can now return a trx_id, when set trx_id to True (default)
* sign and finalizeOp from Hive and Steem return now the trx_id in a field
* add export parameter to all broadcast commands in beempy
* When setting unsigned in beempy, the default value of expires is changed to 3600

0.24.1
------
* fixed missing module in setup.py
Expand Down
12 changes: 10 additions & 2 deletions beem/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .block import Block, BlockHeader
from beemapi.node import Nodes
from .exceptions import BatchedCallsNotSupported, BlockDoesNotExistsException, BlockWaitTimeExceeded, OfflineHasNoRPCException
from beemapi.exceptions import NumRetriesReached
from beemapi.exceptions import NumRetriesReached, UnknownTransaction
from beemgraphenebase.py23 import py23_bytes
from beem.instance import shared_blockchain_instance
from .amount import Amount
Expand Down Expand Up @@ -176,7 +176,7 @@ class Blockchain(object):
""" This class allows to access the blockchain and read data
from it
:param Steem blockchain_instance: Steem instance
:param Steem/Hive blockchain_instance: Steem or Hive instance
:param str mode: (default) Irreversible block (``irreversible``) or
actual head block (``head``)
:param int max_block_wait_repetition: maximum wait repetition for next block
Expand Down Expand Up @@ -251,6 +251,14 @@ def __init__(
def is_irreversible_mode(self):
return self.mode == 'last_irreversible_block_num'

def is_transaction_existing(self, transaction_id):
""" Returns true, if the transaction_id is valid"""
try:
self.get_transaction(transaction_id)
return True
except UnknownTransaction:
return False

def get_transaction(self, transaction_id):
""" Returns a transaction from the blockchain
Expand Down
27 changes: 18 additions & 9 deletions beem/blockchaininstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,21 +840,24 @@ def finalizeOp(self, ops, account, permission, **kwargs):
:param string permission: The required permission for
signing (active, owner, posting)
:param TransactionBuilder append_to: This allows to provide an instance of
TransactionBuilder (see :func:`Steem.new_tx()`) to specify
TransactionBuilder (see :func:`BlockChainInstance.new_tx()`) to specify
where to put a specific operation.
.. note:: ``append_to`` is exposed to every method used in the
Steem class
BlockChainInstance class
.. note:: If ``ops`` is a list of operation, they all need to be
signable by the same key! Thus, you cannot combine ops
that require active permission with ops that require
posting permission. Neither can you use different
accounts for different operations!
.. note:: This uses :func:`Steem.txbuffer` as instance of
.. note:: This uses :func:`BlockChainInstance.txbuffer` as instance of
:class:`beem.transactionbuilder.TransactionBuilder`.
You may want to use your own txbuffer
.. note:: when doing sign + broadcast, the trx_id is added to the returned dict
"""
if self.offline:
return {}
Expand Down Expand Up @@ -887,8 +890,10 @@ def finalizeOp(self, ops, account, permission, **kwargs):
else:
# default behavior: sign + broadcast
self.txbuffer.appendSigner(account, permission)
self.txbuffer.sign()
return self.txbuffer.broadcast()
ret_sign = self.txbuffer.sign()
ret = self.txbuffer.broadcast()
ret["trx_id"] = ret_sign.id
return ret

def sign(self, tx=None, wifs=[], reconstruct_tx=True):
""" Sign a provided transaction with the provided key(s)
Expand All @@ -902,18 +907,22 @@ def sign(self, tx=None, wifs=[], reconstruct_tx=True):
is already contructed, it will not reconstructed
and already added signatures remain
.. note:: The trx_id is added to the returned dict
"""
if tx:
txbuffer = TransactionBuilder(tx, blockchain_instance=self)
else:
txbuffer = self.txbuffer
txbuffer.appendWif(wifs)
txbuffer.appendMissingSignatures()
txbuffer.sign(reconstruct_tx=reconstruct_tx)
return txbuffer.json()
ret_sign = txbuffer.sign(reconstruct_tx=reconstruct_tx)
ret = txbuffer.json()
ret["trx_id"] = ret_sign.id
return ret

def broadcast(self, tx=None):
""" Broadcast a transaction to the Steem network
""" Broadcast a transaction to the Hive/Steem network
:param tx tx: Signed transaction to broadcast
Expand Down Expand Up @@ -1236,7 +1245,7 @@ def create_account(
json_meta=None,
**kwargs
):
""" Create new account on Steem
""" Create new account on Hive/Steem
The brainkey/password can be used to recover all generated keys
(see :class:`beemgraphenebase.account` for more details.
Expand Down
Loading

0 comments on commit 2d7ee64

Please sign in to comment.