feat!(python): drop Mapping protocol support from MessageType

pull/1324/head
matejcik 4 years ago committed by matejcik
parent 8c460dcbf3
commit a36ccd7e6f

@ -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
@ -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 = []

@ -23,6 +23,7 @@ For serializing (dumping) protobuf types, object with `Writer` interface is requ
"""
import logging
import warnings
from io import BytesIO
from itertools import zip_longest
from typing import (
@ -30,7 +31,6 @@ from typing import (
Callable,
Dict,
Iterable,
Iterator,
List,
Optional,
Tuple,
@ -38,7 +38,6 @@ from typing import (
TypeVar,
Union,
)
import warnings
from typing_extensions import Protocol
@ -280,15 +279,6 @@ class MessageType(metaclass=_MessageTypeMeta):
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)

@ -17,6 +17,7 @@
import hashlib
import hmac
import struct
from copy import copy
import ecdsa
from ecdsa.curves import SECP256k1
@ -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)

Loading…
Cancel
Save