Git Product home page Git Product logo

21-flask-boilerplate's Introduction

21 Flask Boilerplate

The 21 Flask Boilerplate provides a template app with built-in 21 Bitcoin Computer features to enable developers to quickly get their project off the ground. The Boilerplate includes two1 library integration providing Bitcoin Computer operators with access to mining and wallet information from a client-side application. The application also providers new users with a multisignature HD wallet provided by BitGo, enabling users to send and receive Bitcoin from an individually-provisioned wallet.

How to develop on the Flask Boilerplate

The 21 Flask Boilerplate must be run on a 21 Bitcoin Computer, please ensure that you have Python3 and Pip installed.

Quick-Start (without BitGo wallet software)

Install the required libraries. Install this first line if you are working with the 21 free client on a Ubuntu instance.

$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
$ sudo pip3 install -r requirements.txt

Create and initialize the database.

$ python3 createdb.py

Run the application.

$ python3 run.py

If running 21 BC as desktop, open a browser and navigate to:

localhost:5000

If ssh'ing into your 21 BC, Install unzip:

$ sudo apt-get install unzip

Download ngrok on your Bitcoin Computer, then:

$ unzip /path/to/ngrok.zip

Run ngrok

$ /path/to/ngrok http 5000

Navigate to the forwarding link provided by ngrok (will end with ngrok.io):

EX: https://[random string].ngrok.io

To access the admin panel which provides the 21 BC mining and wallet diagnostics navigate to:

/admin

and use the username 'admin' and password 'password'.

To access the Bitcoin wallet (only works after BitGo wallet software setup) navigate to:

/marketplace

and sign up for an account. The information you enter will be stored on your local database.

BitGo wallet software setup

  1. Install Node and NPM

    curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
  2. Install BitGo Express

    git clone https://github.com/BitGo/bitgo-express
    cd bitgo-express
    npm install
    
  3. Signup on BitGo and get a developer's token

  • Sign up at www.bitgo.com/wallet.
  • Once logged in, select the gear on the top right hand corner.
  • Select ‘API Access’.
  • Select the ‘Add Access Token’ button.
  • Enter all necessary information and select ‘Add Token’.
  • Set the BTC token limit to something reasonable, and ensure that you enter the public IP address of your 21 computer.
  • Your token will appear at the top of the page.
  • Take this token and set it to the ACCESS_TOKEN variable in config.py
  1. Run BitGo Express
    ./bin/bitgo-express --debug --port 3080 --env prod --bind localhost &
    

Folder Structure

The folder structure mandates that everything be held in the /app folder, all initialization and configurations to be maintained out of this folder

/static - Contains all javascript and css

/templates - Contains the Jinja2 templates which source all javascript and styles from the statics folder

/views - Contains all of the routes and associated logic

/toolbox - Contains utilities such as the mutlisig wallet / email libraries

/models - Contains all database models

/forms - Contains the rules and error checking for all forms in the templates

21 Specific Features

  • Admin panel to provide information on 21 diagnostics
  • Per user, individually provisioned wallets
  • HD child address generation
  • QR Code support
  • Wallet send flow
  • Public listing of 402 endpoints (nice to have)
  • Public access to 402 endpoint for each user, will be centralized through 21-user for now (nice to have)
  • Admin panel accessible by the 21 owner
  • All information available through 21-cli displayable for admins
  • All functionality available with the 21-cli available to admins (flush, mine, etc.)

Please feel free to fill in anything else that you feel would be useful or to create an issue with your suggestion, with an emphasis on tools that have broad use cases

Generic Boilerplate Features

  • User account sign up, sign in, password reset, all through asynchronous email confirmation.
  • Social media logins (Twitter, Facebook, Github)
  • Form generation.
  • Error handling.
  • HTML macros and layout file.
  • "Functional" file structure.
  • Python 3.x compliant.
  • Asynchronous AJAX calls.
  • Application factory.
  • Online administration.
  • Static file bundling, automatic SCSS to CSS conversion and automatic minifying.
  • Websockets (for example for live chatting)
  • Virtual environment example.
  • Heroku deployment example.
  • Digital Ocean deployment example.
  • Tests.
  • Logging.
  • Language selection.

Libraries

Backend

Frontend

Deployment

Configuration

Configuration paramaters can be set in config.py. Please change the default params if using in a production environment.

There is a working Gmail account to confirm user email addresses and reset user passwords. The same goes for API keys, you should keep them secret. You can read more about secret configuration files here.

Read this for information on the possible configuration options.

21-flask-boilerplate's People

Contributors

cponeill avatar davemc84 avatar martinbarnard avatar masonicgit avatar melvillian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

21-flask-boilerplate's Issues

BitGo wallets - Pay to 21 owner

The inspiration for the 21 boilerplate was to provide a public facing channel to interact with 21 backend components.

To make this clear, a pay to 21 owner button is needed that makes a payment to the 21 on-chain address for a given amount. This will help get the point across regarding client-side payments to 21 operators for digital goods harvested from endpoints.

Create a sample app that sources digital good from endpoint. AKA create the entire supply chain

ImportError: cannot import name 'TWO1_MERCHANT_HOST'

Installing on RPi python3 two1 libs installed. Am getting an import error in two1.commands.config:

Traceback (most recent call last):
  File "createdb.py", line 1, in <module>
    from app import db
  File "/home/pi/21co/21-Flask-Boilerplate/app/__init__.py", line 44, in <module>
    from app.views import main, user, error
  File "/home/pi/21co/21-Flask-Boilerplate/app/views/main.py", line 11, in <module>
    from app.toolbox.two1lib import two1lib
  File "/home/pi/21co/21-Flask-Boilerplate/app/toolbox/two1lib.py", line 4, in <module>
    from two1.commands.config import TWO1_MERCHANT_HOST
ImportError: cannot import name 'TWO1_MERCHANT_HOST'

Re-do the BitGo wallet integration

Short-term:

  • Have the user set a new password when the wallet is loaded so that the account and wallet does not share the same password and therefore the 21 BC owner does not have access to the account.
  • Place a text-box and submit button on the wallet page so that the user can set a password once the page loads if BitGo is running.

Long-term:

  • Set a flag to turn off BitGo in the run.py script and to make it optional, if optional turn off the wallet tab for the user. The next time the user logs in, give them the wallet option and allow them to set a password for a new wallet.
  • Require a separate wallet password upon login to encrypt the private keys
  • Have the run.py install node & npm and install bitgo and prompt the user to set a dev token.

Iterate on the long-term solution to land something more palatable

Update screenshots

The images in the screenshots are extremely outdated, consider updating while showcasing the admin panel.

Add "Configuration" page to Admin

We could also call it "Settings" and put the Miner toggle in there with an "On/Off" switch. Also, any other Configuration type settings.

Place ngrok setup information

User's seem to have trouble with accessing localhost:5000, the reason being that most users ssh into the 21 computer to develop and attempt to log into through their local machine or laptop.

Ngrok is a very easy way to avoid port forwarding and to get access to http://localhost:5000 on the 21 publicly.

Signin redirect fails after initial signup

After the initial signup and email verification occurs the page does not redirect to the signup page.

Steps to reproduce:

  1. Go to localhost:5000 and signup with valid credentials
  2. Go to the email that you set upon signup and click on the link in the verification email
  3. Return to localhost:5000. Note that you are not getting redirected to the signup page.
  4. Enter localhost:5000/user/signin into your browser

Note that you are now able to view the signing page

Birthday Present for @wbinns

Provide a gui for the 21 file server.

Location: Place on admin panel under Fileserver
Styling: Allow drag and drop functionality to allow users to drop in as many files as they would like. Dual panel with clients-de and server side access.
Tech: Plug into the 21 buy lib to enable users to connect to one another. Consider a second layer with micropayments channels + data chunking / per unit of consumption chunking (per frame, per second, per pixel).

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.