def signatures_get(shift_id): payload = {'id': shift_id} response = requests.get(constants.SIGNATURES_GET, params=payload, timeout=constants.TIMEOUT ) return response_to_dict(response)
def signatures_add_second(secret, secondSecret, publicKey): payload = { 'secret': secret, 'secondSecret': secondSecret, 'publicKey': publicKey } response = requests.put(constants.SIGNATURES_ADD_SECOND, data=payload, timeout=constants.TIMEOUT ) return response_to_dict(response)
def msignatures_create(secret, lifetime, min_sig, keysgroup): payload = { 'secret': secret, 'lifetime': lifetime, 'min': min_sig, 'keysgroup': keysgroup } response = requests.put(constants.MULTI_SIGNATURE_CREATE_ACCOUNT, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_get(**kwargs): if 'publicKey' in kwargs: payload = {'publicKey': kwargs['publicKey']} elif 'username' in kwargs: payload = {'username': kwargs['username']} else: raise ValueError("Invalid parameter.") response = requests.get(constants.DELEGATES_GET, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def peers_list(**kwargs): PARAMS = ['state', 'os', 'version', 'limit', 'offset', 'orderBy'] payload = {} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.get(constants.PEERS_LIST, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def apps_search(**kwargs): PARAMS = ['q', 'category', 'installed'] payload = {} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.get(constants.APPS_SEARCH, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def apps_get_registered(**kwargs): PARAMS = ['category', 'name', 'type', 'link', 'limit', 'offset', 'orderBy'] payload = {} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.get(constants.APPS_GET_REGISTERED, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def apps_launch(app_id, **kwargs): PARAMS = ['params'] payload = {'id': app_id} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.post(constants.APPS_LAUNCH, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_get_forged(generatorPublicKey, **kwargs): PARAMS = ['start', 'end'] payload = {'generatorPublicKey': generatorPublicKey} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.get(constants.DELEGATES_GET_FORGED, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def msignatures_sign(secret, transactionId, **kwargs): PARAMS = ['publicKey'] payload = {'secret': secret, 'transactionId': transactionId} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.post(constants.MULTI_SIGNATURE_SIGN, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_create(secret, secondSecret, username): if len(username) > 20: print(username, "is too long. Please us a string from 1 to 20 characters") payload = { 'secret': secret, 'secondSecret': secondSecret, 'username': username } response = requests.put(constants.DELEGATES_CREATE, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def transactions_list(**kwargs): PARAMS = [ 'blockId', 'senderId', 'recipientId', 'limit', 'offset', 'orderBy' ] payload = {} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.get(constants.TRANSACTIONS_LIST, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def blocks_get_filter(**kwargs): PARAMS = [ 'totalFee', 'totalAmount', 'previousBlock', 'height', 'generatorPublickey', 'offset', 'limit', 'orderBy' ] payload = {} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.get(constants.BLOCKS_GET_FILTER, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def accounts_put_delegates(secret, delegates, **kwargs): PARAMS = ['secret', 'publicKey', 'secondSecret', 'delegates'] if len(delegates) > 33: raise ValueError( "You are only allowed to vote for 33 delegates at once. You have voted for:", len(delegates)) payload = {'secret': secret, 'delegates': delegates} for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.put(constants.ACCOUNTS_PUT_DELEGATES, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def transactions_send(secret, amount, recipientId, publicKey, **kwargs): PARAMS = ['secondSecret'] payload = { 'secret': secret, 'amount': amount, 'recipientId': recipientId, 'publicKey': publicKey } for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.put(constants.TRANSACTIONS_SEND, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def apps_register(secret, category, app_name, app_type, link, **kwargs): PARAMS = [ 'secret', 'secondSecret', 'publicKey', 'category', 'name', 'description', 'tags', 'type', 'link', 'icon' ] payload = { 'secret': secret, 'category': category, 'name': app_name, 'type': app_type, 'link': link } for name in kwargs: if name not in PARAMS: raise ValueError("%s is not a valid parameter." % name) payload[name] = kwargs[name] response = requests.put(constants.APPS_REGISTER, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def accounts_open(secret): payload = {'secret': secret} response = requests.post(constants.ACCOUNTS_OPEN, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def accounts_get_delegates(address): payload = {'address': address} response = requests.get(constants.ACCOUNTS_GET_DELEGATES, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_disable_forging(secret): payload = {'secret': secret} response = requests.post(constants.DELEGATES_DISABLE_FORGING, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def blocks_get_milestone(): response = requests.get(constants.BLOCKS_GET_MILESTONE, timeout=constants.TIMEOUT) return response_to_dict(response)
def blocks_get_one(shift_id): payload = {'id': shift_id} response = requests.get(constants.BLOCKS_GET_ONE, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def blocks_get_status(): response = requests.get(constants.BLOCKS_GET_STATUS, timeout=constants.TIMEOUT) return response_to_dict(response)
def blocks_get_height(): response = requests.get(constants.BLOCKS_GET_HEIGHT, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_count(): response = requests.get(constants.DELEGATES_COUNT, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_get_votes(address): payload = {'address': address} response = requests.get(constants.DELEGATES_GET_VOTES, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def accounts_get_balance(address): payload = {'address': address} response = requests.get(constants.ACCOUNTS_GET_BALANCE, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def delegates_get_votes(publicKey): payload = {'publicKey': publicKey} response = requests.get(constants.DELEGATES_GET_VOTERS, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def accounts_get_publickey(address): payload = {'address': address} response = requests.get(constants.ACCOUNTS_GET_PUBLICKEY, params=payload, timeout=constants.TIMEOUT) return response_to_dict(response)
def blocks_get_nethash(): response = requests.get(constants.BLOCKS_GET_NETHASH, timeout=constants.TIMEOUT) return response_to_dict(response)
def accounts_gen_publickey(secret): payload = {'secret': secret} response = requests.post(constants.ACCOUNTS_GEN_PUBLICKEY, data=payload, timeout=constants.TIMEOUT) return response_to_dict(response)