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

Commit 9fea2a8

Browse files
authored
Merge pull request #69 from iotaledger/release/2.0.0
2.0.0-beta1
2 parents e345de9 + b409ffd commit 9fea2a8

36 files changed

+32345
-2861
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
dist: trusty
12
language: python
23
python:
34
- '2.7'
@@ -9,7 +10,7 @@ deploy:
910
on:
1011
branch: master
1112
provider: pypi
12-
distribution: sdist bdist_wheel
13+
distribution: bdist_wheel sdist
1314
skip_upload_docs: true
1415
user: phx
1516
password:

README.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
=====
55
PyOTA
66
=====
7+
.. warning::
8+
⚠️ This is pre-release software; it may have performance or stability issues.
9+
Please do not use this software on mainnet until v2.0.0 stable is released. ⚠️
10+
711
This is the official Python library for the IOTA Core.
812

913
It implements both the `official API`_, as well as newly-proposed functionality
@@ -28,9 +32,13 @@ PyOTA is compatible with Python 3.6, 3.5 and 2.7.
2832
============
2933
Installation
3034
============
35+
.. warning::
36+
⚠️ This is pre-release software; it may have performance or stability issues.
37+
Please do not use this software on mainnet until v2.0.0 stable is released. ⚠️
38+
3139
To install the latest version::
3240

33-
pip install pyota
41+
pip install --pre pyota
3442

3543
Optional C Extension
3644
====================
@@ -39,15 +47,8 @@ cryptography features significantly (speedups of **60x** are common!).
3947

4048
To install this extension, use the following command::
4149

42-
pip install pyota[ccurl]
43-
44-
45-
.. note::
46-
47-
The C extension is currently only compatible with Python 3.
50+
pip install --pre pyota[ccurl]
4851

49-
If you are familiar with Python 2's C API, we'd love to hear from you!
50-
See `<https://github.com/todofixthis/pyota-ccurl/issues/4>`_ for more info.
5152

5253
Installing from Source
5354
======================

examples/routingwrapper_pow.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# coding=utf-8
2+
"""
3+
Simple example using the RoutingWrapper to route API requests to different nodes.
4+
See: https://github.com/iotaledger/documentation/blob/iota.lib.py/1.2.x/source/includes/_adapters.md#routingwrapper
5+
"""
6+
from iota import *
7+
from iota.adapter.wrappers import RoutingWrapper
8+
9+
api =\
10+
Iota(
11+
# Send PoW requests to local node.
12+
# All other requests go to light wallet node.
13+
RoutingWrapper('http://service.iotasupport.com:14265')
14+
.add_route('attachToTangle', 'http://localhost:14265'),
15+
16+
# Seed used for cryptographic functions.
17+
seed = b'SEED9GOES9HERE'
18+
)
19+
20+
# Example of sending a transfer using the adapter.
21+
bundle = api.send_transfer(
22+
depth = 100,
23+
transfers = [
24+
ProposedTransaction(
25+
# Recipient of the transfer.
26+
address =
27+
Address(
28+
#b'TESTVALUE9DONTUSEINPRODUCTION99999FBFFTG'
29+
#b'QFWEHEL9KCAFXBJBXGE9HID9XCOHFIDABHDG9AHDR'
30+
),
31+
32+
# Amount of IOTA to transfer.
33+
# This value may be zero.
34+
value = 1,
35+
36+
# Optional tag to attach to the transfer.
37+
tag = Tag(b'ADAPT'),
38+
39+
# Optional message to include with the transfer.
40+
message = TryteString.from_string('Hello!'),
41+
),
42+
],
43+
)

examples/send_transfer.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# coding=utf-8
2+
"""
3+
Example script that shows how to use PyOTA to send a transfer to an address.
4+
"""
5+
from iota import *
6+
7+
8+
# Create the API instance.
9+
api =\
10+
Iota(
11+
# URI of a locally running node.
12+
'http://localhost:14265/',
13+
14+
# Seed used for cryptographic functions.
15+
seed = b'SEED9GOES9HERE'
16+
)
17+
18+
# For more information, see :py:meth:`Iota.send_transfer`.
19+
api.send_transfer(
20+
depth = 100,
21+
22+
# One or more :py:class:`ProposedTransaction` objects to add to the
23+
# bundle.
24+
transfers = [
25+
ProposedTransaction(
26+
# Recipient of the transfer.
27+
address =
28+
Address(
29+
b'TESTVALUE9DONTUSEINPRODUCTION99999FBFFTG'
30+
b'QFWEHEL9KCAFXBJBXGE9HID9XCOHFIDABHDG9AHDR'
31+
),
32+
33+
# Amount of IOTA to transfer.
34+
# This value may be zero.
35+
value = 1,
36+
37+
# Optional tag to attach to the transfer.
38+
tag = Tag(b'EXAMPLE'),
39+
40+
# Optional message to include with the transfer.
41+
message = TryteString.from_string('Hello!'),
42+
),
43+
],
44+
)

iota/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def default_min_weight_magnitude(self):
133133
Returns the default ``min_weight_magnitude`` value to use for API
134134
requests.
135135
"""
136-
return 13 if self.testnet else 18
136+
return 9 if self.testnet else 14
137137

138138
def add_neighbors(self, uris):
139139
# type: (Iterable[Text]) -> dict
@@ -879,4 +879,4 @@ def send_trytes(self, trytes, depth, min_weight_magnitude=None):
879879
trytes = trytes,
880880
depth = depth,
881881
minWeightMagnitude = min_weight_magnitude,
882-
)
882+
)

iota/commands/__init__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
from abc import ABCMeta, abstractmethod as abstract_method
66
from importlib import import_module
7-
from inspect import isabstract as is_abstract, isclass as is_class, \
8-
getmembers as get_members
7+
from inspect import getmembers as get_members, isabstract as is_abstract, \
8+
isclass as is_class
99
from pkgutil import walk_packages
1010
from types import ModuleType
11-
from typing import Dict, Mapping, Optional, Text, Union
11+
from typing import Any, Dict, Mapping, Optional, Text, Union
1212

1313
import filters as f
14-
from iota.exceptions import with_context
15-
from six import with_metaclass, string_types
14+
from six import string_types, with_metaclass
1615

1716
from iota.adapter import BaseAdapter
17+
from iota.exceptions import with_context
1818

1919
__all__ = [
2020
'BaseCommand',
@@ -49,10 +49,14 @@ def discover_commands(package, recursively=True):
4949

5050
commands = {}
5151

52-
for _, name, is_package in walk_packages(package.__path__):
52+
for _, name, is_package in walk_packages(package.__path__, package.__name__ + '.'):
5353
# Loading the module is good enough; the CommandMeta metaclass will
5454
# ensure that any commands in the module get registered.
55-
sub_package = import_module(package.__name__ + '.' + name)
55+
56+
# Prefix in name module move to function "walk_packages" for fix
57+
# conflict with names importing packages
58+
# Bug https://github.com/iotaledger/iota.lib.py/issues/63
59+
sub_package = import_module(name)
5660

5761
# Index any command classes that we find.
5862
for (_, obj) in get_members(sub_package):
@@ -99,7 +103,7 @@ def __init__(self, adapter):
99103
self.response = None # type: dict
100104

101105
def __call__(self, **kwargs):
102-
# type: (dict) -> dict
106+
# type: (**Any) -> dict
103107
"""
104108
Sends the command to the node.
105109
"""

iota/commands/extended/get_new_addresses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from __future__ import absolute_import, division, print_function, \
33
unicode_literals
44

5-
from typing import Optional, List
5+
from typing import List, Optional
66

77
import filters as f
8-
from iota import Address
98

9+
from iota import Address
1010
from iota.commands import FilterCommand, RequestFilter
1111
from iota.commands.core.find_transactions import FindTransactionsCommand
1212
from iota.crypto.addresses import AddressGenerator

iota/crypto/addresses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Generator, Iterable, List, MutableSequence
66

77
from iota import Address, TRITS_PER_TRYTE, TrytesCompatible
8-
from iota.crypto import Curl
8+
from iota.crypto.kerl import Kerl
99
from iota.crypto.signing import KeyGenerator, KeyIterator
1010
from iota.crypto.types import Digest, PrivateKey, Seed
1111
from iota.exceptions import with_context
@@ -157,7 +157,7 @@ def address_from_digest(digest):
157157
"""
158158
address_trits = [0] * (Address.LEN * TRITS_PER_TRYTE) # type: MutableSequence[int]
159159

160-
sponge = Curl()
160+
sponge = Kerl()
161161
sponge.absorb(digest.as_trits())
162162
sponge.squeeze(address_trits)
163163

iota/crypto/kerl/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# coding=utf-8
2+
from __future__ import absolute_import, division, print_function, \
3+
unicode_literals
4+
5+
from .pykerl import *

0 commit comments

Comments
 (0)