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

Commit

Permalink
Merge pull request #9 from iotaledger/release/1.0.2
Browse files Browse the repository at this point in the history
PyOTA-PoW v1.0.2
  • Loading branch information
lzpap authored Oct 21, 2019
2 parents 64ca7a0 + d175a9d commit 5ab966e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ccurl"]
path = ccurl
[submodule "ccurl_repo/ccurl"]
path = ccurl_repo/ccurl
url = https://github.com/iotaledger/ccurl.git
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: python
python:
- '2.7'
- '3.5'
- '3.6'
- '3.7'
before_install: "./init.sh"
install:
- pip install .
script:
- nosetests
deploy:
on:
python: '3.7'
tags: true
provider: pypi
distributions: bdist_wheel sdist
skip_cleanup: true
skip_upload_docs: true
skip_existing: true
user: __token__
password:
secure: ppsDd45z2dXEm+fRP8gTSldI+re64/Q+Q8iRXxKUB22mcbkVUEaqNpYrjd7juQIL1T/LncMunSE8vqd+rEEHcVbLR5nCOyjjPaeXdeQaqWlGCUII3TH6o1V7WhnKG4JM9CocOJNLP3COKmxacfH6e+O8iw1dgrDxXx27Erff82xYlTLBBFsEPYk4njvk0ghe5FztOpMT/im2gNglB27PSFawIEbE7DWVxjD7Bv+dSoGKvgxFnTyfVaIQD2y2NAc0PazLSNRFa6tRmMmKePkzxkN3u7Zupao/SHCZRzCA0d9VlcMmFhFzS28V7pfKz/bj5Xz+9u8WnS3TotJGaEFHKj1pnAoRqw0wVdFlsryCt2FT/ZJfYMrTDViGh8x/ZfVUrLbwQjUHcAhsa2JGDThSTqGc3Arz67hkcQa1Asqtm9Pt+GbhskmbTinFRPt0aS//Ncd6jiMcfw3uzN3d0x60ftwPH26Zd8PjVtTnTv6RVJcVKSh5GrUhBDKUsjguEL0124eMLixfSqwMYG8PfhO3PYpHv5wqSvEL+tuexLxavvy1m927XWhufAFbcuezLb7ePLmJrzvL2NpbuO1KU8CIO/6U2DzptEB/TGbL5N5kY/1CLUvls1GSoF435tg13qG1N+nDoocI/rXVlbg9hDcQUV+WrIyhj6aCleWwIt8lyxU=
24 changes: 12 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Installation

To use the module, follow the steps: - Clone the repo from GitHub:

``$ git clone https://github.com/lzpap/ccurl.interface.py.git``
``$ git clone https://github.com/iotaledger/ccurl.interface.py.git``

- Make sure you have `cmake <https://cmake.org/>`__ availabke on your
- Make sure you have `cmake <https://cmake.org/>`__ available on your
system. This is a build dependecy for the ccurl library.
- Build ccurl according to `build
instructions <https://github.com/iotaledger/ccurl/blob/master/README.md>`__
Expand Down Expand Up @@ -55,17 +55,17 @@ Code Example
::

import iota
from pprint import *
from pprint import pprint
from pow import ccurl_interface

# Generate seed
myseed = iota.crypto.types.Seed.random()

#Generate two addresses
# Generate two addresses
addres_generator = iota.crypto.addresses.AddressGenerator(myseed)
addys = addres_generator.get_addresses(1, count=2)

# preparing transactions
# Preparing transactions
pt = iota.ProposedTransaction(address = iota.Address(addys[0]),
tag = iota.Tag(b'LOCALATTACHINTERFACE99999'),
value = 0)
Expand All @@ -74,16 +74,16 @@ Code Example
tag = iota.Tag(b'LOCALATTACHINTERFACE99999'),
value = 0)

# preparing bundle that consists of both transactions prepared in the previous example
# Preparing bundle that consists of both transactions prepared in the previous example
pb = iota.ProposedBundle(transactions=[pt2,pt])

# generate bundle hash
# Generate bundle hash
pb.finalize()

# declare a api instance
api = iota.Iota("https://nodes.thetangle.org:443") # selecting IOTA node
# Declare an api instance
api = iota.Iota("https://nodes.thetangle.org:443")

# get tips to be approved by your bundle
# Get tips to be approved by your bundle
gta = api.get_transactions_to_approve(depth=3)

minimum_weight_magnitude = 14 # target is mainnet
Expand All @@ -96,7 +96,7 @@ Code Example
gta['branchTransaction'],
mwm
)

# Broadcast transactions on the Tangle
broadcasted = api.broadcast_and_store(bundle_trytes)

Expand All @@ -115,4 +115,4 @@ Contribute
----------

Raise issues:
https://github.com/lzpap/ccurl.interface.py/issues
https://github.com/iotaledger/ccurl.interface.py/issues
Submodule ccurl updated from 000000 to 94d74a
15 changes: 10 additions & 5 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#!/bin/bash
#!/usr/bin/env bash

# ccurl submodule can't be at root level, because then naming collides with
# pyota-ccurl's naming in iota.py repo.
# In iota.crypto.__init__, `from ccurl import ...` tries to import
# from this `ccurl` rather then from `pyota-ccurl`, that results in ImportError.

# Updating ccurl submodule
git submodule update --init --recursive
# Delete binaries if present
rm -f pow/libccurl.so
#rm -f pow/helpers.dll

# Get current working directory
WD=$(pwd)

# Bulding using cmake
echo "Building ccurl library with cmake..."
cd ccurl && mkdir -p build && cd build && cmake .. && cmake --build .
cd ../..
LIB=$(find . -name "*.so")
cd ccurl_repo/ccurl && mkdir -p build && cd build && cmake .. && cmake --build .
cd ../../..
LIB=$(find ./ccurl_repo -name "*.so")

echo "The built library is at:"
echo $LIB
Expand Down
20 changes: 12 additions & 8 deletions pow/ccurl_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from __future__ import absolute_import, division, print_function, \
unicode_literals

from ctypes import *
import iota
from iota import Bundle, TransactionTrytes, TransactionHash, TryteString, \
Transaction
import math
import time
from iota.exceptions import with_context
Expand All @@ -24,10 +28,10 @@ def check_tx_trytes_length(trytes):
"""
Checks if trytes are exactly one transaction in length.
"""
if len(trytes) != iota.TransactionTrytes.LEN:
if len(trytes) != TransactionTrytes.LEN:
raise with_context(
exc=ValueError('Trytes must be {len} trytes long.'.format(
len= iota.TransactionTrytes.LEN
len= TransactionTrytes.LEN
)),

context={
Expand Down Expand Up @@ -105,7 +109,7 @@ def attach_to_tangle(bundle_trytes, # Iterable[TryteString]
previoustx = None

# Construct bundle object
bundle = iota.Bundle.from_tryte_strings(bundle_trytes)
bundle = Bundle.from_tryte_strings(bundle_trytes)

# reversed, beause pyota bundles look like [...tx2,tx1,tx0]
# and we need the tail tx first (tx0)
Expand All @@ -129,14 +133,14 @@ def attach_to_tangle(bundle_trytes, # Iterable[TryteString]
# returns a python unicode string
powed_txn_string = get_powed_tx_trytes(txn_string, mwm)
# construct trytestring from python string
powed_txn_trytes = iota.TryteString(powed_txn_string)
powed_txn_trytes = TryteString(powed_txn_string)
# compute transaction hash
hash_string = get_hash_trytes(powed_txn_string)
hash_trytes = iota.TryteString(hash_string)
hash_= iota.TransactionHash(hash_trytes)
hash_trytes = TryteString(hash_string)
hash_= TransactionHash(hash_trytes)

# Create powed txn object
powed_txn = iota.Transaction.from_tryte_string(
powed_txn = Transaction.from_tryte_string(
trytes=powed_txn_trytes,
hash_=hash_
)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
setup(
name = 'PyOTA-PoW',
description = 'Ccurl PoW Interface for PyOTA',
url = 'https://github.com/lzpap/ccurl.interface.py',
version = '1.0.1',
url = 'https://github.com/iotaledger/ccurl.interface.py',
version = '1.0.2',

long_description = long_description,
packages=['pow'],
Expand Down
1 change: 0 additions & 1 deletion test/test_ccurl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from unittest import TestCase
from pow import ccurl_interface
import iota

class CcurlPowTestcase(TestCase):
"""
Expand Down

0 comments on commit 5ab966e

Please sign in to comment.