From: Chengcheng Zhang <943420582@qq.com> Date: Wed, 20 Feb 2019 07:18:35 +0000 (+0800) Subject: add kit-gm.html X-Git-Url: http://git.osdn.net/view?p=bytom%2Fbytom-kit.git;a=commitdiff_plain;h=707932379f70c6efdc6b0b29c49e85974d80b7fe add kit-gm.html --- diff --git a/app/__init__.py b/app/__init__.py index fed1418..506db15 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,6 +1,7 @@ from flask import Flask from app import api from app.config import config +from flask_cors import CORS # from app.extensions import db @@ -9,6 +10,7 @@ def create_app(config_name=None): """ app = Flask('app') + CORS(app) configure_app(app, config_name) configure_extensions(app) register_blueprints(app) diff --git a/assets/main_gm.js b/assets/main_gm.js new file mode 100644 index 0000000..6323fd8 --- /dev/null +++ b/assets/main_gm.js @@ -0,0 +1,187 @@ +$(function(){ + // 生成新熵 + $('#btnCreateNewKey').click(function(){ + console.log('创建新密钥'); + $.ajax({ + method: 'post', //get or post + url: 'http://127.0.0.1:5000/api/v1/get_gm_new_key', + data: {}, + dataType: 'json', + }).done(function(data){ + console.log(data); + layer.msg('创建成功') + $('#txtEntropy').val(data.entropy) + $('#txtMnemonics').val(data.mnemonic) + $('#txtSeed').val(data.seed) + $('#txtRootXprv').val(data.xprv) + $('#txtRootXpub').val(data.xpub) + $('#imgXprvQRCode').attr('src', 'data:image/jpg;base64,' + data.xprv_base64) + }).fail(function(err){ + layer.alert('创建失败' + err); + }); + }) + // 清除熵 + $('#btnResetKey').click(function(){ + console.log('清除'); + $('#txtEntropy').val('') + $('#txtMnemonics').val('') + $('#txtSeed').val('') + $('#txtRootXprv').val('') + $('#txtRootXpub').val('') + $('#imgXprvQRCode').attr('src', 'data:image/jpg;base64,') + }) + // 生成新地址 + $('#btnCreateNewAddress').click(function(){ + console.log('创建新地址'); + var xpub_str = $('#txtXpub').val() + var account_index_int = $('#txtAccountIndex').val() + var address_index_int = $('#txtAddressIndex').val() + var change_bool = false + if ($("input[name='inlineRadioOptionsChange']:checked").val() == "true") { + change_bool = true + } + var network_str = $("input[name='inlineRadioOptionsNetwork']:checked").val() + $.ajax({ + method: 'post', //get or post + url: 'http://kit.blockmeta.com/api/v1/create_new_address', + data: { + "xpub_str": xpub_str, + "account_index_int": account_index_int, + "address_index_int": address_index_int, + "change_bool": change_bool, + "network_str": network_str + }, + dataType: 'json', + }).done(function(data){ + console.log(data); + layer.msg('创建成功') + $('#txtAddressPath').val(data.path) + $('#txtControlProgram').val(data.control_program) + $('#txtAddress').val(data.address) + $('#imgAddressQRCode').attr('src', 'data:image/jpg;base64,' + data.address_base64) + }).fail(function(err){ + layer.alert('创建失败' + err); + }); + }) + // 清除地址 + $('#btnResetAddress').click(function(){ + console.log('清除'); + $('#txtXpub').val('') + $('#txtAccountIndex').val('1') + $('#txtAddressIndex').val('1') + $('#txtAddressPath').val('') + $('#txtControlProgram').val('') + $('#txtAddress').val('') + $('#imgAddressQRCode').attr('src', 'data:image/jpg;base64,') + }) + // 消息签名 + $('#btnSignMessage').click(function(){ + console.log('创建新签名'); + var xprv_str = $('#txtXprv').val() + var message_str = $('#txtMessage').val() + $.ajax({ + method: 'post', //get or post + url: 'http://kit.blockmeta.com/api/v1/xprv_sign', + data: { + "xprv_str": xprv_str, + "message_str": message_str + }, + dataType: 'json', + }).done(function(data){ + console.log(data); + layer.msg('签名成功') + $('#txtSignature').val(data.signature) + }).fail(function(err){ + layer.alert('签名失败' + err); + }); + }) + // 清除消息签名 + $('#btnResetSign').click(function(){ + console.log('清除'); + $('#txtXprv').val('') + $('#txtMessage').val('') + $('#txtSignature').val('') + }) + // 验证签名 + $('#btnVerifySignature').click(function(){ + console.log('验证签名'); + var xpub_str = $('#txtXpubVerify').val() + var message_str = $('#txtMessageVerify').val() + var signature_str = $('#txtSignatureVerify').val() + $.ajax({ + method: 'post', //get or post + url: 'http://kit.blockmeta.com/api/v1/xpub_verify', + data: { + "xpub_str": xpub_str, + "message_str": message_str, + "signature_str": signature_str + }, + dataType: 'json', + }).done(function(data){ + console.log(data); + layer.msg('验证成功') + $('#txtVerifyResult').val(data.result) + }).fail(function(err){ + layer.alert('验证失败,请检查输入数据格式是否正确' + err); + }); + }) + // 清除消息签名 + $('#btnResetVerify').click(function(){ + console.log('清除'); + $('#txtXpubVerify').val('') + $('#txtMessageVerify').val('') + $('#txtSignatureVerify').val('') + $('#txtVerifyResult').val('') + }) + // 发送交易 + $('#btnSubmitTransaction').click(function(){ + console.log('验证签名'); + var raw_transaction_str = $('#txtRawTransaction').val() + var network_str = $("input[name='inlineRadioOptionsNetworkSubmitTx']:checked").val() + $.ajax({ + method: 'post', //get or post + url: 'http://kit.blockmeta.com/api/v1/submit_transaction', + data: { + "raw_transaction_str": raw_transaction_str, + "network_str": network_str + }, + dataType: 'json', + }).done(function(data){ + console.log(data); + layer.msg('发送成功') + $('#txtRawTransaction').val('') + }).fail(function(err){ + layer.alert('发送失败,请检查输入数据格式是否正确' + err); + }); + }) + // 清除发送交易 + $('#btnResetSubmitTransaction').click(function(){ + console.log('清除'); + $('#txtRawTransaction').val('') + }) + // 解码原生交易信息 + $('#btnDocodeRawTransaction').click(function(){ + console.log('解码交易'); + var raw_transaction_str = $('#txtRawHexTransaction').val() + $.ajax({ + method: 'post', //get or post + url: 'http://kit.blockmeta.com/api/v1/decode_raw_transaction', + data: { + "raw_transaction_str": raw_transaction_str + }, + dataType: 'json', + }).done(function(data){ + console.log(data); + layer.msg('解码成功') + $('#txtJsonTransaction').val(data.response) + }).fail(function(err){ + layer.alert('解码失败,请检查输入数据格式是否正确' + err); + }); + }) + // 清除解码交易 + $('#btnResetDecodeRawTransaction').click(function(){ + console.log('清除'); + $('#txtRawHexTransaction').val('') + $('#txtJsonTransaction').val('') + }) +}); diff --git a/kit-gm.html b/kit-gm.html new file mode 100644 index 0000000..89d1a99 --- /dev/null +++ b/kit-gm.html @@ -0,0 +1,363 @@ + + + + + + + + Bytom Kit + + + + + + + + + + +
+
+
+
+

Key

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+
+ +
+
+
+
+
+
+
+
+

Address

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+ +
+
+
+
+
+
+
+

Sign

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+

Verify

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+
+
+
+
+

Submit Transaction

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+
+
+
+
+
+
+

Decode Raw Transaction

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+
+
+
+

Copyright ©️ Blockmeta.com

+
+ + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 75c06e4..bd6df99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ Click==7.0 Django==2.1.5 ed25519==1.4 Flask==1.0.2 +Flask-Cors==3.0.7 Flask-RESTful==0.3.7 flask-restplus==0.12.1 gevent==1.3.6