Skip to content

Version 0.3.0

Compare
Choose a tag to compare
@MrNaif2018 MrNaif2018 released this 20 Aug 13:15
· 260 commits to master since this release
41c6179

Version 0.3.0:
This version adds new events-based API to get updates.
To register a callback function, use add_event_handler(events, func) function or @on decorator
Example:

@btc.on("new_transaction")
def handler(event, tx):
    print(event)
    print(tx)
    print(btc.get_tx(tx))
btc.poll_updates()

The following code would print

new_transaction
some_tx_hash
dict of tx hash data

On each transaction in your wallet.
btc.on or add_event_handler can also accept a list of events, for example:

def handler(event, **kwargs):
    print(event, kwargs)

Getting updates is the same, via btc.poll_updates().
There are two kinds of events for now:
new_block which gets emitted on every new block, passing height argument to callback function
new_transaction which gets emitted on every new transaction passing tx argument as tx_hash of new transaction to callback_function.
Old @btc.notify api is removed.