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.
The 21 Flask Boilerplate must be run on a 21 Bitcoin Computer, please ensure that you have Python3 and Pip installed.
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.
-
Install Node and NPM
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs
-
Install BitGo Express
git clone https://github.com/BitGo/bitgo-express cd bitgo-express npm install
-
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
- Run BitGo Express
./bin/bitgo-express --debug --port 3080 --env prod --bind localhost &
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
- 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
- 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.
- Flask.
- Flask-Login for the user accounts.
- Flask-SQLAlchemy interacting with the database.
- Flask-WTF and WTForms for the form handling.
- Flask-Mail for sending mails.
- itsdangerous for generating random tokens for the confirmation emails.
- Flask-Bcrypt for generating secret user passwords.
- Flask-Admin for building an administration interface.
- Semantic UI for the global style. Very similar to Bootstrap.
- Leaflet JS for the map. I only added for the sake of the example.
- Heroku
- Digital Ocean
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.