Skip to content

Commit

Permalink
Merge pull request #19 from keepkey/py3-multi-sig
Browse files Browse the repository at this point in the history
Fix base58 functions and protobuf build
  • Loading branch information
ngmiller authored Dec 12, 2017
2 parents ffdb067 + 6c3e70a commit d5718f8
Show file tree
Hide file tree
Showing 9 changed files with 1,093 additions and 644 deletions.
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ How to install (Debian-Ubuntu)
* git clone https://github.com/keepkey/python-keepkey.git
* cd python-keepkey
* python setup.py install (or develop)


Running Tests
-------------

To run unit tests that don't require a device:

.. code:: shell
$ python tests/unit/*.py
5 changes: 2 additions & 3 deletions build_pb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ cd $DEVICE_PROTO
echo "Building with protoc version: $(protoc --version)"
for i in messages types exchange ; do
protoc --python_out=$CURDIR/keepkeylib/ -I/usr/include -I. $i.proto
sed -Ee 's/^import ([^.]+_pb2)/from . import \1/' -i "" $CURDIR/keepkeylib/"$i"_pb2.py
sed -i -Ee 's/^import ([^.]+_pb2)/from . import \1/' $CURDIR/keepkeylib/"$i"_pb2.py
done

cd $CURDIR/keepkeylib
sed -i "" 's/5000\([2-5]\)/6000\1/g' types_pb2.py
sed -i 's/5000\([2-5]\)/6000\1/g' $CURDIR/keepkeylib/types_pb2.py
46 changes: 46 additions & 0 deletions keepkeylib/exchange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from protobuf3.fields import Int64Field, MessageField, UInt64Field, BytesField, StringField
from protobuf3.message import Message


class ExchangeAddress(Message):
pass


class ExchangeResponseV2(Message):
pass


class SignedExchangeResponse(Message):
pass


class ExchangeResponse(Message):
pass

ExchangeAddress.add_field('coin_type', StringField(field_number=1, optional=True))
ExchangeAddress.add_field('address', StringField(field_number=2, optional=True))
ExchangeAddress.add_field('dest_tag', StringField(field_number=3, optional=True))
ExchangeAddress.add_field('rs_address', StringField(field_number=4, optional=True))
ExchangeResponseV2.add_field('deposit_address', MessageField(field_number=1, optional=True, message_cls=ExchangeAddress))
ExchangeResponseV2.add_field('deposit_amount', BytesField(field_number=2, optional=True))
ExchangeResponseV2.add_field('expiration', Int64Field(field_number=3, optional=True))
ExchangeResponseV2.add_field('quoted_rate', BytesField(field_number=4, optional=True))
ExchangeResponseV2.add_field('withdrawal_address', MessageField(field_number=5, optional=True, message_cls=ExchangeAddress))
ExchangeResponseV2.add_field('withdrawal_amount', BytesField(field_number=6, optional=True))
ExchangeResponseV2.add_field('return_address', MessageField(field_number=7, optional=True, message_cls=ExchangeAddress))
ExchangeResponseV2.add_field('api_key', BytesField(field_number=8, optional=True))
ExchangeResponseV2.add_field('miner_fee', BytesField(field_number=9, optional=True))
ExchangeResponseV2.add_field('order_id', BytesField(field_number=10, optional=True))
SignedExchangeResponse.add_field('response', MessageField(field_number=1, optional=True, message_cls=ExchangeResponse))
SignedExchangeResponse.add_field('signature', BytesField(field_number=2, optional=True))
SignedExchangeResponse.add_field('responseV2', MessageField(field_number=3, optional=True, message_cls=ExchangeResponseV2))
ExchangeResponse.add_field('deposit_address', MessageField(field_number=1, optional=True, message_cls=ExchangeAddress))
ExchangeResponse.add_field('deposit_amount', UInt64Field(field_number=2, optional=True))
ExchangeResponse.add_field('expiration', Int64Field(field_number=3, optional=True))
ExchangeResponse.add_field('quoted_rate', UInt64Field(field_number=4, optional=True))
ExchangeResponse.add_field('withdrawal_address', MessageField(field_number=5, optional=True, message_cls=ExchangeAddress))
ExchangeResponse.add_field('withdrawal_amount', UInt64Field(field_number=6, optional=True))
ExchangeResponse.add_field('return_address', MessageField(field_number=7, optional=True, message_cls=ExchangeAddress))
ExchangeResponse.add_field('api_key', BytesField(field_number=8, optional=True))
ExchangeResponse.add_field('miner_fee', UInt64Field(field_number=9, optional=True))
ExchangeResponse.add_field('order_id', BytesField(field_number=10, optional=True))
86 changes: 55 additions & 31 deletions keepkeylib/exchange_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d5718f8

Please sign in to comment.