Coder Social home page Coder Social logo

facundo-ripio / txwatcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tsileo/txwatcher

0.0 0.0 0.0 203 KB

A little Python utility that lets you monitor Bitcoin addresses through Blockchain Websocket API and perform custom callbacks.

License: MIT License

Python 100.00%

txwatcher's Introduction

TxWatcher

A little Python utility that lets you monitor Bitcoin addresses through Blockchain Websocket API and perform custom callbacks.

https://pypip.in/v/txwatcher/badge.png https://pypip.in/d/txwatcher/badge.png

Installation

$ pip install txwatcher

QuickStart

from txwatcher import TxWatcher

w = TxWatcher(['18eGUUxUsSetQYxJcQXEQTjSCUETEFeA4E'])

def tx_printer(tx):
        print(tx)

# You can add as many callbacks as you want
w.on_tx += tx_printer

w.run_forever()
# or
import thread
thread.start_new_thread(w.run_forever, ())

# Do some work

w.add_addresses(*['16xg9kBKUR2S6bmyccCyPichCpMNMPATAH'])

Transactions format

{
    "op": "utx",
    "x": {
        "hash": "f6c51463ea867ce58588fec2a77e9056046657b984fd28b1482912cdadd16374",
        "ver": 1,
        "vin_sz": 4,
        "vout_sz": 2,
        "lock_time": "Unavailable",
        "size": 796,
        "relayed_by": "209.15.238.250",
        "tx_index": 3187820,
        "time": 1331300839,
        "inputs": [
            {
                "prev_out": {
                    "value": 10000000,
                    "type": 0,
                    "addr": "12JSirdrJnQ8QWUaGZGiBPBYD19LxSPXho"
                }
            }
        ],
        "out": [
            {
                "value": 2800000000,
                "type": 0,
                "addr": "1FzzMfNt46cBeS41r6WHDH1iqxSyzmxChw"
            }
        ]
    }
}

Misc

Using TxWatcher within Flask

You can start TxWatcher in a separate thread and have it running within your Flask app (or any Python web framework).

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    # First, start TxWatcher
    tw = TxWatcher([a['address'] for a in col_urls.find()])
    tw.on_tx += new_tx

    thread.start_new_thread(tw.run_forever, ())

    # Then, start the Flask app
    app.run()

Changelog

See CHANGES.rst.

Contribution

Feel free to submit a pull request!

Donation

If you like my work, please consider donating:

BTC 18eGUUxUsSetQYxJcQXEQTjSCUETEFeA4E

License (MIT)

Copyright (c) 2013 Thomas Sileo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

txwatcher's People

Contributors

kwikiel avatar tsileo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.