from app.api.resources import Mnemonic_To_Seed
from app.api.resources import Seed_To_Root_Xprv
from app.api.resources import Xprv_To_Expanded_Private_Key
+from app.api.resources import Xpub_To_Public_Key
blueprint = Blueprint('api', __name__, url_prefix='/api/v1')
api = Api(blueprint)
api.add_resource(Entropy_To_Mnemonic, '/entropy_to_mnemonic')
api.add_resource(Mnemonic_To_Seed, '/mnemonic_to_seed')
api.add_resource(Seed_To_Root_Xprv, '/seed_to_root_xprv')
-api.add_resource(Xprv_To_Expanded_Private_Key, '/xprv_to_expanded_private_key')
\ No newline at end of file
+api.add_resource(Xprv_To_Expanded_Private_Key, '/xprv_to_expanded_private_key')
+api.add_resource(Xpub_To_Public_Key, '/xpub_to_public_key')
\ No newline at end of file
from app.model.key import mnemonic_to_seed
from app.model.key import seed_to_root_xprv
from app.model.key import xprv_to_expanded_private_key
+from app.model.key import xpub_to_public_key
parser = reqparse.RequestParser()
parser.add_argument('private_key_str', type=str)
parser.add_argument('mnemonic_str', type=str)
parser.add_argument('seed_str', type=str)
parser.add_argument('xprv_str', type=str)
+parser.add_argument('xpub_str', type=str)
class Hello(Resource):
args = parser.parse_args()
xprv_str = args.get('xprv_str')
expanded_private_key_str = xprv_to_expanded_private_key(xprv_str)
- return expanded_private_key_str
\ No newline at end of file
+ return expanded_private_key_str
+
+class Xpub_To_Public_Key(Resource):
+
+ def post(self):
+ args = parser.parse_args()
+ xpub_str = args.get('xpub_str')
+ public_key_str = xpub_to_public_key(xpub_str)
+ return public_key_str
\ No newline at end of file
# public_key = private_key.get_verifying_key().to_ascii(encoding='hex')
# xpub_str = public_key.decode() + xprv_str[64:]
# return xpub_str
+##################################################
# xprv_to_expanded_private_key create expanded private key from xprv
# You can verify or get more test data from: https://gist.github.com/zcc0721/ef0bf2e69f5e92b29d716981f2a8fe7d
return expanded_private_key_str
+def xpub_to_public_key(xpub_str):
+ public_key_str = xpub_str[:64]
+
+ return public_key_str
\ No newline at end of file