forked from dfkthf125/api-v1-client-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreatewallet.py
More file actions
40 lines (32 loc) · 1.55 KB
/
createwallet.py
File metadata and controls
40 lines (32 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""This module corresponds to functionality documented
at https://blockchain.info/api/create_wallet
"""
from . import util
import json
def create_wallet(password, api_code, priv = None, label = None, email = None):
"""Create a new Blockchain.info wallet. It can be created containing a
pre-generated private key or will otherwise generate a new private key.
:param str password: password for the new wallet. At least 10 characters.
:param str api_code: API code with create wallets permission
:param str priv: private key to add to the wallet (optional)
:param str label: label for the first address in the wallet (optional)
:param str email: email to associate with the new wallet (optional)
:return: an instance of :class:`WalletResponse` class
"""
params = { 'password': password, 'api_code': api_code }
if priv is not None:
params['priv'] = priv
if label is not None:
params['label'] = label
if email is not None:
params['email'] = email
response = util.call_api("api/v2/create_wallet", params)
json_response = json.loads(response)
return CreateWalletResponse(json_response['guid'],
json_response['address'],
json_response['link'])
class CreateWalletResponse:
def __init__(self, identifier, address, link):
self.identifier = identifier
self.address = address
self.link = link