mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-29 12:18:51 +00:00
python: drop deprecated name CallException
This commit is contained in:
parent
7a85d93d94
commit
b440ca1ec5
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from . import messages
|
from . import exceptions, messages
|
||||||
from .tools import CallException, expect, normalize_nfc, session
|
from .tools import expect, normalize_nfc, session
|
||||||
|
|
||||||
|
|
||||||
def from_json(json_dict):
|
def from_json(json_dict):
|
||||||
@ -114,8 +114,8 @@ def verify_message(client, coin_name, address, signature, message):
|
|||||||
coin_name=coin_name,
|
coin_name=coin_name,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except CallException as e:
|
except exceptions.TrezorFailure as e:
|
||||||
resp = e
|
return False
|
||||||
return isinstance(resp, messages.Success)
|
return isinstance(resp, messages.Success)
|
||||||
|
|
||||||
|
|
||||||
@ -197,13 +197,10 @@ def sign_tx(client, coin_name, inputs, outputs, details=None, prev_txes=None):
|
|||||||
msg.extra_data = current_tx.extra_data[o : o + l]
|
msg.extra_data = current_tx.extra_data[o : o + l]
|
||||||
res = client.call(messages.TxAck(tx=msg))
|
res = client.call(messages.TxAck(tx=msg))
|
||||||
|
|
||||||
if isinstance(res, messages.Failure):
|
|
||||||
raise CallException("Signing failed")
|
|
||||||
|
|
||||||
if not isinstance(res, messages.TxRequest):
|
if not isinstance(res, messages.TxRequest):
|
||||||
raise CallException("Unexpected message")
|
raise exceptions.TrezorException("Unexpected message")
|
||||||
|
|
||||||
if None in signatures:
|
if None in signatures:
|
||||||
raise RuntimeError("Some signatures are missing!")
|
raise exceptions.TrezorException("Some signatures are missing!")
|
||||||
|
|
||||||
return signatures, serialized_tx
|
return signatures, serialized_tx
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from . import messages
|
from . import exceptions, messages
|
||||||
from .tools import CallException, b58decode, expect, session
|
from .tools import b58decode, expect, session
|
||||||
|
|
||||||
|
|
||||||
def name_to_number(name):
|
def name_to_number(name):
|
||||||
@ -337,12 +337,13 @@ def sign_tx(client, address, transaction, chain_id):
|
|||||||
response = client.call(actions.pop(0))
|
response = client.call(actions.pop(0))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# pop from empty list
|
# pop from empty list
|
||||||
raise CallException(
|
raise exceptions.TrezorException(
|
||||||
"Eos.UnexpectedEndOfOperations",
|
"Reached end of operations without a signature."
|
||||||
"Reached end of operations without a signature.",
|
|
||||||
) from None
|
) from None
|
||||||
|
|
||||||
if not isinstance(response, messages.EosSignedTx):
|
if not isinstance(response, messages.EosSignedTx):
|
||||||
raise CallException(messages.FailureType.UnexpectedMessage, response)
|
raise exceptions.TrezorException(
|
||||||
|
"Unexpected message: {}".format(response.__class__.__name__)
|
||||||
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
# You should have received a copy of the License along with this library.
|
# You should have received a copy of the License along with this library.
|
||||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
from . import messages as proto
|
from . import exceptions, messages
|
||||||
from .tools import CallException, expect, normalize_nfc, session
|
from .tools import expect, normalize_nfc, session
|
||||||
|
|
||||||
|
|
||||||
def int_to_big_endian(value):
|
def int_to_big_endian(value):
|
||||||
@ -25,15 +25,17 @@ def int_to_big_endian(value):
|
|||||||
# ====== Client functions ====== #
|
# ====== Client functions ====== #
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.EthereumAddress, field="address")
|
@expect(messages.EthereumAddress, field="address")
|
||||||
def get_address(client, n, show_display=False, multisig=None):
|
def get_address(client, n, show_display=False, multisig=None):
|
||||||
return client.call(proto.EthereumGetAddress(address_n=n, show_display=show_display))
|
return client.call(
|
||||||
|
messages.EthereumGetAddress(address_n=n, show_display=show_display)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.EthereumPublicKey)
|
@expect(messages.EthereumPublicKey)
|
||||||
def get_public_node(client, n, show_display=False):
|
def get_public_node(client, n, show_display=False):
|
||||||
return client.call(
|
return client.call(
|
||||||
proto.EthereumGetPublicKey(address_n=n, show_display=show_display)
|
messages.EthereumGetPublicKey(address_n=n, show_display=show_display)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ def sign_tx(
|
|||||||
chain_id=None,
|
chain_id=None,
|
||||||
tx_type=None,
|
tx_type=None,
|
||||||
):
|
):
|
||||||
msg = proto.EthereumSignTx(
|
msg = messages.EthereumSignTx(
|
||||||
address_n=n,
|
address_n=n,
|
||||||
nonce=int_to_big_endian(nonce),
|
nonce=int_to_big_endian(nonce),
|
||||||
gas_price=int_to_big_endian(gas_price),
|
gas_price=int_to_big_endian(gas_price),
|
||||||
@ -71,7 +73,7 @@ def sign_tx(
|
|||||||
while response.data_length is not None:
|
while response.data_length is not None:
|
||||||
data_length = response.data_length
|
data_length = response.data_length
|
||||||
data, chunk = data[data_length:], data[:data_length]
|
data, chunk = data[data_length:], data[:data_length]
|
||||||
response = client.call(proto.EthereumTxAck(data_chunk=chunk))
|
response = client.call(messages.EthereumTxAck(data_chunk=chunk))
|
||||||
|
|
||||||
# https://github.com/trezor/trezor-core/pull/311
|
# https://github.com/trezor/trezor-core/pull/311
|
||||||
# only signature bit returned. recalculate signature_v
|
# only signature bit returned. recalculate signature_v
|
||||||
@ -81,22 +83,20 @@ def sign_tx(
|
|||||||
return response.signature_v, response.signature_r, response.signature_s
|
return response.signature_v, response.signature_r, response.signature_s
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.EthereumMessageSignature)
|
@expect(messages.EthereumMessageSignature)
|
||||||
def sign_message(client, n, message):
|
def sign_message(client, n, message):
|
||||||
message = normalize_nfc(message)
|
message = normalize_nfc(message)
|
||||||
return client.call(proto.EthereumSignMessage(address_n=n, message=message))
|
return client.call(messages.EthereumSignMessage(address_n=n, message=message))
|
||||||
|
|
||||||
|
|
||||||
def verify_message(client, address, signature, message):
|
def verify_message(client, address, signature, message):
|
||||||
message = normalize_nfc(message)
|
message = normalize_nfc(message)
|
||||||
try:
|
try:
|
||||||
resp = client.call(
|
resp = client.call(
|
||||||
proto.EthereumVerifyMessage(
|
messages.EthereumVerifyMessage(
|
||||||
address=address, signature=signature, message=message
|
address=address, signature=signature, message=message
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except CallException as e:
|
except exceptions.TrezorFailure:
|
||||||
resp = e
|
return False
|
||||||
if isinstance(resp, proto.Success):
|
return isinstance(resp, messages.Success)
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
@ -14,45 +14,47 @@
|
|||||||
# You should have received a copy of the License along with this library.
|
# You should have received a copy of the License along with this library.
|
||||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
from . import messages as proto
|
from . import exceptions, messages
|
||||||
from .protobuf import dict_to_proto
|
from .protobuf import dict_to_proto
|
||||||
from .tools import CallException, dict_from_camelcase, expect, normalize_nfc
|
from .tools import dict_from_camelcase, expect, normalize_nfc
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.LiskAddress, field="address")
|
@expect(messages.LiskAddress, field="address")
|
||||||
def get_address(client, n, show_display=False):
|
def get_address(client, n, show_display=False):
|
||||||
return client.call(proto.LiskGetAddress(address_n=n, show_display=show_display))
|
return client.call(messages.LiskGetAddress(address_n=n, show_display=show_display))
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.LiskPublicKey)
|
@expect(messages.LiskPublicKey)
|
||||||
def get_public_key(client, n, show_display=False):
|
def get_public_key(client, n, show_display=False):
|
||||||
return client.call(proto.LiskGetPublicKey(address_n=n, show_display=show_display))
|
return client.call(
|
||||||
|
messages.LiskGetPublicKey(address_n=n, show_display=show_display)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.LiskMessageSignature)
|
@expect(messages.LiskMessageSignature)
|
||||||
def sign_message(client, n, message):
|
def sign_message(client, n, message):
|
||||||
message = normalize_nfc(message)
|
message = normalize_nfc(message)
|
||||||
return client.call(proto.LiskSignMessage(address_n=n, message=message))
|
return client.call(messages.LiskSignMessage(address_n=n, message=message))
|
||||||
|
|
||||||
|
|
||||||
def verify_message(client, pubkey, signature, message):
|
def verify_message(client, pubkey, signature, message):
|
||||||
message = normalize_nfc(message)
|
message = normalize_nfc(message)
|
||||||
try:
|
try:
|
||||||
resp = client.call(
|
resp = client.call(
|
||||||
proto.LiskVerifyMessage(
|
messages.LiskVerifyMessage(
|
||||||
signature=signature, public_key=pubkey, message=message
|
signature=signature, public_key=pubkey, message=message
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except CallException as e:
|
except exceptions.TrezorFailure:
|
||||||
resp = e
|
return False
|
||||||
return isinstance(resp, proto.Success)
|
return isinstance(resp, messages.Success)
|
||||||
|
|
||||||
|
|
||||||
RENAMES = {"lifetime": "life_time", "keysgroup": "keys_group"}
|
RENAMES = {"lifetime": "life_time", "keysgroup": "keys_group"}
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.LiskSignedTx)
|
@expect(messages.LiskSignedTx)
|
||||||
def sign_tx(client, n, transaction):
|
def sign_tx(client, n, transaction):
|
||||||
transaction = dict_from_camelcase(transaction, renames=RENAMES)
|
transaction = dict_from_camelcase(transaction, renames=RENAMES)
|
||||||
msg = dict_to_proto(proto.LiskTransactionCommon, transaction)
|
msg = dict_to_proto(messages.LiskTransactionCommon, transaction)
|
||||||
return client.call(proto.LiskSignTx(address_n=n, transaction=msg))
|
return client.call(messages.LiskSignTx(address_n=n, transaction=msg))
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from . import messages as proto
|
from . import exceptions, messages
|
||||||
from .tools import CallException, expect
|
from .tools import expect
|
||||||
|
|
||||||
TYPE_TRANSACTION_TRANSFER = 0x0101
|
TYPE_TRANSACTION_TRANSFER = 0x0101
|
||||||
TYPE_IMPORTANCE_TRANSFER = 0x0801
|
TYPE_IMPORTANCE_TRANSFER = 0x0801
|
||||||
@ -30,7 +30,7 @@ TYPE_MOSAIC_SUPPLY_CHANGE = 0x4002
|
|||||||
|
|
||||||
|
|
||||||
def create_transaction_common(transaction):
|
def create_transaction_common(transaction):
|
||||||
msg = proto.NEMTransactionCommon()
|
msg = messages.NEMTransactionCommon()
|
||||||
msg.network = (transaction["version"] >> 24) & 0xFF
|
msg.network = (transaction["version"] >> 24) & 0xFF
|
||||||
msg.timestamp = transaction["timeStamp"]
|
msg.timestamp = transaction["timeStamp"]
|
||||||
msg.fee = transaction["fee"]
|
msg.fee = transaction["fee"]
|
||||||
@ -43,7 +43,7 @@ def create_transaction_common(transaction):
|
|||||||
|
|
||||||
|
|
||||||
def create_transfer(transaction):
|
def create_transfer(transaction):
|
||||||
msg = proto.NEMTransfer()
|
msg = messages.NEMTransfer()
|
||||||
msg.recipient = transaction["recipient"]
|
msg.recipient = transaction["recipient"]
|
||||||
msg.amount = transaction["amount"]
|
msg.amount = transaction["amount"]
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ def create_transfer(transaction):
|
|||||||
|
|
||||||
if "mosaics" in transaction:
|
if "mosaics" in transaction:
|
||||||
msg.mosaics = [
|
msg.mosaics = [
|
||||||
proto.NEMMosaic(
|
messages.NEMMosaic(
|
||||||
namespace=mosaic["mosaicId"]["namespaceId"],
|
namespace=mosaic["mosaicId"]["namespaceId"],
|
||||||
mosaic=mosaic["mosaicId"]["name"],
|
mosaic=mosaic["mosaicId"]["name"],
|
||||||
quantity=mosaic["quantity"],
|
quantity=mosaic["quantity"],
|
||||||
@ -67,9 +67,9 @@ def create_transfer(transaction):
|
|||||||
|
|
||||||
|
|
||||||
def create_aggregate_modification(transactions):
|
def create_aggregate_modification(transactions):
|
||||||
msg = proto.NEMAggregateModification()
|
msg = messages.NEMAggregateModification()
|
||||||
msg.modifications = [
|
msg.modifications = [
|
||||||
proto.NEMCosignatoryModification(
|
messages.NEMCosignatoryModification(
|
||||||
type=modification["modificationType"],
|
type=modification["modificationType"],
|
||||||
public_key=bytes.fromhex(modification["cosignatoryAccount"]),
|
public_key=bytes.fromhex(modification["cosignatoryAccount"]),
|
||||||
)
|
)
|
||||||
@ -83,7 +83,7 @@ def create_aggregate_modification(transactions):
|
|||||||
|
|
||||||
|
|
||||||
def create_provision_namespace(transaction):
|
def create_provision_namespace(transaction):
|
||||||
msg = proto.NEMProvisionNamespace()
|
msg = messages.NEMProvisionNamespace()
|
||||||
msg.namespace = transaction["newPart"]
|
msg.namespace = transaction["newPart"]
|
||||||
|
|
||||||
if transaction["parent"]:
|
if transaction["parent"]:
|
||||||
@ -96,8 +96,8 @@ def create_provision_namespace(transaction):
|
|||||||
|
|
||||||
def create_mosaic_creation(transaction):
|
def create_mosaic_creation(transaction):
|
||||||
definition = transaction["mosaicDefinition"]
|
definition = transaction["mosaicDefinition"]
|
||||||
msg = proto.NEMMosaicCreation()
|
msg = messages.NEMMosaicCreation()
|
||||||
msg.definition = proto.NEMMosaicDefinition()
|
msg.definition = messages.NEMMosaicDefinition()
|
||||||
msg.definition.namespace = definition["id"]["namespaceId"]
|
msg.definition.namespace = definition["id"]["namespaceId"]
|
||||||
msg.definition.mosaic = definition["id"]["name"]
|
msg.definition.mosaic = definition["id"]["name"]
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ def create_mosaic_creation(transaction):
|
|||||||
|
|
||||||
|
|
||||||
def create_supply_change(transaction):
|
def create_supply_change(transaction):
|
||||||
msg = proto.NEMMosaicSupplyChange()
|
msg = messages.NEMMosaicSupplyChange()
|
||||||
msg.namespace = transaction["mosaicId"]["namespaceId"]
|
msg.namespace = transaction["mosaicId"]["namespaceId"]
|
||||||
msg.mosaic = transaction["mosaicId"]["name"]
|
msg.mosaic = transaction["mosaicId"]["name"]
|
||||||
msg.type = transaction["supplyType"]
|
msg.type = transaction["supplyType"]
|
||||||
@ -138,7 +138,7 @@ def create_supply_change(transaction):
|
|||||||
|
|
||||||
|
|
||||||
def create_importance_transfer(transaction):
|
def create_importance_transfer(transaction):
|
||||||
msg = proto.NEMImportanceTransfer()
|
msg = messages.NEMImportanceTransfer()
|
||||||
msg.mode = transaction["importanceTransfer"]["mode"]
|
msg.mode = transaction["importanceTransfer"]["mode"]
|
||||||
msg.public_key = bytes.fromhex(transaction["importanceTransfer"]["publicKey"])
|
msg.public_key = bytes.fromhex(transaction["importanceTransfer"]["publicKey"])
|
||||||
return msg
|
return msg
|
||||||
@ -162,7 +162,7 @@ def fill_transaction_by_type(msg, transaction):
|
|||||||
|
|
||||||
|
|
||||||
def create_sign_tx(transaction):
|
def create_sign_tx(transaction):
|
||||||
msg = proto.NEMSignTx()
|
msg = messages.NEMSignTx()
|
||||||
msg.transaction = create_transaction_common(transaction)
|
msg.transaction = create_transaction_common(transaction)
|
||||||
msg.cosigning = transaction["type"] == TYPE_MULTISIG_SIGNATURE
|
msg.cosigning = transaction["type"] == TYPE_MULTISIG_SIGNATURE
|
||||||
|
|
||||||
@ -181,19 +181,19 @@ def create_sign_tx(transaction):
|
|||||||
# ====== Client functions ====== #
|
# ====== Client functions ====== #
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.NEMAddress, field="address")
|
@expect(messages.NEMAddress, field="address")
|
||||||
def get_address(client, n, network, show_display=False):
|
def get_address(client, n, network, show_display=False):
|
||||||
return client.call(
|
return client.call(
|
||||||
proto.NEMGetAddress(address_n=n, network=network, show_display=show_display)
|
messages.NEMGetAddress(address_n=n, network=network, show_display=show_display)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.NEMSignedTx)
|
@expect(messages.NEMSignedTx)
|
||||||
def sign_tx(client, n, transaction):
|
def sign_tx(client, n, transaction):
|
||||||
try:
|
try:
|
||||||
msg = create_sign_tx(transaction)
|
msg = create_sign_tx(transaction)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise CallException(e.args)
|
raise exceptions.TrezorException("Failed to encode transaction") from e
|
||||||
|
|
||||||
assert msg.transaction is not None
|
assert msg.transaction is not None
|
||||||
msg.transaction.address_n = n
|
msg.transaction.address_n = n
|
||||||
|
@ -18,8 +18,8 @@ import base64
|
|||||||
import struct
|
import struct
|
||||||
import xdrlib
|
import xdrlib
|
||||||
|
|
||||||
from . import messages
|
from . import exceptions, messages
|
||||||
from .tools import CallException, expect
|
from .tools import expect
|
||||||
|
|
||||||
# Memo types
|
# Memo types
|
||||||
MEMO_TYPE_NONE = 0
|
MEMO_TYPE_NONE = 0
|
||||||
@ -368,18 +368,18 @@ def sign_tx(
|
|||||||
resp = client.call(operations.pop(0))
|
resp = client.call(operations.pop(0))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# pop from empty list
|
# pop from empty list
|
||||||
raise CallException(
|
raise exceptions.TrezorException(
|
||||||
"Stellar.UnexpectedEndOfOperations",
|
"Reached end of operations without a signature."
|
||||||
"Reached end of operations without a signature.",
|
|
||||||
) from None
|
) from None
|
||||||
|
|
||||||
if not isinstance(resp, messages.StellarSignedTx):
|
if not isinstance(resp, messages.StellarSignedTx):
|
||||||
raise CallException(messages.FailureType.UnexpectedMessage, resp)
|
raise exceptions.TrezorException(
|
||||||
|
"Unexpected message: {}".format(resp.__class__.__name__)
|
||||||
|
)
|
||||||
|
|
||||||
if operations:
|
if operations:
|
||||||
raise CallException(
|
raise exceptions.TrezorException(
|
||||||
"Stellar.UnprocessedOperations",
|
"Received a signature before processing all operations."
|
||||||
"Received a signature before processing all operations.",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
@ -23,8 +23,6 @@ from typing import List, NewType
|
|||||||
|
|
||||||
from .exceptions import TrezorFailure
|
from .exceptions import TrezorFailure
|
||||||
|
|
||||||
CallException = TrezorFailure
|
|
||||||
|
|
||||||
HARDENED_FLAG = 1 << 31
|
HARDENED_FLAG = 1 << 31
|
||||||
|
|
||||||
Address = NewType("Address", List[int])
|
Address = NewType("Address", List[int])
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import H_, CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import H_, parse_path
|
||||||
|
|
||||||
from .. import bip32
|
from .. import bip32
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
@ -163,7 +164,7 @@ class TestMsgGetaddress:
|
|||||||
node = btc.get_public_node(client, parse_path("44'/0'/%d'" % n))
|
node = btc.get_public_node(client, parse_path("44'/0'/%d'" % n))
|
||||||
xpubs.append(node.xpub)
|
xpubs.append(node.xpub)
|
||||||
for nr in range(1, 4):
|
for nr in range(1, 4):
|
||||||
with pytest.raises(CallException):
|
with pytest.raises(TrezorFailure):
|
||||||
btc.get_address(
|
btc.get_address(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -171,7 +172,7 @@ class TestMsgGetaddress:
|
|||||||
show_display=(nr == 1),
|
show_display=(nr == 1),
|
||||||
multisig=getmultisig(0, 0, xpubs=xpubs),
|
multisig=getmultisig(0, 0, xpubs=xpubs),
|
||||||
)
|
)
|
||||||
with pytest.raises(CallException):
|
with pytest.raises(TrezorFailure):
|
||||||
btc.get_address(
|
btc.get_address(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc
|
from trezorlib import btc
|
||||||
from trezorlib.tools import H_, CallException
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import H_
|
||||||
|
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
|
|
||||||
@ -80,5 +81,5 @@ class TestMsgGetpublickeyCurve:
|
|||||||
== "00514f73a05184458611b14c348fee4fd988d36cf3aee7207737861bac611de991"
|
== "00514f73a05184458611b14c348fee4fd988d36cf3aee7207737861bac611de991"
|
||||||
)
|
)
|
||||||
# test failure when using public derivation
|
# test failure when using public derivation
|
||||||
with pytest.raises(CallException):
|
with pytest.raises(TrezorFailure):
|
||||||
btc.get_public_node(client, [H_(111), 42], ecdsa_curve_name="ed25519")
|
btc.get_public_node(client, [H_(111), 42], ecdsa_curve_name="ed25519")
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import messages, ripple
|
from trezorlib import messages, ripple
|
||||||
from trezorlib.tools import CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.altcoin
|
@pytest.mark.altcoin
|
||||||
@ -105,7 +106,7 @@ class TestMsgRippleSignTx:
|
|||||||
"Sequence": 1,
|
"Sequence": 1,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
ripple.sign_tx(client, parse_path("m/44'/144'/0'/0/2"), msg)
|
ripple.sign_tx(client, parse_path("m/44'/144'/0'/0/2"), msg)
|
||||||
assert exc.value.args[0] == messages.FailureType.ProcessError
|
assert exc.value.args[0] == messages.FailureType.ProcessError
|
||||||
assert exc.value.args[1].endswith(
|
assert exc.value.args[1].endswith(
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import H_, CallException, btc_hash, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import H_, btc_hash, parse_path
|
||||||
|
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
from ..tx_cache import TxCache
|
from ..tx_cache import TxCache
|
||||||
@ -490,7 +491,7 @@ class TestMsgSigntx:
|
|||||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
check_sign_tx(
|
check_sign_tx(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -605,7 +606,7 @@ class TestMsgSigntx:
|
|||||||
# Set up attack processors
|
# Set up attack processors
|
||||||
client.set_filter(proto.TxAck, attack_processor)
|
client.set_filter(proto.TxAck, attack_processor)
|
||||||
|
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(
|
btc.sign_tx(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -661,7 +662,7 @@ class TestMsgSigntx:
|
|||||||
# Set up attack processors
|
# Set up attack processors
|
||||||
client.set_filter(proto.TxAck, attack_processor)
|
client.set_filter(proto.TxAck, attack_processor)
|
||||||
|
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(
|
btc.sign_tx(
|
||||||
client, "Testnet", [inp1], [out1, out2], prev_txes=TxCache("Testnet")
|
client, "Testnet", [inp1], [out1, out2], prev_txes=TxCache("Testnet")
|
||||||
)
|
)
|
||||||
@ -762,7 +763,7 @@ class TestMsgSigntx:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
# Now run the attack, must trigger the exception
|
# Now run the attack, must trigger the exception
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(
|
btc.sign_tx(
|
||||||
client,
|
client,
|
||||||
"Testnet",
|
"Testnet",
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import H_, CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import H_, parse_path
|
||||||
|
|
||||||
from ..tx_cache import TxCache
|
from ..tx_cache import TxCache
|
||||||
|
|
||||||
@ -329,7 +330,7 @@ class TestMsgSigntxBch:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(client, "Bcash", [inp1, inp2], [out1], prev_txes=TX_API)
|
btc.sign_tx(client, "Bcash", [inp1, inp2], [out1], prev_txes=TX_API)
|
||||||
|
|
||||||
assert exc.value.args[0] in (
|
assert exc.value.args[0] in (
|
||||||
@ -398,7 +399,7 @@ class TestMsgSigntxBch:
|
|||||||
proto.Failure(code=proto.FailureType.ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
with pytest.raises(CallException):
|
with pytest.raises(TrezorFailure):
|
||||||
btc.sign_tx(client, "Bcash", [inp1], [out1, out2], prev_txes=TX_API)
|
btc.sign_tx(client, "Bcash", [inp1], [out1, out2], prev_txes=TX_API)
|
||||||
|
|
||||||
@pytest.mark.multisig
|
@pytest.mark.multisig
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import H_, CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import H_, parse_path
|
||||||
|
|
||||||
from ..tx_cache import TxCache
|
from ..tx_cache import TxCache
|
||||||
|
|
||||||
@ -213,7 +214,7 @@ class TestMsgSigntxBitcoinGold:
|
|||||||
proto.Failure(code=proto.FailureType.ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
with pytest.raises(CallException):
|
with pytest.raises(TrezorFailure):
|
||||||
btc.sign_tx(client, "Bgold", [inp1], [out1, out2], prev_txes=TX_API)
|
btc.sign_tx(client, "Bgold", [inp1], [out1, out2], prev_txes=TX_API)
|
||||||
|
|
||||||
@pytest.mark.multisig
|
@pytest.mark.multisig
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import H_, CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import H_, parse_path
|
||||||
|
|
||||||
from ..tx_cache import TxCache
|
from ..tx_cache import TxCache
|
||||||
|
|
||||||
@ -412,7 +413,7 @@ class TestMsgSigntxSegwit:
|
|||||||
proto.Failure(code=proto.FailureType.ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(client, "Testnet", [inp1], [out1, out2], prev_txes=TX_API)
|
btc.sign_tx(client, "Testnet", [inp1], [out1, out2], prev_txes=TX_API)
|
||||||
assert exc.value.args[0] == proto.FailureType.ProcessError
|
assert exc.value.args[0] == proto.FailureType.ProcessError
|
||||||
if client.features.model == "1":
|
if client.features.model == "1":
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import messages as proto, stellar
|
from trezorlib import messages as proto, stellar
|
||||||
from trezorlib.tools import CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ class TestMsgStellarGetAddress:
|
|||||||
assert address == "GBAW5XGWORWVFE2XTJYDTLDHXTY2Q2MO73HYCGB3XMFMQ562Q2W2GJQX"
|
assert address == "GBAW5XGWORWVFE2XTJYDTLDHXTY2Q2MO73HYCGB3XMFMQ562Q2W2GJQX"
|
||||||
|
|
||||||
def test_stellar_get_address_fail(self, client):
|
def test_stellar_get_address_fail(self, client):
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
stellar.get_address(client, parse_path("m/0/1"))
|
stellar.get_address(client, parse_path("m/0/1"))
|
||||||
|
|
||||||
if client.features.model == "1":
|
if client.features.model == "1":
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
from .. import bip32
|
from .. import bip32
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
@ -297,7 +298,7 @@ class TestMultisig:
|
|||||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
|
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
|
||||||
|
|
||||||
assert exc.value.args[0] == proto.FailureType.DataError
|
assert exc.value.args[0] == proto.FailureType.DataError
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, messages as proto
|
from trezorlib import btc, messages as proto
|
||||||
from trezorlib.tools import CallException, parse_path
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
from ..tx_cache import TxCache
|
from ..tx_cache import TxCache
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ class TestOpReturn:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(CallException) as exc:
|
with pytest.raises(TrezorFailure) as exc:
|
||||||
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
|
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
|
||||||
|
|
||||||
if client.features.model == "1":
|
if client.features.model == "1":
|
||||||
|
Loading…
Reference in New Issue
Block a user