You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should create a new wallet (address) in the blockchain.
Response:
{// Private key, which will be used to// sign transactions by the [POST] /api/sign“privateKey”: ”string”,// Address which identifies the wallet in the blockchain“publicAddress”: “string”,// Any non security sensitive data associated with// wallet. This context will be passed to// [POST] /api/transactions/*. // Can be empty.“addressContext”: “string”}
Python implementation
defcreate_wallet():
""" Create the wallet in blockchain """# generate CSRF tokenCSRF_token=app.session.get(form_url(app_config.SKYCOIN_NODE_URL, "/api/v1/csrf")).json()
ifnotCSRF_tokenor"csrf_token"notinCSRF_token:
return {"status": 500, "error": "Unknown server error"}
# generate new seednew_seed=app.session.get(
form_url(app_config.SKYCOIN_NODE_URL, "/api/v1/wallet/newSeed?entropy=128"),
headers={'X-CSRF-Token': CSRF_token['csrf_token']}).json()
ifnotnew_seedor"seed"notinnew_seed:
return {"status": 500, "error": "Unknown server error"}
# create the wallet from seedresp=app.session.post(form_url(app_config.SKYCOIN_NODE_URL, "/api/v1/wallet/create"),
{"seed": new_seed["seed"],
"label": app_config.WALLET_LABEL, "scan": "10"},
headers={'X-CSRF-Token': CSRF_token['csrf_token']})
ifnotresp:
return {"status": 500, "error": "Unknown server error"}
ifresp.status_code!=200:
return {"status": 500, "error": "Unknown server error"}
new_wallet=resp.json()
ifnotnew_walletor"entries"notinnew_wallet:
return {"status": 500, "error": "Unknown server error"}
seed=new_seed['seed']
pubkey=skycoin.cipher_PubKey()
seckey=skycoin.cipher_SecKey()
error=skycoin.SKY_cipher_GenerateDeterministicKeyPair(
seed.encode(), pubkey, seckey)
iferror!=0:
return {"status": 500, "error": "Unknown server error"}
return {
"privateKey": binascii.hexlify(bytearray(seckey.toStr())).decode('ascii'),
"publicAddress": new_wallet["entries"][0]["address"],
"addressContext": new_wallet['meta']['filename']
}
The text was updated successfully, but these errors were encountered:
Original issue: fibercrypto/skyxcommons#6 (comment)
Implement [POST] api/wallets
Should create a new wallet (address) in the blockchain.
Response:
Python implementation
The text was updated successfully, but these errors were encountered: