Commit eaa6c2ed authored by Jonas Smedegaard's avatar Jonas Smedegaard

New upstream version 0.6.2

parents a3950a2d d198457b
......@@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"
[packages]
commandlines = "*"
click = "*"
ipaddress = "*"
tabulate = "*"
scrypt = "*"
......
{
"_meta": {
"hash": {
"sha256": "44e71031df1ac2e4bd25e523804020e5d05d2d8b71a33d0d84f2a296523345e1"
"sha256": "cd8383687b27bd13d038a1d59ead6e80bd301a266dcdaf6eeb4f330e36cd629d"
},
"pipfile-spec": 6,
"requires": {
......@@ -53,13 +53,13 @@
],
"version": "==1.11.5"
},
"commandlines": {
"click": {
"hashes": [
"sha256:86b650b78470ac95966d7b1a9d215c16591bccb34b28ae2bb9026c3b4166fd64",
"sha256:b7dbf71b8dec42c16e9694b87e0e121d288e5a40d5d4f0dd1c0651ab7af06837"
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
],
"index": "pypi",
"version": "==0.4.1"
"version": "==7.0"
},
"e1839a8": {
"editable": true,
......@@ -84,7 +84,6 @@
"hashes": [
"sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
],
"markers": "python_version >= '2.7' and python_version != '3.1.*' and python_version != '3.2.*' and python_version != '3.3.*' and python_version != '3.0.*'",
"version": "==2.19"
},
"pynacl": {
......@@ -110,7 +109,6 @@
"sha256:f67814c38162f4deb31f68d590771a29d5ae3b1bd64b75cf232308e5c74777e0"
],
"index": "pypi",
"markers": "python_version >= '2.7' and python_version != '3.1.*' and python_version != '3.2.*' and python_version != '3.3.*' and python_version != '3.0.*'",
"version": "==1.3.0"
},
"scrypt": {
......@@ -133,10 +131,10 @@
},
"six": {
"hashes": [
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.11.0"
"version": "==1.12.0"
},
"tabulate": {
"hashes": [
......@@ -192,17 +190,17 @@
},
"certifi": {
"hashes": [
"sha256:339dc09518b07e2fa7eda5450740925974815557727d6bd35d319c1524a04a4c",
"sha256:6d58c986d22b038c8c0df30d639f23a3e6d172a05c3583e766f4c0b785c0986a"
"sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7",
"sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033"
],
"version": "==2018.10.15"
"version": "==2018.11.29"
},
"cfgv": {
"hashes": [
"sha256:73f48a752bd7aab103c4b882d6596c6360b7aa63b34073dd2c35c7b4b8f93010",
"sha256:d1791caa9ff5c0c7bce80e7ecc1921752a2eb7c2463a08ed9b6c96b85a2f75aa"
"sha256:c7c332338fc9936b38aea5916020caeb5d34e40774992893fc4353957e1394bd",
"sha256:d25d51bd5e8514dcb55fb07c773db316a2ee9db0c07aefc028c8a7a7b1e45321"
],
"version": "==1.1.0"
"version": "==1.2.0"
},
"chardet": {
"hashes": [
......@@ -216,7 +214,7 @@
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
],
"markers": "python_version != '3.2.*' and python_version != '3.0.*' and python_version != '3.3.*' and python_version != '3.1.*' and python_version >= '2.7'",
"index": "pypi",
"version": "==7.0"
},
"docutils": {
......@@ -229,25 +227,24 @@
},
"identify": {
"hashes": [
"sha256:5e956558a9a1e3b3891d7c6609fc9709657a11878af288ace484d1a46a93922b",
"sha256:623086059219cc7b86c77a3891f3700cb175d4ce02b8fb8802b047301d71e783"
"sha256:08826e68e39e7de53cc2ddd8f6228a4e463b4bacb20565e5301c3ec690e68d27",
"sha256:2364e24a7699fea0dc910e90740adbab43eef3746eeea4e016029c34123ce66d"
],
"version": "==1.1.7"
"version": "==1.1.8"
},
"idna": {
"hashes": [
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
"sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"
],
"version": "==2.7"
"version": "==2.8"
},
"importlib-metadata": {
"hashes": [
"sha256:36b02c84f9001adf65209fefdf951be8e9014a95eab9938c0779ad5670359b1c",
"sha256:60b6481a72908c93ccb707abeb926fb5a15319b9e6f0b76639a718837ee12de0"
"sha256:a17ce1a8c7bff1e8674cb12c992375d8d0800c9190177ecf0ad93e0097224095",
"sha256:b50191ead8c70adfa12495fba19ce6d75f2e0275c14c5a7beb653d6799b512bd"
],
"markers": "python_version != '3.2' and python_version != '3.0' and python_version != '3.1' and python_version != '3.3' and python_version >= '2.7'",
"version": "==0.6"
"version": "==0.8"
},
"nodeenv": {
"hashes": [
......@@ -264,18 +261,18 @@
},
"pre-commit": {
"hashes": [
"sha256:7542bd8ae1c58745175ea0a9295964ee82a10f7e18c4344f5e4c02bd85d02561",
"sha256:87f687da6a2651d5067cfec95b854b004e95b70143cbf2369604bb3acbce25ec"
"sha256:33bb9bf599c334d458fa9e311bde54e0c306a651473b6a36fdb36a61c8605c89",
"sha256:e233f5cf3230ae9ed9ada132e9cf6890e18cc937adc669353fb64394f6e80c17"
],
"index": "pypi",
"version": "==1.12.0"
"version": "==1.13.0"
},
"pygments": {
"hashes": [
"sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d",
"sha256:dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
"sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a",
"sha256:e8218dd399a61674745138520d0d4cf2621d7e032439341bc3f647bff125818d"
],
"version": "==2.2.0"
"version": "==2.3.1"
},
"pyyaml": {
"hashes": [
......@@ -296,10 +293,10 @@
},
"requests": {
"hashes": [
"sha256:65b3a120e4329e33c9889db89c80976c5272f56ea92d3e74da8a463992e3ff54",
"sha256:ea881206e59f41dbd0bd445437d792e43906703fff75ca8ff43ccdb11f33f263"
"sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e",
"sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b"
],
"version": "==2.20.1"
"version": "==2.21.0"
},
"requests-toolbelt": {
"hashes": [
......@@ -310,10 +307,10 @@
},
"six": {
"hashes": [
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.11.0"
"version": "==1.12.0"
},
"toml": {
"hashes": [
......@@ -327,7 +324,6 @@
"sha256:3c4d4a5a41ef162dd61f1edb86b0e1c7859054ab656b2e7c7b77e7fbf6d9f392",
"sha256:5b4d5549984503050883bc126280b386f5f4ca87e6c023c5d015655ad75bdebb"
],
"markers": "python_version >= '2.6' and python_version != '3.1.*' and python_version != '3.0.*'",
"version": "==4.28.1"
},
"twine": {
......@@ -343,16 +339,14 @@
"sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39",
"sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22"
],
"markers": "python_version != '3.2.*' and python_version < '4' and python_version != '3.0.*' and python_version != '3.3.*' and python_version != '3.1.*' and python_version >= '2.7'",
"version": "==1.24.1"
},
"virtualenv": {
"hashes": [
"sha256:686176c23a538ecc56d27ed9d5217abd34644823d6391cbeb232f42bf722baad",
"sha256:f899fafcd92e1150f40c8215328be38ff24b519cd95357fa6e78e006c7638208"
"sha256:34b9ae3742abed2f95d3970acf4d80533261d6061b51160b197f84e5b4c98b4c",
"sha256:fa736831a7b18bd2bfeef746beb622a92509e9733d645952da136b0639cd40cd"
],
"markers": "python_version != '3.2.*' and python_version != '3.0.*' and python_version != '3.3.*' and python_version != '3.1.*' and python_version >= '2.7'",
"version": "==16.1.0"
"version": "==16.2.0"
},
"webencodings": {
"hashes": [
......@@ -363,11 +357,18 @@
},
"wheel": {
"hashes": [
"sha256:196c9842d79262bb66fcf59faa4bd0deb27da911dbc7c6cdca931080eb1f0783",
"sha256:c93e2d711f5f9841e17f53b0e6c0ff85593f3b416b6eec7a9452041a59a42688"
"sha256:029703bf514e16c8271c3821806a1c171220cc5bdd325cbf4e7da1e056a01db6",
"sha256:1e53cdb3f808d5ccd0df57f964263752aa74ea7359526d3da6c02114ec1e1d44"
],
"index": "pypi",
"version": "==0.32.2"
"version": "==0.32.3"
},
"zipp": {
"hashes": [
"sha256:55ca87266c38af6658b84db8cfb7343cdb0bf275f93c7afaea0d8e7a209c7478",
"sha256:682b3e1c62b7026afe24eadf6be579fb45fec54c07ea218bded8092af07a68c4"
],
"version": "==0.3.3"
}
}
}
......@@ -2,12 +2,7 @@
from sys import exit
from silkaj.network_tools import check_port, best_node, EndPoint
from silkaj.cli_tools import manage_cmd
if __name__ == "__main__":
ep = EndPoint().ep
if not check_port(ep["port"]):
exit(1)
best_node(ep, True)
manage_cmd()
......@@ -22,7 +22,7 @@ check_branch() {
}
update_version() {
sed -i "s/SILKAJ_VERSION = \"silkaj.*\"/SILKAJ_VERSION = \"silkaj $VERSION\"/" silkaj/constants.py
sed -i "s/SILKAJ_VERSION = \".*\"/SILKAJ_VERSION = \"$VERSION\"/" silkaj/constants.py
sed -i "s/version=\".*\",/version=\"$VERSION\",/" setup.py
git diff
}
......
......@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="silkaj",
version="0.6.1",
version="0.6.2",
author="Moul",
author_email="moul@moul.re",
description="Command line client for Duniter",
......@@ -25,7 +25,7 @@ setuptools.setup(
"Operating System :: OS Independent",
),
install_requires=[
"commandlines",
"Click",
"ipaddress",
"tabulate",
"pynacl",
......
......@@ -7,25 +7,25 @@ import pyaes
from getpass import getpass
from os import path
from re import compile, search
import click
def auth_method(cli_args):
if cli_args.contains_switches("auth-seed"):
@click.pass_context
def auth_method(ctx):
if ctx.obj["AUTH_SEED"]:
return auth_by_seed()
if cli_args.contains_switches("auth-file"):
return auth_by_auth_file(cli_args)
if cli_args.contains_switches("auth-wif"):
if ctx.obj["AUTH_FILE"]:
return auth_by_auth_file()
if ctx.obj["AUTH_WIF"]:
return auth_by_wif()
else:
return auth_by_scrypt(cli_args)
return auth_by_scrypt()
def generate_auth_file(cli_args):
if cli_args.contains_definitions("file"):
file = cli_args.get_definition("file")
else:
def generate_auth_file(file):
if not file:
file = "authfile"
seed = auth_method(cli_args)
seed = auth_method()
with open(file, "w") as f:
f.write(seed)
print(
......@@ -35,9 +35,10 @@ def generate_auth_file(cli_args):
)
def auth_by_auth_file(cli_args):
if cli_args.contains_definitions("file"):
file = cli_args.get_definition("file")
@click.pass_context
def auth_by_auth_file(ctx):
if ctx.obj["AUTH_FILE_PATH"]:
file = ctx.obj["AUTH_FILE_PATH"]
else:
file = "authfile"
if not path.isfile(file):
......@@ -69,20 +70,13 @@ def auth_by_seed():
return seed
def auth_by_scrypt(cli_args):
@click.pass_context
def auth_by_scrypt(ctx):
salt = getpass("Please enter your Scrypt Salt (Secret identifier): ")
password = getpass("Please enter your Scrypt password (masked): ")
if (
cli_args.contains_definitions("n")
and cli_args.contains_definitions("r")
and cli_args.contains_definitions("p")
):
n, r, p = (
cli_args.get_definition("n"),
cli_args.get_definition("r"),
cli_args.get_definition("p"),
)
if ctx.obj["AUTH_SCRYPT_PARAMS"]:
n, r, p = ctx.obj["AUTH_SCRYPT_PARAMS"].split(",")
if n.isnumeric() and r.isnumeric() and p.isnumeric():
n, r, p = int(n), int(r), int(p)
if n <= 0 or n > 65536 or r <= 0 or r > 512 or p <= 0 or p > 32:
......
......@@ -11,15 +11,15 @@ from silkaj.license import license_approval
from silkaj.wot import is_member, get_uid_from_pubkey, get_informations_for_identity
def send_certification(cli_args):
id_to_certify = get_informations_for_identity(cli_args.subsubcmd)
def send_certification(id_to_certify):
id_to_certify = get_informations_for_identity(id_to_certify)
main_id_to_certify = id_to_certify["uids"][0]
# Display license and ask for confirmation
license_approval(HeadBlock().head_block["currency"])
# Authentication
seed = auth_method(cli_args)
seed = auth_method()
# Check whether current user is member
issuer_pubkey = get_publickey_from_seed(seed)
......
# -*- coding: utf-8 -*-
import click
from sys import stderr
from commandlines import Command
from silkaj.tx import send_transaction
from silkaj.money import cmd_amount
from silkaj.cert import send_certification
......@@ -27,6 +27,163 @@ from silkaj.constants import (
)
@click.group()
@click.version_option(version=SILKAJ_VERSION)
@click.option(
"--peer",
"-p",
help="Default endpoint will reach Ğ1 currency with `https://g1.duniter.org` endpoint.\
Custom endpoint can be specified with `-p` option followed by <domain>:<port>",
)
@click.option(
"--gtest", "-gt", is_flag=True, help="ĞTest: `https://g1-test.duniter.org` endpoint"
)
@click.option(
"--auth-scrypt", is_flag=True, help="Scrypt authentication: default method"
)
@click.option(
"--scrypt-params",
"--nrp",
help="Scrypt parameters seperated by commas: defaults N,r,p: 4096,16,1",
)
@click.option(
"--auth-file", is_flag=True, help="Authentication file. Defaults to: './authfile'"
)
@click.option("--file", help="Path file specification with '--auth-file'")
@click.option("--auth-seed", is_flag=True, help="Seed authentication")
@click.option("--auth-wif", is_flag=True, help="WIF and EWIF authentication methods")
@click.pass_context
def cli(
ctx, peer, gtest, auth_scrypt, scrypt_params, auth_file, file, auth_seed, auth_wif
):
ctx.obj = dict()
ctx.ensure_object(dict)
ctx.obj["PEER"] = peer
ctx.obj["GTEST"] = gtest
ctx.obj["AUTH_SCRYPT"] = auth_scrypt
ctx.obj["AUTH_SCRYPT_PARAMS"] = scrypt_params
ctx.obj["AUTH_FILE"] = auth_file
ctx.obj["AUTH_FILE_PATH"] = file
ctx.obj["AUTH_SEED"] = auth_seed
ctx.obj["AUTH_WIF"] = auth_wif
def manage_cmd():
cli(obj={})
@cli.command("about", help="Display informations about the programm")
def cliAbout():
about()
@cli.command("amount", help="Get amount of pubkeys")
@click.option(
"--pubkeys", "-p", help="pubkeys and/or ids separated with colon: <pubkey:pubkey>"
)
def cliAmount(pubkeys):
cmd_amount(pubkeys)
@cli.command("argos", help="Display currency information formated for Argos or BitBar")
def cliArgos():
argos_info()
@cli.command("blocks", help="Display blocks")
@click.option(
"--nbr",
"-n",
required=True,
type=int,
help="Number of blocks (`0` for current window size), Details blocks are displayed under n <= 30.",
)
@click.option("--detailed", "-d", is_flag=True, help="This flag force detailed view")
def cliBlocks(nbr, detailed):
list_issuers(nbr, detailed)
@cli.command("cert", help="Send certification")
@click.argument("id_to_certify")
def cliCert(id_to_certify):
send_certification(id_to_certify)
@cli.command("diffi", help="List proof-of-work difficulty to generate next block")
def cliDiffi():
difficulties()
@cli.command(
"generate_auth_file", help="Generate file to store the seed of the account"
)
@click.option("--file", help="Path file")
def cliGenerateAuthFile(file):
generate_auth_file(file)
@cli.command("id", help="Get corresponding identity or pubkey from pubkey or identity")
@click.argument("id_pubkey")
def cliId(id_pubkey):
id_pubkey_correspondence(id_pubkey)
@cli.command("info", help="Display information about currency")
def cliInfo():
currency_info()
@cli.command("license", help="Display Ğ1 license")
def cliLicense():
display_license()
@cli.command("net", help="Display network")
@click.option(
"--discover", "-d", is_flag=True, help="Discover all network (could take a while)"
)
@click.option(
"--sort",
"-s",
help='Sort column names comma-separated (for example "-s block,diffi"), optional. Default sort: block,member,diffi,uid',
)
def cliNetwork(discover, sort):
network_info(discover, sort)
@cli.command("tx", help="Send transaction")
@click.option("--amount", type=float, help="Quantitative value")
@click.option("--amountUD", type=float, help="Relative value")
@click.option("--allSources", is_flag=True, help="Send all sources")
@click.option(
"--output",
help="Pubkey(s)’ recipients + optional checksum: <pubkey>[!checksum]:[<pubkey>[!checksum]]",
)
@click.option("--comment", help="Comment")
@click.option(
"--outputBackChange",
help="Pubkey recipient to send the rest of the transaction: <pubkey[!checksum]>",
)
@click.option("--yes", "-y", is_flag=True, help="Assume yes. No prompt confirmation")
def cliTransaction(
amount, amountud, allsources, output, comment, outputbackchange, yes
):
send_transaction(
amount, amountud, allsources, output, comment, outputbackchange, yes
)
@cli.command("usage", help="Display usage")
def cliUsage():
usage()
@cli.command("wot", help="Display received and sent certifications of an id")
@click.argument("id")
def cliWot(id):
received_sent_certifications(id)
def usage():
message_exit(
"Silkaj: command line client for Duniter currencies\
......@@ -102,89 +259,12 @@ def usage():
)
def manage_cmd():
cli_args = Command()
if cli_args.is_version_request():
message_exit(SILKAJ_VERSION)
subcmd = [
"license",
"about",
"info",
"diffi",
"net",
"network",
"issuers",
"argos",
"amount",
"tx",
"transaction",
"cert",
"generate_auth_file",
"id",
"identities",
"wot",
]
if (
cli_args.is_help_request()
or cli_args.is_usage_request()
or cli_args.subcmd not in subcmd
):
usage()
if cli_args.subcmd == "about":
about()
elif cli_args.subcmd == "info":
currency_info()
elif cli_args.subcmd == "diffi":
difficulties()
elif cli_args.subcmd == "net" or cli_args.subcmd == "network":
if cli_args.contains_switches("sort"):
set_network_sort_keys(cli_args.get_definition("sort"))
if cli_args.contains_switches("s"):
set_network_sort_keys(cli_args.get_definition("s"))
network_info(cli_args.contains_switches("discover"))
elif (
cli_args.subcmd == "issuers"
and cli_args.subsubcmd
and int(cli_args.subsubcmd) >= 0
):
list_issuers(int(cli_args.subsubcmd), cli_args.contains_switches("last"))
elif cli_args.subcmd == "argos":
argos_info()
elif cli_args.subcmd == "amount":
cmd_amount(cli_args)
elif cli_args.subcmd == "tx" or cli_args.subcmd == "transaction":
send_transaction(cli_args)
elif cli_args.subcmd == "cert":
send_certification(cli_args)
elif cli_args.subcmd == "generate_auth_file":
generate_auth_file(cli_args)
elif cli_args.subcmd == "id" or cli_args.subcmd == "identities":
id_pubkey_correspondence(cli_args.subsubcmd)
elif cli_args.subcmd == "wot":
received_sent_certifications(cli_args.subsubcmd)
elif cli_args.subcmd == "license":
display_license()
def about():
print(
"\
\n @@@@@@@@@@@@@\
\n @@@ @ @@@\
\n @@@ @@ @@@@@@ @@. ",
\n @@@ @@ @@@@@@ @@. Silkaj",