Skip to content
Snippets Groups Projects
Commit f119922c authored by Moul's avatar Moul
Browse files

[enh] #42: head_block and params: retrieve once and use in the program.

parent cab781fc
No related branches found
No related tags found
No related merge requests found
...@@ -3,15 +3,14 @@ from tabulate import tabulate ...@@ -3,15 +3,14 @@ from tabulate import tabulate
from silkaj.auth import auth_method from silkaj.auth import auth_method
from silkaj.tools import get_publickey_from_seed, message_exit, sign_document_from_seed from silkaj.tools import get_publickey_from_seed, message_exit, sign_document_from_seed
from silkaj.network_tools import get_current_block, post_request from silkaj.network_tools import post_request
from silkaj.license import license_approval from silkaj.license import license_approval
from silkaj.constants import NO_MATCHING_ID from silkaj.constants import NO_MATCHING_ID
from silkaj.wot import is_member, get_pubkey_from_id, get_pubkeys_from_id,\ from silkaj.wot import is_member, get_pubkey_from_id, get_pubkeys_from_id,\
get_uid_from_pubkey get_uid_from_pubkey
def send_certification(ep, cli_args): def send_certification(ep, head_block, cli_args):
current_blk = get_current_block(ep)
certified_uid = cli_args.subsubcmd certified_uid = cli_args.subsubcmd
certified_pubkey = get_pubkey_from_id(ep, certified_uid) certified_pubkey = get_pubkey_from_id(ep, certified_uid)
...@@ -20,7 +19,7 @@ def send_certification(ep, cli_args): ...@@ -20,7 +19,7 @@ def send_certification(ep, cli_args):
message_exit(NO_MATCHING_ID) message_exit(NO_MATCHING_ID)
# Display license and ask for confirmation # Display license and ask for confirmation
license_approval(current_blk["currency"]) license_approval(head_block["currency"])
# Authentication # Authentication
seed = auth_method(cli_args) seed = auth_method(cli_args)
...@@ -44,7 +43,7 @@ def send_certification(ep, cli_args): ...@@ -44,7 +43,7 @@ def send_certification(ep, cli_args):
# Certification confirmation # Certification confirmation
if not certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certified_pubkey): if not certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certified_pubkey):
return return
cert_doc = generate_certification_document(id_lookup, current_blk, issuer_pubkey, certified_uid) cert_doc = generate_certification_document(id_lookup, head_block, issuer_pubkey, certified_uid)
cert_doc += sign_document_from_seed(cert_doc, seed) + "\n" cert_doc += sign_document_from_seed(cert_doc, seed) + "\n"
# Send certification document # Send certification document
...@@ -62,13 +61,13 @@ def certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certifie ...@@ -62,13 +61,13 @@ def certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certifie
return True return True
def generate_certification_document(id_lookup, current_blk, issuer_pubkey, certified_uid): def generate_certification_document(id_lookup, head_block, issuer_pubkey, certified_uid):
return "Version: 10\n\ return "Version: 10\n\
Type: Certification\n\ Type: Certification\n\
Currency: " + current_blk["currency"] + "\n\ Currency: " + head_block["currency"] + "\n\
Issuer: " + issuer_pubkey + "\n\ Issuer: " + issuer_pubkey + "\n\
IdtyIssuer: " + id_lookup["pubkey"] + "\n\ IdtyIssuer: " + id_lookup["pubkey"] + "\n\
IdtyUniqueID: " + certified_uid + "\n\ IdtyUniqueID: " + certified_uid + "\n\
IdtyTimestamp: " + id_lookup["uids"][0]["meta"]["timestamp"] + "\n\ IdtyTimestamp: " + id_lookup["uids"][0]["meta"]["timestamp"] + "\n\
IdtySignature: " + id_lookup["uids"][0]["self"] + "\n\ IdtySignature: " + id_lookup["uids"][0]["self"] + "\n\
CertTimestamp: " + str(current_blk["number"]) + "-" + current_blk["hash"] + "\n" CertTimestamp: " + str(head_block["number"]) + "-" + head_block["hash"] + "\n"
...@@ -11,22 +11,21 @@ from silkaj.tools import convert_time, get_currency_symbol, message_exit ...@@ -11,22 +11,21 @@ from silkaj.tools import convert_time, get_currency_symbol, message_exit
from silkaj.constants import NO_MATCHING_ID from silkaj.constants import NO_MATCHING_ID
def currency_info(ep): def currency_info(ep, head_block):
info_type = ["newcomers", "certs", "actives", "leavers", "excluded", "ud", "tx"] info_type = ["newcomers", "certs", "actives", "leavers", "excluded", "ud", "tx"]
i, info_data = 0, dict() i, info_data = 0, dict()
while (i < len(info_type)): while (i < len(info_type)):
info_data[info_type[i]] = get_request(ep, "blockchain/with/" + info_type[i])["result"]["blocks"] info_data[info_type[i]] = get_request(ep, "blockchain/with/" + info_type[i])["result"]["blocks"]
i += 1 i += 1
current = get_current_block(ep)
system("clear") system("clear")
print("Connected to node:", ep[best_node(ep, 1)], ep["port"], print("Connected to node:", ep[best_node(ep, False)], ep["port"],
"\nCurrent block number:", current["number"], "\nCurrent block number:", head_block["number"],
"\nCurrency name:", get_currency_symbol(current["currency"]), "\nCurrency name:", get_currency_symbol(head_block["currency"]),
"\nNumber of members:", current["membersCount"], "\nNumber of members:", head_block["membersCount"],
"\nMinimal Proof-of-Work:", current["powMin"], "\nMinimal Proof-of-Work:", head_block["powMin"],
"\nCurrent time:", convert_time(current["time"], "all"), "\nCurrent time:", convert_time(head_block["time"], "all"),
"\nMedian time:", convert_time(current["medianTime"], "all"), "\nMedian time:", convert_time(head_block["medianTime"], "all"),
"\nDifference time:", convert_time(current["time"] - current["medianTime"], "hour"), "\nDifference time:", convert_time(head_block["time"] - head_block["medianTime"], "hour"),
"\nNumber of blocks containing: \ "\nNumber of blocks containing: \
\n- new comers:", len(info_data["newcomers"]), \n- new comers:", len(info_data["newcomers"]),
"\n- Certifications:", len(info_data["certs"]), "\n- Certifications:", len(info_data["certs"]),
...@@ -159,11 +158,10 @@ def network_info(ep, discover): ...@@ -159,11 +158,10 @@ def network_info(ep, discover):
print(tabulate(endpoints, headers="keys", tablefmt="orgtbl", stralign="center")) print(tabulate(endpoints, headers="keys", tablefmt="orgtbl", stralign="center"))
def list_issuers(ep, nbr, last): def list_issuers(ep, head_block, nbr, last):
current_blk = get_current_block(ep) current_nbr = head_block["number"]
current_nbr = current_blk["number"]
if nbr == 0: if nbr == 0:
nbr = current_blk["issuersFrame"] nbr = head_block["issuersFrame"]
url = "blockchain/blocks/" + str(nbr) + "/" + str(current_nbr - nbr + 1) url = "blockchain/blocks/" + str(nbr) + "/" + str(current_nbr - nbr + 1)
blocks, list_issuers, j = get_request(ep, url), list(), 0 blocks, list_issuers, j = get_request(ep, url), list(), 0
issuers_dict = dict() issuers_dict = dict()
...@@ -217,28 +215,27 @@ def list_issuers(ep, nbr, last): ...@@ -217,28 +215,27 @@ def list_issuers(ep, nbr, last):
tabulate(sorted_list, headers="keys", tablefmt="orgtbl", floatfmt=".1f", stralign="center"))) tabulate(sorted_list, headers="keys", tablefmt="orgtbl", floatfmt=".1f", stralign="center")))
def argos_info(ep): def argos_info(ep, head_block):
info_type = ["newcomers", "certs", "actives", "leavers", "excluded", "ud", "tx"] info_type = ["newcomers", "certs", "actives", "leavers", "excluded", "ud", "tx"]
pretty_names = {'g1': 'Ğ1', 'gtest': 'Ğtest'} pretty_names = {'g1': 'Ğ1', 'gtest': 'Ğtest'}
i, info_data = 0, dict() i, info_data = 0, dict()
while (i < len(info_type)): while (i < len(info_type)):
info_data[info_type[i]] = get_request(ep, "blockchain/with/" + info_type[i])["result"]["blocks"] info_data[info_type[i]] = get_request(ep, "blockchain/with/" + info_type[i])["result"]["blocks"]
i += 1 i += 1
current = get_current_block(ep) pretty = head_block["currency"]
pretty = current["currency"] if head_block["currency"] in pretty_names:
if current["currency"] in pretty_names: pretty = pretty_names[head_block["currency"]]
pretty = pretty_names[current["currency"]]
print(pretty, "|") print(pretty, "|")
print("---") print("---")
href = 'href=http://%s:%s/' % (ep[best_node(ep, 1)], ep["port"]) href = 'href=http://%s:%s/' % (ep[best_node(ep, False)], ep["port"])
print("Connected to node:", ep[best_node(ep, 1)], ep["port"], "|", href, print("Connected to node:", ep[best_node(ep, False)], ep["port"], "|", href,
"\nCurrent block number:", current["number"], "\nCurrent block number:", head_block["number"],
"\nCurrency name:", get_currency_symbol(current["currency"]), "\nCurrency name:", get_currency_symbol(head_block["currency"]),
"\nNumber of members:", current["membersCount"], "\nNumber of members:", head_block["membersCount"],
"\nMinimal Proof-of-Work:", current["powMin"], "\nMinimal Proof-of-Work:", head_block["powMin"],
"\nCurrent time:", convert_time(current["time"], "all"), "\nCurrent time:", convert_time(head_block["time"], "all"),
"\nMedian time:", convert_time(current["medianTime"], "all"), "\nMedian time:", convert_time(head_block["medianTime"], "all"),
"\nDifference time:", convert_time(current["time"] - current["medianTime"], "hour"), "\nDifference time:", convert_time(head_block["time"] - head_block["medianTime"], "hour"),
"\nNumber of blocks containing… \ "\nNumber of blocks containing… \
\n-- new comers:", len(info_data["newcomers"]), \n-- new comers:", len(info_data["newcomers"]),
"\n-- Certifications:", len(info_data["certs"]), "\n-- Certifications:", len(info_data["certs"]),
......
from silkaj.network_tools import get_request, get_current_block from silkaj.network_tools import get_request
from silkaj.tools import get_currency_symbol, get_publickey_from_seed from silkaj.tools import get_currency_symbol, get_publickey_from_seed
from silkaj.auth import auth_method from silkaj.auth import auth_method
from silkaj.wot import check_public_key from silkaj.wot import check_public_key
def cmd_amount(ep, cli_args): def cmd_amount(ep, cli_args, config, head_block, ud_value, currency_symbol):
if not cli_args.subsubcmd.startswith("--"): if not cli_args.subsubcmd.startswith("--"):
pubkeys = cli_args.subsubcmd.split(":") pubkeys = cli_args.subsubcmd.split(":")
for pubkey in pubkeys: for pubkey in pubkeys:
...@@ -13,8 +13,8 @@ def cmd_amount(ep, cli_args): ...@@ -13,8 +13,8 @@ def cmd_amount(ep, cli_args):
return return
total = [0, 0] total = [0, 0]
for pubkey in pubkeys: for pubkey in pubkeys:
value = get_amount_from_pubkey(ep, pubkey) value = get_amount_from_pubkey(ep, head_block, pubkey)
show_amount_from_pubkey(ep, pubkey, value) show_amount_from_pubkey(pubkey, value, ud_value, currency_symbol)
total[0] += value[0] total[0] += value[0]
total[1] += value[1] total[1] += value[1]
if (len(pubkeys) > 1): if (len(pubkeys) > 1):
...@@ -22,7 +22,7 @@ def cmd_amount(ep, cli_args): ...@@ -22,7 +22,7 @@ def cmd_amount(ep, cli_args):
else: else:
seed = auth_method(cli_args) seed = auth_method(cli_args)
pubkey = get_publickey_from_seed(seed) pubkey = get_publickey_from_seed(seed)
show_amount_from_pubkey(ep, pubkey, get_amount_from_pubkey(ep, pubkey)) show_amount_from_pubkey(pubkey, get_amount_from_pubkey(ep, head_block, pubkey), ud_value, currency_symbol)
def show_amount_from_pubkey(ep, pubkey, value): def show_amount_from_pubkey(ep, pubkey, value):
...@@ -50,7 +50,7 @@ def show_amount_from_pubkey(ep, pubkey, value): ...@@ -50,7 +50,7 @@ def show_amount_from_pubkey(ep, pubkey, value):
print("Total Quantitative =", round(totalAmountInput / 100, 2), currency_symbol + "\n") print("Total Quantitative =", round(totalAmountInput / 100, 2), currency_symbol + "\n")
def get_amount_from_pubkey(ep, pubkey): def get_amount_from_pubkey(ep, head_block, pubkey):
sources = get_request(ep, "tx/sources/" + pubkey)["sources"] sources = get_request(ep, "tx/sources/" + pubkey)["sources"]
listinput = [] listinput = []
...@@ -69,8 +69,7 @@ def get_amount_from_pubkey(ep, pubkey): ...@@ -69,8 +69,7 @@ def get_amount_from_pubkey(ep, pubkey):
pendings = history["sending"] + history["receiving"] + history["pending"] pendings = history["sending"] + history["receiving"] + history["pending"]
# print(pendings) # print(pendings)
current_blk = get_current_block(ep) last_block_number = int(head_block["number"])
last_block_number = int(current_blk["number"])
# add pending output # add pending output
for pending in pendings: for pending in pendings:
......
...@@ -107,7 +107,7 @@ def manage_cmd(ep, cli_args): ...@@ -107,7 +107,7 @@ def manage_cmd(ep, cli_args):
if cli_args.subcmd == "about": if cli_args.subcmd == "about":
about() about()
elif cli_args.subcmd == "info": elif cli_args.subcmd == "info":
currency_info(ep) currency_info(ep, head_block)
elif cli_args.subcmd == "diffi": elif cli_args.subcmd == "diffi":
difficulties(ep) difficulties(ep)
...@@ -120,19 +120,19 @@ def manage_cmd(ep, cli_args): ...@@ -120,19 +120,19 @@ def manage_cmd(ep, cli_args):
network_info(ep, cli_args.contains_switches("discover")) network_info(ep, cli_args.contains_switches("discover"))
elif cli_args.subcmd == "issuers" and cli_args.subsubcmd and int(cli_args.subsubcmd) >= 0: elif cli_args.subcmd == "issuers" and cli_args.subsubcmd and int(cli_args.subsubcmd) >= 0:
list_issuers(ep, int(cli_args.subsubcmd), cli_args.contains_switches('last')) list_issuers(ep, head_block, int(cli_args.subsubcmd), cli_args.contains_switches('last'))
elif cli_args.subcmd == "argos": elif cli_args.subcmd == "argos":
argos_info(ep) argos_info(ep, head_block)
elif cli_args.subcmd == "amount" and cli_args.subsubcmd: elif cli_args.subcmd == "amount":
cmd_amount(ep, cli_args) cmd_amount(ep, cli_args, currency_config, head_block, ud_value, currency_symbol)
elif cli_args.subcmd == "tx" or cli_args.subcmd == "transaction": elif cli_args.subcmd == "tx" or cli_args.subcmd == "transaction":
send_transaction(ep, cli_args) send_transaction(ep, cli_args, head_block, ud_value, currency_symbol)
elif cli_args.subcmd == "cert": elif cli_args.subcmd == "cert":
send_certification(ep, cli_args) send_certification(ep, head_block, cli_args)
elif cli_args.subcmd == "generate_auth_file": elif cli_args.subcmd == "generate_auth_file":
generate_auth_file(cli_args) generate_auth_file(cli_args)
...@@ -141,7 +141,7 @@ def manage_cmd(ep, cli_args): ...@@ -141,7 +141,7 @@ def manage_cmd(ep, cli_args):
id_pubkey_correspondence(ep, cli_args.subsubcmd) id_pubkey_correspondence(ep, cli_args.subsubcmd)
elif cli_args.subcmd == "wot": elif cli_args.subcmd == "wot":
received_sent_certifications(ep, cli_args.subsubcmd) received_sent_certifications(ep, params, cli_args.subsubcmd)
elif cli_args.subcmd == "license": elif cli_args.subcmd == "license":
display_license() display_license()
......
...@@ -4,8 +4,8 @@ from time import sleep ...@@ -4,8 +4,8 @@ from time import sleep
import urllib import urllib
from tabulate import tabulate from tabulate import tabulate
from silkaj.network_tools import get_request, post_request, get_current_block from silkaj.network_tools import get_request, post_request
from silkaj.tools import get_currency_symbol, get_publickey_from_seed, sign_document_from_seed,\ from silkaj.tools import get_publickey_from_seed, sign_document_from_seed,\
check_public_key, message_exit check_public_key, message_exit
from silkaj.auth import auth_method from silkaj.auth import auth_method
from silkaj.wot import get_uid_from_pubkey from silkaj.wot import get_uid_from_pubkey
...@@ -13,7 +13,7 @@ from silkaj.money import get_last_ud_value, get_amount_from_pubkey ...@@ -13,7 +13,7 @@ from silkaj.money import get_last_ud_value, get_amount_from_pubkey
from silkaj.constants import NO_MATCHING_ID from silkaj.constants import NO_MATCHING_ID
def send_transaction(ep, cli_args): def send_transaction(ep, cli_args, head_block, ud_value, currency_symbol):
""" """
Main function Main function
""" """
...@@ -22,14 +22,14 @@ def send_transaction(ep, cli_args): ...@@ -22,14 +22,14 @@ def send_transaction(ep, cli_args):
seed = auth_method(cli_args) seed = auth_method(cli_args)
issuer_pubkey = get_publickey_from_seed(seed) issuer_pubkey = get_publickey_from_seed(seed)
pubkey_amount = get_amount_from_pubkey(ep, issuer_pubkey)[0] pubkey_amount = get_amount_from_pubkey(ep, head_block, issuer_pubkey)[0]
outputAddresses = output.split(':') outputAddresses = output.split(':')
check_transaction_values(comment, outputAddresses, outputBackChange, pubkey_amount < amount * len(outputAddresses), issuer_pubkey) check_transaction_values(comment, outputAddresses, outputBackChange, pubkey_amount < amount * len(outputAddresses), issuer_pubkey)
if cli_args.contains_switches('yes') or cli_args.contains_switches('y') or \ if cli_args.contains_switches('yes') or cli_args.contains_switches('y') or \
input(tabulate(transaction_confirmation(ep, issuer_pubkey, amount, ud, outputAddresses, comment), input(tabulate(transaction_confirmation(ep, issuer_pubkey, amount, ud, outputAddresses, comment),
tablefmt="fancy_grid") + "\nDo you confirm sending this transaction? [yes/no]: ") == "yes": tablefmt="fancy_grid") + "\nDo you confirm sending this transaction? [yes/no]: ") == "yes":
generate_and_send_transaction(ep, seed, issuer_pubkey, amount, outputAddresses, comment, allSources, outputBackChange) generate_and_send_transaction(ep, head_block, seed, issuer_pubkey, amount, outputAddresses, comment, allSources, outputBackChange)
def cmd_transaction(cli_args, ud): def cmd_transaction(cli_args, ud):
...@@ -92,10 +92,10 @@ def transaction_confirmation(ep, issuer_pubkey, amount, ud, outputAddresses, com ...@@ -92,10 +92,10 @@ def transaction_confirmation(ep, issuer_pubkey, amount, ud, outputAddresses, com
return tx return tx
def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAddresses, Comment="", all_input=False, OutputbackChange=None): def generate_and_send_transaction(ep, head_block, seed, issuers, AmountTransfered, outputAddresses, Comment="", all_input=False, OutputbackChange=None):
while True: while True:
listinput_and_amount = get_list_input_for_transaction(ep, issuers, AmountTransfered * len(outputAddresses), all_input) listinput_and_amount = get_list_input_for_transaction(ep, head_block, issuers, AmountTransfered * len(outputAddresses), all_input)
intermediatetransaction = listinput_and_amount[2] intermediatetransaction = listinput_and_amount[2]
if intermediatetransaction: if intermediatetransaction:
...@@ -104,7 +104,7 @@ def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAdd ...@@ -104,7 +104,7 @@ def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAdd
print(" - From: " + issuers) print(" - From: " + issuers)
print(" - To: " + issuers) print(" - To: " + issuers)
print(" - Amount: " + str(totalAmountInput / 100)) print(" - Amount: " + str(totalAmountInput / 100))
transaction = generate_transaction_document(ep, issuers, totalAmountInput, listinput_and_amount, outputAddresses, "Change operation") transaction = generate_transaction_document(ep, head_block, issuers, totalAmountInput, listinput_and_amount, outputAddresses, "Change operation")
transaction += sign_document_from_seed(transaction, seed) + "\n" transaction += sign_document_from_seed(transaction, seed) + "\n"
post_request(ep, "tx/process", "transaction=" + urllib.parse.quote_plus(transaction)) post_request(ep, "tx/process", "transaction=" + urllib.parse.quote_plus(transaction))
print("Change Transaction successfully sent.") print("Change Transaction successfully sent.")
...@@ -119,7 +119,7 @@ def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAdd ...@@ -119,7 +119,7 @@ def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAdd
print(" - Amount: " + str(listinput_and_amount[1] / 100)) print(" - Amount: " + str(listinput_and_amount[1] / 100))
else: else:
print(" - Amount: " + str(AmountTransfered / 100 * len(outputAddresses))) print(" - Amount: " + str(AmountTransfered / 100 * len(outputAddresses)))
transaction = generate_transaction_document(ep, issuers, AmountTransfered, listinput_and_amount, outputAddresses, Comment, OutputbackChange) transaction = generate_transaction_document(ep, head_block, issuers, AmountTransfered, listinput_and_amount, outputAddresses, Comment, OutputbackChange)
transaction += sign_document_from_seed(transaction, seed) + "\n" transaction += sign_document_from_seed(transaction, seed) + "\n"
post_request(ep, "tx/process", "transaction=" + urllib.parse.quote_plus(transaction)) post_request(ep, "tx/process", "transaction=" + urllib.parse.quote_plus(transaction))
...@@ -127,17 +127,16 @@ def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAdd ...@@ -127,17 +127,16 @@ def generate_and_send_transaction(ep, seed, issuers, AmountTransfered, outputAdd
break break
def generate_transaction_document(ep, issuers, AmountTransfered, listinput_and_amount, outputAddresses, Comment="", OutputbackChange=None): def generate_transaction_document(ep, head_block, issuers, AmountTransfered, listinput_and_amount, outputAddresses, Comment="", OutputbackChange=None):
totalAmountTransfered = AmountTransfered * len(outputAddresses) totalAmountTransfered = AmountTransfered * len(outputAddresses)
listinput = listinput_and_amount[0] listinput = listinput_and_amount[0]
totalAmountInput = listinput_and_amount[1] totalAmountInput = listinput_and_amount[1]
current_blk = get_current_block(ep) currency_name = head_block["currency"]
currency_name = current_blk["currency"] blockstamp_current = str(head_block["number"]) + "-" + str(head_block["hash"])
blockstamp_current = str(current_blk["number"]) + "-" + str(current_blk["hash"]) curentUnitBase = head_block["unitbase"]
curentUnitBase = current_blk["unitbase"]
if not OutputbackChange: if not OutputbackChange:
OutputbackChange = issuers OutputbackChange = issuers
...@@ -196,7 +195,7 @@ def generate_transaction_document(ep, issuers, AmountTransfered, listinput_and_a ...@@ -196,7 +195,7 @@ def generate_transaction_document(ep, issuers, AmountTransfered, listinput_and_a
return transaction_document return transaction_document
def get_list_input_for_transaction(ep, pubkey, TXamount, allinput=False): def get_list_input_for_transaction(ep, head_block, pubkey, TXamount, allinput=False):
# real source in blockchain # real source in blockchain
sources = get_request(ep, "tx/sources/" + pubkey)["sources"] sources = get_request(ep, "tx/sources/" + pubkey)["sources"]
if sources is None: if sources is None:
...@@ -211,8 +210,7 @@ def get_list_input_for_transaction(ep, pubkey, TXamount, allinput=False): ...@@ -211,8 +210,7 @@ def get_list_input_for_transaction(ep, pubkey, TXamount, allinput=False):
history = get_request(ep, "tx/history/" + pubkey + "/pending")["history"] history = get_request(ep, "tx/history/" + pubkey + "/pending")["history"]
pendings = history["sending"] + history["receiving"] + history["pending"] pendings = history["sending"] + history["receiving"] + history["pending"]
current_blk = get_current_block(ep) last_block_number = int(head_block["number"])
last_block_number = int(current_blk["number"])
# add pending output # add pending output
for pending in pendings: for pending in pendings:
......
...@@ -18,7 +18,7 @@ def get_sent_certifications(certs, time_first_block, params): ...@@ -18,7 +18,7 @@ def get_sent_certifications(certs, time_first_block, params):
return sent, expire return sent, expire
def received_sent_certifications(ep, id): def received_sent_certifications(ep, params, id):
""" """
check id exist check id exist
many identities could exist many identities could exist
...@@ -26,7 +26,6 @@ def received_sent_certifications(ep, id): ...@@ -26,7 +26,6 @@ def received_sent_certifications(ep, id):
get id of received and sent certifications get id of received and sent certifications
display on a chart the result with the numbers display on a chart the result with the numbers
""" """
params = get_request(ep, "blockchain/parameters")
time_first_block = get_request(ep, "blockchain/block/1")["time"] time_first_block = get_request(ep, "blockchain/block/1")["time"]
if get_pubkeys_from_id(ep, id) == NO_MATCHING_ID: if get_pubkeys_from_id(ep, id) == NO_MATCHING_ID:
message_exit(NO_MATCHING_ID) message_exit(NO_MATCHING_ID)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment