From 22376bede4eabd0e7b71cd69ff2796c2231fe4a3 Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 5 Mar 2019 16:28:17 +0100 Subject: [PATCH] protobuf: drop legacy CopyFrom method --- trezorlib/btc.py | 3 +-- trezorlib/protobuf.py | 3 --- trezorlib/tests/support/ckd_public.py | 5 ++--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/trezorlib/btc.py b/trezorlib/btc.py index f22f05340c..c360528506 100644 --- a/trezorlib/btc.py +++ b/trezorlib/btc.py @@ -126,8 +126,7 @@ def sign_tx(client, coin_name, inputs, outputs, details=None, prev_txes=None): serialized_tx = b"" def copy_tx_meta(tx): - tx_copy = messages.TransactionType() - tx_copy.CopyFrom(tx) + tx_copy = messages.TransactionType(**tx) # clear fields tx_copy.inputs_cnt = len(tx.inputs) tx_copy.inputs = [] diff --git a/trezorlib/protobuf.py b/trezorlib/protobuf.py index 55172a7220..187a067867 100644 --- a/trezorlib/protobuf.py +++ b/trezorlib/protobuf.py @@ -165,9 +165,6 @@ class MessageType: else: setattr(self, fname, None) - def CopyFrom(self, obj): - self.__dict__ = obj.__dict__.copy() - def ByteSize(self): data = BytesIO() dump_message(data, self) diff --git a/trezorlib/tests/support/ckd_public.py b/trezorlib/tests/support/ckd_public.py index 144dbe1c6b..b7a60624e8 100644 --- a/trezorlib/tests/support/ckd_public.py +++ b/trezorlib/tests/support/ckd_public.py @@ -71,11 +71,10 @@ def public_ckd(public_node, n): if not isinstance(n, list): raise ValueError("Parameter must be a list") - node = messages.HDNodeType() - node.CopyFrom(public_node) + node = messages.HDNodeType(**public_node) for i in n: - node.CopyFrom(get_subnode(node, i)) + node = get_subnode(node, i) return node