Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

PyOTA v2.0.7 #208

Merged
merged 40 commits into from
Nov 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f601596
Progressive PEP-8 migration.
todofixthis Jun 10, 2018
4ad7219
Progressive PEP-8 migration.
todofixthis Jun 10, 2018
232e2fe
Progressive PEP-8 migration.
todofixthis Jun 10, 2018
850d31d
Progressive PEP-8 migration.
todofixthis Jun 10, 2018
cca655f
Progressive PEP-8 migration.
todofixthis Jun 10, 2018
e5f3f82
Cleaned up code file, added extra docs.
todofixthis Jun 10, 2018
0d57510
[#145] Reformat core commands for PEP-8.
todofixthis Jun 11, 2018
d4662f5
[#145][#184] Reformat for PEP-8, remove dead code.
todofixthis Jun 12, 2018
49e7b8e
[#145] Reformat kerl package for PEP-8.
todofixthis Jun 13, 2018
ba99517
[#145] Reformat rest of crypto package for PEP-8.
todofixthis Jun 13, 2018
24e2c73
Fixed incorrect type hints.
todofixthis Jun 13, 2018
02f4767
[#145] Reformat multisig commands for PEP-8.
todofixthis Jun 15, 2018
3ce90c0
[#145] Reformat multisig crypto for PEP-8.
todofixthis Jun 15, 2018
ac0a6e4
[#145] Reformatted rest of multisig package for PEP-8.
todofixthis Jun 15, 2018
687f68f
[#145] Reformatted transaction package for PEP-8.
todofixthis Jun 15, 2018
a74ec33
[#145] Reformatted API module for PEP-8 🤕
todofixthis Jun 15, 2018
1dcad0a
[#145] Reformatted codecs module for PEP-8.
todofixthis Jun 15, 2018
1879c01
[#145] Reformatted rest of `iota` package for PEP-8.
todofixthis Jun 15, 2018
3f0f132
[#145] Reformatted examples for PEP-8.
todofixthis Jun 22, 2018
f17d6e3
usage of bundle hash by find_transactions
oskyk Jun 27, 2018
b3bc935
Merge pull request #189 from oskyk/186-find-tx-bundle-hash
todofixthis Jun 28, 2018
04f2312
[#145] Maintain PEP-8 on `develop` branch.
todofixthis Jun 28, 2018
09dbc94
#181 security_level into get_account_data
oskyk Jun 28, 2018
492de37
#181 security_level into get_account_data test fixes
oskyk Jun 28, 2018
9c74dfc
Merge pull request #190 from oskyk/181-security-level-in-get-account-…
todofixthis Jul 1, 2018
cef03e7
fixes #191
Jul 4, 2018
3751bb0
Reverting test changes
Hribek25 Jul 5, 2018
fbc1f61
[#145] Reformat setup.py for PEP-8.
todofixthis Jul 6, 2018
cdc0551
Merge branch 'develop' into master
Hribek25 Jul 10, 2018
2baf06b
Merge pull request #192 from Hribek25/master
todofixthis Jul 16, 2018
f072b2f
examples/send_transfer: cleanups for better user experience
EmbeddedAndroid Jul 6, 2018
11b727e
Setting depth default value to 3
Jul 18, 2018
292c4ce
Merge pull request #194 from EmbeddedAndroid/send-transfer-example
todofixthis Jul 24, 2018
2fa8c0d
Merge pull request #200 from redondo-mk/195_default_depth_value
todofixthis Jul 24, 2018
3032c57
Added missing symbols to public API.
todofixthis Jul 24, 2018
936ad37
Merge branch 'develop' of github:iotaledger/iota.lib.py into develop
todofixthis Jul 24, 2018
8d04b45
[#206] Fix exception when adding client instance to abstract class.
todofixthis Nov 3, 2018
b69227e
Merge pull request #207 from iotaledger/feature/206-client-instance-a…
todofixthis Nov 4, 2018
6310d7e
Bumping version number.
todofixthis Nov 4, 2018
6c44d4f
Fixed typo in documentation.
todofixthis Nov 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 105 additions & 100 deletions examples/address_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,128 +4,133 @@
"""

from __future__ import absolute_import, division, print_function, \
unicode_literals
unicode_literals

from argparse import ArgumentParser
from getpass import getpass as secure_input
from sys import argv
from typing import Optional, Text

from iota import __version__, Iota
from six import binary_type, moves as compat, text_type

from iota import Iota, __version__
from iota.crypto.addresses import AddressGenerator
from iota.crypto.types import Seed
from six import binary_type, moves as compat, text_type


def main(uri, index, count, security, checksum):
# type: (Text, int, Optional[int], Optional[int], bool) -> None
seed = get_seed()
# type: (Text, int, Optional[int], Optional[int], bool) -> None
seed = get_seed()

# Create the API instance.
# Note: If ``seed`` is null, a random seed will be generated.
api = Iota(uri, seed)
# Create the API instance.
# Note: If ``seed`` is null, a random seed will be generated.
api = Iota(uri, seed)

# If we generated a random seed, then we need to display it to the
# user, or else they won't be able to use their new addresses!
if not seed:
print('A random seed has been generated. Press return to see it.')
output_seed(api.seed)
# If we generated a random seed, then we need to display it to the
# user, or else they won't be able to use their new addresses!
if not seed:
print('A random seed has been generated. Press return to see it.')
output_seed(api.seed)

print('Generating addresses. This may take a few minutes...')
print('')
print('Generating addresses. This may take a few minutes...')
print('')

# Here's where all the magic happens!
api_response = api.get_new_addresses(index, count, security, checksum)
for addy in api_response['addresses']:
print(binary_type(addy).decode('ascii'))
# Here's where all the magic happens!
api_response = api.get_new_addresses(index, count, security, checksum)
for addy in api_response['addresses']:
print(binary_type(addy).decode('ascii'))

print('')
print('')


def get_seed():
# type: () -> binary_type
"""
Prompts the user securely for their seed.
"""
print(
'Enter seed and press return (typing will not be shown). '
'If empty, a random seed will be generated and displayed on the screen.'
)
seed = secure_input('') # type: Text
return seed.encode('ascii')
# type: () -> binary_type
"""
Prompts the user securely for their seed.
"""
print(
'Enter seed and press return (typing will not be shown). '
'If empty, a random seed will be generated and displayed on the screen.'
)
seed = secure_input('') # type: Text
return seed.encode('ascii')


def output_seed(seed):
# type: (Seed) -> None
"""
Outputs the user's seed to stdout, along with lots of warnings
about security.
"""
print(
'WARNING: Anyone who has your seed can spend your IOTAs! '
'Clear the screen after recording your seed!'
)
compat.input('')
print('Your seed is:')
print('')
print(binary_type(seed).decode('ascii'))
print('')

print(
'Clear the screen to prevent shoulder surfing, '
'and press return to continue.'
)
print('https://en.wikipedia.org/wiki/Shoulder_surfing_(computer_security)')
compat.input('')
# type: (Seed) -> None
"""
Outputs the user's seed to stdout, along with lots of warnings
about security.
"""
print(
'WARNING: Anyone who has your seed can spend your IOTAs! '
'Clear the screen after recording your seed!'
)
compat.input('')
print('Your seed is:')
print('')
print(binary_type(seed).decode('ascii'))
print('')

print(
'Clear the screen to prevent shoulder surfing, '
'and press return to continue.'
)
print('https://en.wikipedia.org/wiki/Shoulder_surfing_(computer_security)')
compat.input('')


if __name__ == '__main__':
parser = ArgumentParser(
description = __doc__,
epilog = 'PyOTA v{version}'.format(version=__version__),
)

parser.add_argument(
'--uri',
type = text_type,
default = 'http://localhost:14265/',

help =
'URI of the node to connect to '
'(defaults to http://localhost:14265/).',
)

parser.add_argument(
'--index',
type = int,
default = 0,
help = 'Index of the key to generate.',
)

parser.add_argument(
'--count',
type = int,
default = None,

help =
'Number of addresses to generate. '
'If not specified, the first unused address will be returned.'
)

parser.add_argument(
'--security',
type = int,
default = AddressGenerator.DEFAULT_SECURITY_LEVEL,
help = 'Security level to be used for the private key / address. '
'Can be 1, 2 or 3',
)

parser.add_argument(
'--with-checksum',
action = 'store_true',
default = False,
dest = 'checksum',
help = 'List the address with the checksum.',
)

main(**vars(parser.parse_args(argv[1:])))
parser = ArgumentParser(
description=__doc__,
epilog='PyOTA v{version}'.format(version=__version__),
)

parser.add_argument(
'--uri',
type=text_type,
default='http://localhost:14265/',

help=(
'URI of the node to connect to '
'(defaults to http://localhost:14265/).'
),
)

parser.add_argument(
'--index',
type=int,
default=0,
help='Index of the key to generate.',
)

parser.add_argument(
'--count',
type=int,
default=None,

help=(
'Number of addresses to generate. '
'If not specified, the first unused address will be returned.'
),
)

parser.add_argument(
'--security',
type=int,
default=AddressGenerator.DEFAULT_SECURITY_LEVEL,
help=(
'Security level to be used for the private key / address. '
'Can be 1, 2 or 3'
),
)

parser.add_argument(
'--with-checksum',
action='store_true',
default=False,
dest='checksum',
help='List the address with the checksum.',
)

main(**vars(parser.parse_args(argv[1:])))
65 changes: 34 additions & 31 deletions examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from __future__ import absolute_import, division, print_function, \
unicode_literals
unicode_literals

from argparse import ArgumentParser
from pprint import pprint
Expand All @@ -19,36 +19,39 @@


def main(uri):
# type: (Text) -> None
api = StrictIota(uri)

try:
node_info = api.get_node_info()
except ConnectionError as e:
print("Hm. {uri} isn't responding. Is the node running?".format(uri=uri))
print(e)
except BadApiResponse as e:
print("Looks like {uri} isn't very talkative today ):".format(uri=uri))
print(e)
else:
print('Hello {uri}!'.format(uri=uri))
pprint(node_info)
# type: (Text) -> None
api = StrictIota(uri)

try:
node_info = api.get_node_info()
except ConnectionError as e:
print(
"Hm. {uri} isn't responding; is the node running?".format(uri=uri)
)
print(e)
except BadApiResponse as e:
print("Looks like {uri} isn't very talkative today ):".format(uri=uri))
print(e)
else:
print('Hello {uri}!'.format(uri=uri))
pprint(node_info)


if __name__ == '__main__':
parser = ArgumentParser(
description = __doc__,
epilog = 'PyOTA v{version}'.format(version=__version__),
)

parser.add_argument(
'--uri',
type = text_type,
default = 'http://localhost:14265/',

help =
'URI of the node to connect to '
'(defaults to http://localhost:14265/).',
)

main(**vars(parser.parse_args(argv[1:])))
parser = ArgumentParser(
description=__doc__,
epilog='PyOTA v{version}'.format(version=__version__),
)

parser.add_argument(
'--uri',
type=text_type,
default='http://localhost:14265/',

help=(
'URI of the node to connect to '
'(defaults to http://localhost:14265/).'
),
)

main(**vars(parser.parse_args(argv[1:])))
Loading