mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-29 00:31:02 +00:00
feat!(python): drop Mapping protocol support from MessageType
This commit is contained in:
parent
8c460dcbf3
commit
a36ccd7e6f
@ -15,6 +15,7 @@
|
|||||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
from copy import copy
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING, Any, Dict, Sequence, Tuple
|
from typing import TYPE_CHECKING, Any, Dict, Sequence, Tuple
|
||||||
|
|
||||||
@ -235,7 +236,7 @@ def sign_tx(
|
|||||||
serialized_tx = b""
|
serialized_tx = b""
|
||||||
|
|
||||||
def copy_tx_meta(tx: messages.TransactionType) -> messages.TransactionType:
|
def copy_tx_meta(tx: messages.TransactionType) -> messages.TransactionType:
|
||||||
tx_copy = messages.TransactionType(**tx)
|
tx_copy = copy(tx)
|
||||||
# clear fields
|
# clear fields
|
||||||
tx_copy.inputs_cnt = len(tx.inputs)
|
tx_copy.inputs_cnt = len(tx.inputs)
|
||||||
tx_copy.inputs = []
|
tx_copy.inputs = []
|
||||||
|
@ -23,6 +23,7 @@ For serializing (dumping) protobuf types, object with `Writer` interface is requ
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import warnings
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
from typing import (
|
from typing import (
|
||||||
@ -30,7 +31,6 @@ from typing import (
|
|||||||
Callable,
|
Callable,
|
||||||
Dict,
|
Dict,
|
||||||
Iterable,
|
Iterable,
|
||||||
Iterator,
|
|
||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
Tuple,
|
Tuple,
|
||||||
@ -38,7 +38,6 @@ from typing import (
|
|||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
import warnings
|
|
||||||
|
|
||||||
from typing_extensions import Protocol
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
@ -280,15 +279,6 @@ class MessageType(metaclass=_MessageTypeMeta):
|
|||||||
d[key] = value
|
d[key] = value
|
||||||
return "<%s: %s>" % (self.__class__.__name__, d)
|
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:
|
def ByteSize(self) -> int:
|
||||||
data = BytesIO()
|
data = BytesIO()
|
||||||
dump_message(data, self)
|
dump_message(data, self)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import struct
|
import struct
|
||||||
|
from copy import copy
|
||||||
|
|
||||||
import ecdsa
|
import ecdsa
|
||||||
from ecdsa.curves import SECP256k1
|
from ecdsa.curves import SECP256k1
|
||||||
@ -67,7 +68,7 @@ def public_ckd(public_node, n):
|
|||||||
if not isinstance(n, list):
|
if not isinstance(n, list):
|
||||||
raise ValueError("Parameter must be a list")
|
raise ValueError("Parameter must be a list")
|
||||||
|
|
||||||
node = messages.HDNodeType(**public_node)
|
node = copy(public_node)
|
||||||
|
|
||||||
for i in n:
|
for i in n:
|
||||||
node = get_subnode(node, i)
|
node = get_subnode(node, i)
|
||||||
|
Loading…
Reference in New Issue
Block a user