リビジョン | d7001892b32ff5d0c211644d9793d03cae8ac208 (tree) |
---|---|
日時 | 2019-03-20 18:32:26 |
作者 | Chengcheng Zhang <943420582@qq.c...> |
コミッター | Chengcheng Zhang |
update api
@@ -224,7 +224,11 @@ class Create_QRcode_Base64(Resource): | ||
224 | 224 | class Create_New_Key(Resource): |
225 | 225 | |
226 | 226 | def post(self): |
227 | - return create_new_key() | |
227 | + args = parser.parse_args() | |
228 | + entropy = args.get('entropy_str') | |
229 | + mnemonic = args.get('mnemonic_str') | |
230 | + response = create_new_key(entropy, mnemonic) | |
231 | + return response | |
228 | 232 | |
229 | 233 | |
230 | 234 | class Create_New_Address(Resource): |
@@ -339,7 +343,11 @@ class Get_Gm_Address(Resource): | ||
339 | 343 | class Get_Gm_New_Key(Resource): |
340 | 344 | |
341 | 345 | def post(self): |
342 | - return get_gm_new_key() | |
346 | + args = parser.parse_args() | |
347 | + entropy = args.get('entropy_str') | |
348 | + mnemonic = args.get('mnemonic_str') | |
349 | + response = get_gm_new_key(entropy, mnemonic) | |
350 | + return response | |
343 | 351 | |
344 | 352 | class Get_Gm_New_Address(Resource): |
345 | 353 |
@@ -384,9 +384,14 @@ def xpub_verify(xpub_str, message_str, signature_str): | ||
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | -def create_new_key(): | |
388 | - entropy_str = create_entropy()['entropy'] | |
389 | - mnemonic_str = entropy_to_mnemonic(entropy_str)['mnemonic'] | |
387 | +def create_new_key(entropy_str, mnemonic_str): | |
388 | + if (entropy_str == "") and (mnemonic_str == ""): | |
389 | + entropy_str = create_entropy()['entropy'] | |
390 | + mnemonic_str = entropy_to_mnemonic(entropy_str)['mnemonic'] | |
391 | + if (entropy_str == "") and (mnemonic_str != ""): | |
392 | + pass | |
393 | + if entropy_str != "": | |
394 | + mnemonic_str = entropy_to_mnemonic(entropy_str)['mnemonic'] | |
390 | 395 | seed_str = mnemonic_to_seed(mnemonic_str)['seed'] |
391 | 396 | root_xprv_str = seed_to_root_xprv(seed_str)['root_xprv'] |
392 | 397 | xpub_str = xprv_to_xpub(root_xprv_str)['xpub'] |
@@ -274,9 +274,14 @@ def gm_xpub_verify(xpub_str, message_str, signature_str): | ||
274 | 274 | } |
275 | 275 | |
276 | 276 | |
277 | -def get_gm_new_key(): | |
278 | - entropy_str = key.create_entropy()['entropy'] | |
279 | - mnemonic_str = key.entropy_to_mnemonic(entropy_str)['mnemonic'] | |
277 | +def get_gm_new_key(entropy_str, mnemonic_str): | |
278 | + if (entropy_str == "") and (mnemonic_str == ""): | |
279 | + entropy_str = key.create_entropy()['entropy'] | |
280 | + mnemonic_str = key.entropy_to_mnemonic(entropy_str)['mnemonic'] | |
281 | + if (entropy_str == "") and (mnemonic_str != ""): | |
282 | + pass | |
283 | + if entropy_str != "": | |
284 | + mnemonic_str = key.entropy_to_mnemonic(entropy_str)['mnemonic'] | |
280 | 285 | seed_str = key.mnemonic_to_seed(mnemonic_str)['seed'] |
281 | 286 | root_xprv_str = get_gm_root_xprv(seed_str)['root_xprv'] |
282 | 287 | xpub_str = get_gm_xpub(root_xprv_str)['xpub'] |