from app.api.resources import Create_Address
from app.api.resources import Get_Path_From_Index
from app.api.resources import Broadcast_Transaction
+from app.api.resources import Create_Address_QRcode
blueprint = Blueprint('api', __name__, url_prefix='/api/v1')
api = Api(blueprint)
api.add_resource(Create_P2WPKH_Program, '/create_P2WPKH_program')
api.add_resource(Create_Address, '/create_address')
api.add_resource(Get_Path_From_Index, '/get_path_from_index')
-api.add_resource(Broadcast_Transaction, '/broadcast_transaction')
\ No newline at end of file
+api.add_resource(Broadcast_Transaction, '/broadcast_transaction')
+api.add_resource(Create_Address_QRcode, '/create_address_qrcode')
\ No newline at end of file
from app.model.receiver import create_P2WPKH_program
from app.model.receiver import create_address
from app.model.receiver import get_path_from_index
+from app.model.receiver import create_address_qrcode
from app.model.transaction import broadcast_transaction
+
parser = reqparse.RequestParser()
parser.add_argument('private_key_str', type=str)
parser.add_argument('message_str', type=str)
parser.add_argument('control_program_str', type=str)
parser.add_argument('network_str', type=str)
parser.add_argument('raw_transaction_str', type=str)
+parser.add_argument('address_str', type=str)
class Hello(Resource):
raw_transaction = args.get('raw_transaction_str')
network = args.get('network_str')
response = broadcast_transaction(raw_transaction, network)
- return response
\ No newline at end of file
+ return response
+
+class Create_Address_QRcode(Resource):
+
+ def post(self):
+ args = parser.parse_args()
+ address = args.get('address_str')
+ img = create_address_qrcode(address)
+ return img
\ No newline at end of file
import hashlib
from app.model.key import *
from app.model import segwit_addr
+import qrcode
+import pybase64
+from io import BytesIO
# get_path_from_index create xpub path from account key index and current address index
# path: purpose(0x2c=44)/coin_type(btm:0x99)/account_index/change(1 or 0)/address_index
else:
hrp = 'sm'
address_str = segwit_addr.encode(hrp, 0, bytes.fromhex(public_key_hash_str))
- return address_str
\ No newline at end of file
+ return address_str
+
+# create_address_qrcode create address qrcode, then encode it to base64
+def create_address_qrcode(address_str):
+ img = qrcode.make(address_str)
+ buffered = BytesIO()
+ img.save(buffered, format="JPEG")
+ return pybase64.b64encode(buffered.getvalue()).decode("utf-8")
+
aniso8601==4.0.1
astroid==2.1.0
+atomicwrites==1.2.1
+attrs==18.2.0
certifi==2018.11.29
chardet==3.0.4
Click==7.0
+Django==2.1.5
ed25519==1.4
Flask==1.0.2
Flask-RESTful==0.3.7
+flask-restplus==0.12.1
idna==2.8
+image==1.5.27
isort==4.3.4
itsdangerous==1.1.0
Jinja2==2.10
+jsonschema==2.6.0
lazy-object-proxy==1.3.1
MarkupSafe==1.1.0
mccabe==0.6.1
+more-itertools==4.3.0
pbkdf2==1.3
+Pillow==5.4.1
+pluggy==0.8.0
+py==1.7.0
+pybase64==0.4.0
pylint==2.2.2
pysha3==1.0.2
+pytest==4.0.1
+python-dotenv==0.10.0
pytz==2018.7
+qrcode==6.0
requests==2.21.0
sha3==0.2.1
simplejson==3.16.0