Skip to content

Commit

Permalink
feat!(python): drop Mapping protocol support from MessageType
Browse files Browse the repository at this point in the history
  • Loading branch information
matejcik committed Oct 12, 2020
1 parent 5b986d1 commit fe5f6ad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
3 changes: 2 additions & 1 deletion python/src/trezorlib/btc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.

import warnings
from copy import copy
from decimal import Decimal
from typing import TYPE_CHECKING, Any, Dict, Sequence, Tuple

Expand Down Expand Up @@ -235,7 +236,7 @@ def sign_tx(
serialized_tx = b""

def copy_tx_meta(tx: messages.TransactionType) -> messages.TransactionType:
tx_copy = messages.TransactionType(**tx)
tx_copy = copy(tx)
# clear fields
tx_copy.inputs_cnt = len(tx.inputs)
tx_copy.inputs = []
Expand Down
12 changes: 1 addition & 11 deletions python/src/trezorlib/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@
"""

import logging
import warnings
from io import BytesIO
from itertools import zip_longest
from typing import (
Any,
Callable,
Dict,
Iterable,
Iterator,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
)
import warnings

from typing_extensions import Protocol

Expand Down Expand Up @@ -278,15 +277,6 @@ def __repr__(self) -> str:
d[key] = value
return "<%s: %s>" % (self.__class__.__name__, d)

def __iter__(self) -> Iterator[str]:
return iter(self.keys())

def keys(self) -> Iterator[str]:
return (name for name, _, _ in self.get_fields().values())

def __getitem__(self, key: str) -> Any:
return getattr(self, key)

def ByteSize(self) -> int:
data = BytesIO()
dump_message(data, self)
Expand Down
3 changes: 2 additions & 1 deletion tests/bip32.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import hashlib
import hmac
import struct
from copy import copy

import ecdsa
from ecdsa.curves import SECP256k1
Expand Down Expand Up @@ -67,7 +68,7 @@ def public_ckd(public_node, n):
if not isinstance(n, list):
raise ValueError("Parameter must be a list")

node = messages.HDNodeType(**public_node)
node = copy(public_node)

for i in n:
node = get_subnode(node, i)
Expand Down

0 comments on commit fe5f6ad

Please sign in to comment.