Coder Social home page Coder Social logo

webclinic017 / f13x Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bloomark/f13x

0.0 0.0 0.0 636 KB

HyperDex, Flask Cryptocurrency Trading Platform, Exchange

License: BSD 3-Clause "New" or "Revised" License

Python 63.35% JavaScript 0.31% CSS 0.44% HTML 35.69% Shell 0.21%

f13x's Introduction

#f13x - Bitcoin Exchange

At a high level, f13x can be broken into these components.

  • Flask Server

  • Webserver's hyperspaces (database tables)

  • The webserver's own instances of bitcoind.

  • A connection to chain.so_, we use their blockchain API.

  • Admin's hyperspaces (the admin has his own hyperspaces because this is the location of the private keys, that ought not to be exposed to the internet)

  • Admin's bitcoind and dogecoind

The administrator would only need to manage the web server, run with Flask, and the data stores, HyperDex along with providing bitcoind and dogecoind endpoints to monitor addresses and spend outputs.

The Webserver

The Flask server is the user facing part of the application. It hosts most of the application logic, including order matching, and provides users with their order history and account balance information. We uses AJAX and highcharts to visualize exchange information in real-time. Public addresses are picked up from a pool of unused addresses and assigned to users by a cron job. Since the web server never sees private keys we invoke the importaddress RPC call on the daemons to import these as watch-only addresses (importaddress_ isn't yet implemented on the dogecoin master, hence the need for chain.so_).

The web server also has its own hyperspaces, schemas can be viewed in the db_create.py file, that contain information on users, orders, transactions and a pool of unused addresses. The hyperspaces can be located either on the same machine as the Flask web server or on a different machine with changes in the code to point to the appropriate endpoint.

Admin's Server

We think it's most secure if the admin's and the web server's hyperspaces are on different machines because of the need to key bitcoin and dogecoin private keys as secret as possible, else anyone would be able to steal unspents! The admin periodically generates new keypairs and pushes only public keys to the webserver's hyperspace for consumption by new users. Additionally, the admin's instances of bitcoind and dogecoind store the exchange's private keys, much important.

When a user send satoshis or koinus to his f13x public address they aren't credited to his account until the admin calls his 'sweep' command, instead they continue to remain as unspent outputs in his public address. On calling sweep, the admin program looks up unspent outputs for each user and user uses their private keys to sign a transaction that send all unspents to the exchange's account and subsequently updates user balances in the front-end data stores. Until this point, unspents with >6 confirmations show up as pending balance on the user's finance page.

A cashout is when a user wants to send satoshis or koinus from his account to another address. Cashing out is the most sensitive operation on f13x. It isn't safe to let satisfy a user's cash out request instantaneously, the frequency with which pending cashouts are processed is upto the admin. All requests are processed when a cashout is requested and transaction id's are made available to the user.

Summary

This concludes a high level overview of f13x. To sum it up, here are the endpoints we need

1 x Flask

2 x Bitcoin daemons

1 x Dogecoin daemons

2 x HyperDex hyperspaces (datastores)

##Dependencies

Enable Google+ API on Google developers console

##Usage

  • python ./db_create.py to initiate the database
  • python f13x.py
  • Head to localhost:5000 on your browser

f13x's People

Contributors

bloomark avatar akhilum 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.