mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-27 15:51:02 +00:00
chore(tests): renaming all "proto" usages to "messages" in device tests
This commit is contained in:
parent
a92d29ddbf
commit
18a2642d95
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import messages as proto, nem
|
||||
from trezorlib import messages, nem
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ...common import MNEMONIC12
|
||||
@ -34,12 +34,12 @@ def test_nem_signtx_simple(client):
|
||||
client.set_expected_responses(
|
||||
[
|
||||
# Confirm transfer and network fee
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
|
||||
# Unencrypted message
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
|
||||
# Confirm recipient
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||
proto.NEMSignedTx,
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
messages.NEMSignedTx,
|
||||
]
|
||||
)
|
||||
|
||||
@ -77,12 +77,12 @@ def test_nem_signtx_encrypted_payload(client):
|
||||
client.set_expected_responses(
|
||||
[
|
||||
# Confirm transfer and network fee
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
|
||||
# Ask for encryption
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
|
||||
# Confirm recipient
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||
proto.NEMSignedTx,
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
messages.NEMSignedTx,
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import device, messages as proto
|
||||
from trezorlib import device, messages
|
||||
|
||||
from ...common import MNEMONIC12
|
||||
|
||||
@ -30,7 +30,7 @@ pytestmark = [pytest.mark.skip_t2]
|
||||
def test_pin_passphrase(client):
|
||||
mnemonic = MNEMONIC12.split(" ")
|
||||
ret = client.call_raw(
|
||||
proto.RecoveryDevice(
|
||||
messages.RecoveryDevice(
|
||||
word_count=12,
|
||||
passphrase_protection=True,
|
||||
pin_protection=True,
|
||||
@ -41,35 +41,35 @@ def test_pin_passphrase(client):
|
||||
)
|
||||
|
||||
# click through confirmation
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = client.debug.encode_pin(PIN6)
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time
|
||||
pin_encoded = client.debug.encode_pin(PIN6)
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
fakes = 0
|
||||
for _ in range(int(12 * 2)):
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, messages.WordRequest)
|
||||
(word, pos) = client.debug.read_recovery_word()
|
||||
|
||||
if pos != 0:
|
||||
ret = client.call_raw(proto.WordAck(word=mnemonic[pos - 1]))
|
||||
ret = client.call_raw(messages.WordAck(word=mnemonic[pos - 1]))
|
||||
mnemonic[pos - 1] = None
|
||||
else:
|
||||
ret = client.call_raw(proto.WordAck(word=word))
|
||||
ret = client.call_raw(messages.WordAck(word=word))
|
||||
fakes += 1
|
||||
|
||||
# Workflow succesfully ended
|
||||
assert isinstance(ret, proto.Success)
|
||||
assert isinstance(ret, messages.Success)
|
||||
|
||||
# 12 expected fake words and all words of mnemonic are used
|
||||
assert fakes == 12
|
||||
@ -83,16 +83,16 @@ def test_pin_passphrase(client):
|
||||
assert client.features.passphrase_protection is True
|
||||
|
||||
# Do passphrase-protected action, PassphraseRequest should be raised
|
||||
resp = client.call_raw(proto.GetAddress())
|
||||
assert isinstance(resp, proto.PassphraseRequest)
|
||||
client.call_raw(proto.Cancel())
|
||||
resp = client.call_raw(messages.GetAddress())
|
||||
assert isinstance(resp, messages.PassphraseRequest)
|
||||
client.call_raw(messages.Cancel())
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_nopin_nopassphrase(client):
|
||||
mnemonic = MNEMONIC12.split(" ")
|
||||
ret = client.call_raw(
|
||||
proto.RecoveryDevice(
|
||||
messages.RecoveryDevice(
|
||||
word_count=12,
|
||||
passphrase_protection=False,
|
||||
pin_protection=False,
|
||||
@ -103,24 +103,24 @@ def test_nopin_nopassphrase(client):
|
||||
)
|
||||
|
||||
# click through confirmation
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
fakes = 0
|
||||
for _ in range(int(12 * 2)):
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, messages.WordRequest)
|
||||
(word, pos) = client.debug.read_recovery_word()
|
||||
|
||||
if pos != 0:
|
||||
ret = client.call_raw(proto.WordAck(word=mnemonic[pos - 1]))
|
||||
ret = client.call_raw(messages.WordAck(word=mnemonic[pos - 1]))
|
||||
mnemonic[pos - 1] = None
|
||||
else:
|
||||
ret = client.call_raw(proto.WordAck(word=word))
|
||||
ret = client.call_raw(messages.WordAck(word=word))
|
||||
fakes += 1
|
||||
|
||||
# Workflow succesfully ended
|
||||
assert isinstance(ret, proto.Success)
|
||||
assert isinstance(ret, messages.Success)
|
||||
|
||||
# 12 expected fake words and all words of mnemonic are used
|
||||
assert fakes == 12
|
||||
@ -134,14 +134,14 @@ def test_nopin_nopassphrase(client):
|
||||
assert client.features.passphrase_protection is False
|
||||
|
||||
# Do pin & passphrase-protected action, PassphraseRequest should NOT be raised
|
||||
resp = client.call_raw(proto.GetAddress())
|
||||
assert isinstance(resp, proto.Address)
|
||||
resp = client.call_raw(messages.GetAddress())
|
||||
assert isinstance(resp, messages.Address)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_word_fail(client):
|
||||
ret = client.call_raw(
|
||||
proto.RecoveryDevice(
|
||||
messages.RecoveryDevice(
|
||||
word_count=12,
|
||||
passphrase_protection=False,
|
||||
pin_protection=False,
|
||||
@ -152,25 +152,25 @@ def test_word_fail(client):
|
||||
)
|
||||
|
||||
# click through confirmation
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, messages.WordRequest)
|
||||
for _ in range(int(12 * 2)):
|
||||
(word, pos) = client.debug.read_recovery_word()
|
||||
if pos != 0:
|
||||
ret = client.call_raw(proto.WordAck(word="kwyjibo"))
|
||||
assert isinstance(ret, proto.Failure)
|
||||
ret = client.call_raw(messages.WordAck(word="kwyjibo"))
|
||||
assert isinstance(ret, messages.Failure)
|
||||
break
|
||||
else:
|
||||
client.call_raw(proto.WordAck(word=word))
|
||||
client.call_raw(messages.WordAck(word=word))
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_pin_fail(client):
|
||||
ret = client.call_raw(
|
||||
proto.RecoveryDevice(
|
||||
messages.RecoveryDevice(
|
||||
word_count=12,
|
||||
passphrase_protection=True,
|
||||
pin_protection=True,
|
||||
@ -181,23 +181,23 @@ def test_pin_fail(client):
|
||||
)
|
||||
|
||||
# click through confirmation
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = client.debug.encode_pin(PIN4)
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time, but different one
|
||||
pin_encoded = client.debug.encode_pin(PIN6)
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Failure should be raised
|
||||
assert isinstance(ret, proto.Failure)
|
||||
assert isinstance(ret, messages.Failure)
|
||||
|
||||
|
||||
def test_already_initialized(client):
|
||||
@ -207,9 +207,9 @@ def test_already_initialized(client):
|
||||
)
|
||||
|
||||
ret = client.call_raw(
|
||||
proto.RecoveryDevice(
|
||||
word_count=12, type=proto.RecoveryDeviceType.ScrambledWords
|
||||
messages.RecoveryDevice(
|
||||
word_count=12, type=messages.RecoveryDeviceType.ScrambledWords
|
||||
)
|
||||
)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
assert isinstance(ret, messages.Failure)
|
||||
assert "Device is already initialized" in ret.message
|
||||
|
@ -17,7 +17,7 @@
|
||||
import pytest
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
from trezorlib import device, messages as proto
|
||||
from trezorlib import device, messages
|
||||
|
||||
from ...common import generate_entropy
|
||||
|
||||
@ -29,7 +29,7 @@ def reset_device(client, strength):
|
||||
external_entropy = b"zlutoucky kun upel divoke ody" * 2
|
||||
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
messages.ResetDevice(
|
||||
display_random=False,
|
||||
strength=strength,
|
||||
passphrase_protection=False,
|
||||
@ -39,14 +39,14 @@ def reset_device(client, strength):
|
||||
)
|
||||
)
|
||||
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Provide entropy
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, messages.EntropyRequest)
|
||||
internal_entropy = client.debug.state().reset_entropy
|
||||
ret = client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
ret = client.call_raw(messages.EntropyAck(entropy=external_entropy))
|
||||
|
||||
# Generate mnemonic locally
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
@ -54,10 +54,10 @@ def reset_device(client, strength):
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
mnemonic.append(client.debug.read_reset_word())
|
||||
client.debug.press_yes()
|
||||
client.call_raw(proto.ButtonAck())
|
||||
client.call_raw(messages.ButtonAck())
|
||||
|
||||
mnemonic = " ".join(mnemonic)
|
||||
|
||||
@ -66,12 +66,12 @@ def reset_device(client, strength):
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
mnemonic.append(client.debug.read_reset_word())
|
||||
client.debug.press_yes()
|
||||
resp = client.call_raw(proto.ButtonAck())
|
||||
resp = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(resp, proto.Success)
|
||||
assert isinstance(resp, messages.Success)
|
||||
|
||||
mnemonic = " ".join(mnemonic)
|
||||
|
||||
@ -79,15 +79,15 @@ def reset_device(client, strength):
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = client.call_raw(proto.Initialize())
|
||||
resp = client.call_raw(messages.Initialize())
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is False
|
||||
assert resp.passphrase_protection is False
|
||||
|
||||
# Do pin & passphrase-protected action, PassphraseRequest should NOT be raised
|
||||
resp = client.call_raw(proto.GetAddress())
|
||||
assert isinstance(resp, proto.Address)
|
||||
resp = client.call_raw(messages.GetAddress())
|
||||
assert isinstance(resp, messages.Address)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
@ -106,7 +106,7 @@ def test_reset_device_256_pin(client):
|
||||
strength = 256
|
||||
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
messages.ResetDevice(
|
||||
display_random=True,
|
||||
strength=strength,
|
||||
passphrase_protection=True,
|
||||
@ -117,35 +117,35 @@ def test_reset_device_256_pin(client):
|
||||
)
|
||||
|
||||
# Do you want ... ?
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Entropy screen #1
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Entropy screen #2
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = client.debug.encode_pin("654")
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time
|
||||
pin_encoded = client.debug.encode_pin("654")
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Provide entropy
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, messages.EntropyRequest)
|
||||
internal_entropy = client.debug.state().reset_entropy
|
||||
ret = client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
ret = client.call_raw(messages.EntropyAck(entropy=external_entropy))
|
||||
|
||||
# Generate mnemonic locally
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
@ -153,10 +153,10 @@ def test_reset_device_256_pin(client):
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
mnemonic.append(client.debug.read_reset_word())
|
||||
client.debug.press_yes()
|
||||
client.call_raw(proto.ButtonAck())
|
||||
client.call_raw(messages.ButtonAck())
|
||||
|
||||
mnemonic = " ".join(mnemonic)
|
||||
|
||||
@ -165,12 +165,12 @@ def test_reset_device_256_pin(client):
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
mnemonic.append(client.debug.read_reset_word())
|
||||
client.debug.press_yes()
|
||||
resp = client.call_raw(proto.ButtonAck())
|
||||
resp = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(resp, proto.Success)
|
||||
assert isinstance(resp, messages.Success)
|
||||
|
||||
mnemonic = " ".join(mnemonic)
|
||||
|
||||
@ -178,16 +178,16 @@ def test_reset_device_256_pin(client):
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = client.call_raw(proto.Initialize())
|
||||
resp = client.call_raw(messages.Initialize())
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is True
|
||||
assert resp.passphrase_protection is True
|
||||
|
||||
# Do passphrase-protected action, PassphraseRequest should be raised
|
||||
resp = client.call_raw(proto.GetAddress())
|
||||
assert isinstance(resp, proto.PassphraseRequest)
|
||||
client.call_raw(proto.Cancel())
|
||||
resp = client.call_raw(messages.GetAddress())
|
||||
assert isinstance(resp, messages.PassphraseRequest)
|
||||
client.call_raw(messages.Cancel())
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
@ -196,7 +196,7 @@ def test_failed_pin(client):
|
||||
strength = 128
|
||||
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
messages.ResetDevice(
|
||||
display_random=True,
|
||||
strength=strength,
|
||||
passphrase_protection=True,
|
||||
@ -207,32 +207,32 @@ def test_failed_pin(client):
|
||||
)
|
||||
|
||||
# Do you want ... ?
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Entropy screen #1
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Entropy screen #2
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = client.debug.encode_pin("1234")
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
assert isinstance(ret, messages.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time
|
||||
pin_encoded = client.debug.encode_pin("6789")
|
||||
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
ret = client.call_raw(messages.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
assert isinstance(ret, proto.Failure)
|
||||
assert isinstance(ret, messages.Failure)
|
||||
|
||||
|
||||
def test_already_initialized(client):
|
||||
|
@ -17,7 +17,7 @@
|
||||
import pytest
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib import messages
|
||||
|
||||
from ...common import generate_entropy
|
||||
|
||||
@ -30,7 +30,7 @@ STRENGTH = 128
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_skip_backup(client):
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
messages.ResetDevice(
|
||||
display_random=False,
|
||||
strength=STRENGTH,
|
||||
passphrase_protection=False,
|
||||
@ -41,18 +41,18 @@ def test_reset_device_skip_backup(client):
|
||||
)
|
||||
)
|
||||
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Provide entropy
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, messages.EntropyRequest)
|
||||
internal_entropy = client.debug.state().reset_entropy
|
||||
ret = client.call_raw(proto.EntropyAck(entropy=EXTERNAL_ENTROPY))
|
||||
assert isinstance(ret, proto.Success)
|
||||
ret = client.call_raw(messages.EntropyAck(entropy=EXTERNAL_ENTROPY))
|
||||
assert isinstance(ret, messages.Success)
|
||||
|
||||
# Check if device is properly initialized
|
||||
ret = client.call_raw(proto.Initialize())
|
||||
ret = client.call_raw(messages.Initialize())
|
||||
assert ret.initialized is True
|
||||
assert ret.needs_backup is True
|
||||
assert ret.unfinished_backup is False
|
||||
@ -63,14 +63,14 @@ def test_reset_device_skip_backup(client):
|
||||
expected_mnemonic = Mnemonic("english").to_mnemonic(entropy)
|
||||
|
||||
# start Backup workflow
|
||||
ret = client.call_raw(proto.BackupDevice())
|
||||
ret = client.call_raw(messages.BackupDevice())
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(STRENGTH // 32 * 3):
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
mnemonic.append(client.debug.read_reset_word())
|
||||
client.debug.press_yes()
|
||||
client.call_raw(proto.ButtonAck())
|
||||
client.call_raw(messages.ButtonAck())
|
||||
|
||||
mnemonic = " ".join(mnemonic)
|
||||
|
||||
@ -79,12 +79,12 @@ def test_reset_device_skip_backup(client):
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(STRENGTH // 32 * 3):
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
mnemonic.append(client.debug.read_reset_word())
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.Success)
|
||||
assert isinstance(ret, messages.Success)
|
||||
|
||||
mnemonic = " ".join(mnemonic)
|
||||
|
||||
@ -92,14 +92,14 @@ def test_reset_device_skip_backup(client):
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# start backup again - should fail
|
||||
ret = client.call_raw(proto.BackupDevice())
|
||||
assert isinstance(ret, proto.Failure)
|
||||
ret = client.call_raw(messages.BackupDevice())
|
||||
assert isinstance(ret, messages.Failure)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_skip_backup_break(client):
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
messages.ResetDevice(
|
||||
display_random=False,
|
||||
strength=STRENGTH,
|
||||
passphrase_protection=False,
|
||||
@ -110,40 +110,40 @@ def test_reset_device_skip_backup_break(client):
|
||||
)
|
||||
)
|
||||
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Provide entropy
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
ret = client.call_raw(proto.EntropyAck(entropy=EXTERNAL_ENTROPY))
|
||||
assert isinstance(ret, proto.Success)
|
||||
assert isinstance(ret, messages.EntropyRequest)
|
||||
ret = client.call_raw(messages.EntropyAck(entropy=EXTERNAL_ENTROPY))
|
||||
assert isinstance(ret, messages.Success)
|
||||
|
||||
# Check if device is properly initialized
|
||||
ret = client.call_raw(proto.Initialize())
|
||||
ret = client.call_raw(messages.Initialize())
|
||||
assert ret.initialized is True
|
||||
assert ret.needs_backup is True
|
||||
assert ret.unfinished_backup is False
|
||||
assert ret.no_backup is False
|
||||
|
||||
# start Backup workflow
|
||||
ret = client.call_raw(proto.BackupDevice())
|
||||
ret = client.call_raw(messages.BackupDevice())
|
||||
|
||||
# send Initialize -> break workflow
|
||||
ret = client.call_raw(proto.Initialize())
|
||||
assert isinstance(ret, proto.Features)
|
||||
ret = client.call_raw(messages.Initialize())
|
||||
assert isinstance(ret, messages.Features)
|
||||
assert ret.initialized is True
|
||||
assert ret.needs_backup is False
|
||||
assert ret.unfinished_backup is True
|
||||
assert ret.no_backup is False
|
||||
|
||||
# start backup again - should fail
|
||||
ret = client.call_raw(proto.BackupDevice())
|
||||
assert isinstance(ret, proto.Failure)
|
||||
ret = client.call_raw(messages.BackupDevice())
|
||||
assert isinstance(ret, messages.Failure)
|
||||
|
||||
# read Features again
|
||||
ret = client.call_raw(proto.Initialize())
|
||||
assert isinstance(ret, proto.Features)
|
||||
ret = client.call_raw(messages.Initialize())
|
||||
assert isinstance(ret, messages.Features)
|
||||
assert ret.initialized is True
|
||||
assert ret.needs_backup is False
|
||||
assert ret.unfinished_backup is True
|
||||
@ -151,14 +151,14 @@ def test_reset_device_skip_backup_break(client):
|
||||
|
||||
|
||||
def test_initialized_device_backup_fail(client):
|
||||
ret = client.call_raw(proto.BackupDevice())
|
||||
assert isinstance(ret, proto.Failure)
|
||||
ret = client.call_raw(messages.BackupDevice())
|
||||
assert isinstance(ret, messages.Failure)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_skip_backup_show_entropy_fail(client):
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
messages.ResetDevice(
|
||||
display_random=True,
|
||||
strength=STRENGTH,
|
||||
passphrase_protection=False,
|
||||
@ -168,4 +168,4 @@ def test_reset_device_skip_backup_show_entropy_fail(client):
|
||||
skip_backup=True,
|
||||
)
|
||||
)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
assert isinstance(ret, messages.Failure)
|
||||
|
@ -19,7 +19,7 @@ from unittest import mock
|
||||
import pytest
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
from trezorlib import device, messages as proto
|
||||
from trezorlib import device, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.messages import ButtonRequestType as B
|
||||
|
||||
@ -62,15 +62,15 @@ def reset_device(client, strength):
|
||||
with mock.patch("os.urandom", os_urandom), client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.EntropyRequest(),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.Success,
|
||||
proto.Features,
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.EntropyRequest(),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.Success,
|
||||
messages.Features,
|
||||
]
|
||||
)
|
||||
client.set_input_flow(input_flow)
|
||||
@ -95,12 +95,12 @@ def reset_device(client, strength):
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = client.call_raw(proto.Initialize())
|
||||
resp = client.call_raw(messages.Initialize())
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is False
|
||||
assert resp.passphrase_protection is False
|
||||
assert resp.backup_type is proto.BackupType.Bip39
|
||||
assert resp.backup_type is messages.BackupType.Bip39
|
||||
|
||||
# backup attempt fails because backup was done in reset
|
||||
with pytest.raises(TrezorFailure, match="ProcessError: Seed already backed up"):
|
||||
@ -170,18 +170,18 @@ def test_reset_device_pin(client):
|
||||
with mock.patch("os.urandom", os_urandom), client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.PinEntry),
|
||||
proto.ButtonRequest(code=B.PinEntry),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.EntropyRequest(),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.Success,
|
||||
proto.Features,
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.PinEntry),
|
||||
messages.ButtonRequest(code=B.PinEntry),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.EntropyRequest(),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.Success,
|
||||
messages.Features,
|
||||
]
|
||||
)
|
||||
client.set_input_flow(input_flow)
|
||||
@ -206,7 +206,7 @@ def test_reset_device_pin(client):
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = client.call_raw(proto.Initialize())
|
||||
resp = client.call_raw(messages.Initialize())
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is True
|
||||
@ -250,17 +250,17 @@ def test_reset_failed_check(client):
|
||||
with mock.patch("os.urandom", os_urandom), client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.EntropyRequest(),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.Success,
|
||||
proto.Features,
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.EntropyRequest(),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.Success,
|
||||
messages.Features,
|
||||
]
|
||||
)
|
||||
client.set_input_flow(input_flow)
|
||||
@ -285,12 +285,12 @@ def test_reset_failed_check(client):
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = client.call_raw(proto.Initialize())
|
||||
resp = client.call_raw(messages.Initialize())
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is False
|
||||
assert resp.passphrase_protection is False
|
||||
assert resp.backup_type is proto.BackupType.Bip39
|
||||
assert resp.backup_type is messages.BackupType.Bip39
|
||||
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
@ -298,25 +298,25 @@ def test_failed_pin(client):
|
||||
# external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
||||
strength = 128
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(strength=strength, pin_protection=True, label="test")
|
||||
messages.ResetDevice(strength=strength, pin_protection=True, label="test")
|
||||
)
|
||||
|
||||
# Confirm Reset
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.press_yes()
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Enter PIN for first time
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.input("654")
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Enter PIN for second time
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
client.debug.input("456")
|
||||
ret = client.call_raw(proto.ButtonAck())
|
||||
ret = client.call_raw(messages.ButtonAck())
|
||||
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
||||
|
@ -19,7 +19,7 @@ from unittest import mock
|
||||
import pytest
|
||||
from shamir_mnemonic import shamir
|
||||
|
||||
from trezorlib import device, messages as proto
|
||||
from trezorlib import device, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.messages import BackupType, ButtonRequestType as B
|
||||
|
||||
@ -72,36 +72,36 @@ def test_reset_device_slip39_advanced(client):
|
||||
with mock.patch("os.urandom", os_urandom), client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.EntropyRequest(),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice), # group #1 counts
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice), # group #2 counts
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice), # group #3 counts
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice), # group #4 counts
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice), # group #5 counts
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.EntropyRequest(),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice), # group #1 counts
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice), # group #2 counts
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice), # group #3 counts
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice), # group #4 counts
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice), # group #5 counts
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
]
|
||||
+ [
|
||||
# individual mnemonic
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
]
|
||||
* (5 * 5) # groups * shares
|
||||
+ [
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.Success,
|
||||
proto.Features,
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.Success,
|
||||
messages.Features,
|
||||
]
|
||||
)
|
||||
client.set_input_flow(input_flow)
|
||||
|
@ -20,7 +20,7 @@ from unittest import mock
|
||||
import pytest
|
||||
from shamir_mnemonic import MnemonicError, shamir
|
||||
|
||||
from trezorlib import device, messages as proto
|
||||
from trezorlib import device, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.messages import BackupType, ButtonRequestType as B
|
||||
|
||||
@ -69,26 +69,26 @@ def reset_device(client, strength):
|
||||
with mock.patch("os.urandom", os_urandom), client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.EntropyRequest(),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.EntropyRequest(),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
]
|
||||
+ [
|
||||
# individual mnemonic
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
]
|
||||
* 5 # number of shares
|
||||
+ [
|
||||
proto.ButtonRequest(code=B.Success),
|
||||
proto.Success,
|
||||
proto.Features,
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.Success,
|
||||
messages.Features,
|
||||
]
|
||||
)
|
||||
client.set_input_flow(input_flow)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
@ -29,7 +29,7 @@ def test_show_segwit(client):
|
||||
parse_path("49'/1'/0'/1/0"),
|
||||
True,
|
||||
None,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
== "2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX"
|
||||
)
|
||||
@ -40,7 +40,7 @@ def test_show_segwit(client):
|
||||
parse_path("49'/1'/0'/0/0"),
|
||||
False,
|
||||
None,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
== "2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp"
|
||||
)
|
||||
@ -51,7 +51,7 @@ def test_show_segwit(client):
|
||||
parse_path("44'/1'/0'/0/0"),
|
||||
False,
|
||||
None,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
== "2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc"
|
||||
)
|
||||
@ -62,7 +62,7 @@ def test_show_segwit(client):
|
||||
parse_path("44'/1'/0'/0/0"),
|
||||
False,
|
||||
None,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
== "mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q"
|
||||
)
|
||||
@ -77,7 +77,7 @@ def test_show_segwit_altcoin(client):
|
||||
parse_path("49'/1'/0'/0/0"),
|
||||
False,
|
||||
None,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
== "2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e"
|
||||
)
|
||||
@ -88,7 +88,7 @@ def test_show_segwit_altcoin(client):
|
||||
parse_path("m/49'/1'/0'/0/0"),
|
||||
False,
|
||||
None,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
== "XNW67ZQA9K3AuXPBWvJH4zN2y5QBDTwy2Z"
|
||||
)
|
||||
@ -103,11 +103,11 @@ def test_show_multisig_3(client):
|
||||
for i in range(1, 4)
|
||||
]
|
||||
|
||||
multisig1 = proto.MultisigRedeemScriptType(
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 7], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
# multisig2 = proto.MultisigRedeemScriptType(
|
||||
# pubkeys=map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
|
||||
# multisig2 = messages.MultisigRedeemScriptType(
|
||||
# pubkeys=map(lambda n: messages.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
|
||||
# signatures=[b'', b'', b''],
|
||||
# m=2,
|
||||
# )
|
||||
@ -119,7 +119,7 @@ def test_show_multisig_3(client):
|
||||
parse_path(f"49'/1'/{i}'/0/7"),
|
||||
False,
|
||||
multisig1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
== "2MwuUwUzPG17wiKQpfXmzfxJEoe7RXZDRad"
|
||||
)
|
||||
@ -135,7 +135,7 @@ def test_multisig_missing(client, show_display):
|
||||
btc.get_public_node(client, parse_path(f"49'/0'/{i}'")).node
|
||||
for i in range(1, 4)
|
||||
]
|
||||
multisig1 = proto.MultisigRedeemScriptType(
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
@ -143,11 +143,11 @@ def test_multisig_missing(client, show_display):
|
||||
node = btc.get_public_node(
|
||||
client, parse_path("49h/0h/0h/0"), coin_name="Bitcoin"
|
||||
).node
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node, address_n=[1]),
|
||||
proto.HDNodePathType(node=node, address_n=[2]),
|
||||
proto.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
@ -161,5 +161,5 @@ def test_multisig_missing(client, show_display):
|
||||
parse_path("49'/0'/0'/0/0"),
|
||||
show_display=show_display,
|
||||
multisig=multisig,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
@ -24,25 +24,25 @@ VECTORS = ( # coin, path, script_type, address
|
||||
(
|
||||
"Testnet",
|
||||
"84'/1'/0'/0/0",
|
||||
proto.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
"tb1qkvwu9g3k2pdxewfqr7syz89r3gj557l3uuf9r9",
|
||||
),
|
||||
(
|
||||
"Testnet",
|
||||
"84'/1'/0'/1/0",
|
||||
proto.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
"tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x",
|
||||
),
|
||||
(
|
||||
"Bitcoin",
|
||||
"84'/0'/0'/0/0",
|
||||
proto.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
"bc1qannfxke2tfd4l7vhepehpvt05y83v3qsf6nfkk",
|
||||
),
|
||||
(
|
||||
"Bitcoin",
|
||||
"84'/0'/0'/1/0",
|
||||
proto.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
"bc1qktmhrsmsenepnnfst8x6j27l0uqv7ggrg8x38q",
|
||||
),
|
||||
(
|
||||
@ -72,14 +72,14 @@ VECTORS = ( # coin, path, script_type, address
|
||||
pytest.param(
|
||||
"Groestlcoin",
|
||||
"84'/17'/0'/0/0",
|
||||
proto.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
"grs1qw4teyraux2s77nhjdwh9ar8rl9dt7zww8r6lne",
|
||||
marks=pytest.mark.altcoin,
|
||||
),
|
||||
pytest.param(
|
||||
"Elements",
|
||||
"84'/1'/0'/0/0",
|
||||
proto.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
"ert1qkvwu9g3k2pdxewfqr7syz89r3gj557l3xp9k2v",
|
||||
marks=pytest.mark.altcoin,
|
||||
),
|
||||
@ -136,10 +136,10 @@ def test_show_multisig_3(client):
|
||||
).node
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig1 = proto.MultisigRedeemScriptType(
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 1], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
for i in [1, 2, 3]:
|
||||
@ -150,7 +150,7 @@ def test_show_multisig_3(client):
|
||||
parse_path(f"84'/1'/{i}'/0/1"),
|
||||
False,
|
||||
multisig2,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
== "tb1qauuv4e2pwjkr4ws5f8p20hu562jlqpe5h74whxqrwf7pufsgzcms9y8set"
|
||||
)
|
||||
@ -161,7 +161,7 @@ def test_show_multisig_3(client):
|
||||
parse_path(f"84'/1'/{i}'/0/0"),
|
||||
False,
|
||||
multisig1,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
== "tb1qgvn67p4twmpqhs8c39tukmu9geamtf7x0z3flwf9rrw4ff3h6d2qt0czq3"
|
||||
)
|
||||
@ -177,7 +177,7 @@ def test_multisig_missing(client, show_display):
|
||||
btc.get_public_node(client, parse_path(f"84'/0'/{i}'")).node
|
||||
for i in range(1, 4)
|
||||
]
|
||||
multisig1 = proto.MultisigRedeemScriptType(
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
@ -185,11 +185,11 @@ def test_multisig_missing(client, show_display):
|
||||
node = btc.get_public_node(
|
||||
client, parse_path("84h/0h/0h/0"), coin_name="Bitcoin"
|
||||
).node
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node, address_n=[1]),
|
||||
proto.HDNodePathType(node=node, address_n=[2]),
|
||||
proto.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
@ -203,5 +203,5 @@ def test_multisig_missing(client, show_display):
|
||||
parse_path("84'/0'/0'/0/0"),
|
||||
show_display=show_display,
|
||||
multisig=multisig,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import messages as proto, misc
|
||||
from trezorlib import messages, misc
|
||||
|
||||
from ..common import MNEMONIC12
|
||||
|
||||
|
||||
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
||||
def test_ecdh(client):
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="gpg",
|
||||
user="",
|
||||
host="Satoshi Nakamoto <satoshi@bitcoin.org>",
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import messages as proto, misc
|
||||
from trezorlib import messages, misc
|
||||
|
||||
from ..common import MNEMONIC12
|
||||
|
||||
@ -31,7 +31,7 @@ def test_sign(client):
|
||||
# URI : https://satoshi@bitcoin.org/login
|
||||
# hash : d0e2389d4c8394a9f3e32de01104bf6e8db2d9e2bb0905d60fffa5a18fd696db
|
||||
# path : m/2147483661/2637750992/2845082444/3761103859/4005495825
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="https",
|
||||
user="satoshi",
|
||||
host="bitcoin.org",
|
||||
@ -53,7 +53,7 @@ def test_sign(client):
|
||||
# URI : ftp://satoshi@bitcoin.org:2323/pub
|
||||
# hash : 79a6b53831c6ff224fb283587adc4ebae8fb0d734734a46c876838f52dff53f3
|
||||
# path : m/2147483661/3098912377/2734671409/3632509519/3125730426
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="ftp",
|
||||
user="satoshi",
|
||||
host="bitcoin.org",
|
||||
@ -75,7 +75,7 @@ def test_sign(client):
|
||||
# URI : ssh://satoshi@bitcoin.org
|
||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="ssh", user="satoshi", host="bitcoin.org", port="", path="", index=47
|
||||
)
|
||||
sig = misc.sign_identity(
|
||||
@ -94,7 +94,7 @@ def test_sign(client):
|
||||
# URI : ssh://satoshi@bitcoin.org
|
||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="ssh", user="satoshi", host="bitcoin.org", port="", path="", index=47
|
||||
)
|
||||
sig = misc.sign_identity(
|
||||
@ -111,7 +111,7 @@ def test_sign(client):
|
||||
)
|
||||
|
||||
# URI : gpg://satoshi@bitcoin.org
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="gpg", user="satoshi", host="bitcoin.org", port="", path=""
|
||||
)
|
||||
sig = misc.sign_identity(
|
||||
@ -128,7 +128,7 @@ def test_sign(client):
|
||||
)
|
||||
|
||||
# URI : signify://satoshi@bitcoin.org
|
||||
identity = proto.IdentityType(
|
||||
identity = messages.IdentityType(
|
||||
proto="signify", user="satoshi", host="bitcoin.org", port="", path=""
|
||||
)
|
||||
sig = misc.sign_identity(
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import H_, parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Bcash")
|
||||
|
||||
TXHASH_bc37c2 = bytes.fromhex(
|
||||
@ -43,23 +43,23 @@ pytestmark = pytest.mark.altcoin
|
||||
|
||||
|
||||
def test_send_bch_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/0'/0/0"),
|
||||
# bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv
|
||||
amount=1995344,
|
||||
prev_hash=TXHASH_bc37c2,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/145'/0'/1/0"),
|
||||
amount=1896050,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4",
|
||||
amount=73452,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -67,8 +67,8 @@ def test_send_bch_change(client):
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_bc37c2),
|
||||
request_input(0, TXHASH_bc37c2),
|
||||
@ -90,26 +90,26 @@ def test_send_bch_change(client):
|
||||
|
||||
|
||||
def test_send_bch_nochange(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/0'/1/0"),
|
||||
# bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw
|
||||
amount=1896050,
|
||||
prev_hash=TXHASH_502e85,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/0'/0/1"),
|
||||
# bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4
|
||||
amount=73452,
|
||||
prev_hash=TXHASH_502e85,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="bitcoincash:qq6wnnkrz7ykaqvxrx4hmjvayvzjzml54uyk76arx4",
|
||||
amount=1934960,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -117,8 +117,8 @@ def test_send_bch_nochange(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_502e85),
|
||||
request_input(0, TXHASH_502e85),
|
||||
@ -146,26 +146,26 @@ def test_send_bch_nochange(client):
|
||||
|
||||
|
||||
def test_send_bch_oldaddr(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/0'/1/0"),
|
||||
# bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw
|
||||
amount=1896050,
|
||||
prev_hash=TXHASH_502e85,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/0'/0/1"),
|
||||
# bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4
|
||||
amount=73452,
|
||||
prev_hash=TXHASH_502e85,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz",
|
||||
amount=1934960,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -173,8 +173,8 @@ def test_send_bch_oldaddr(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_502e85),
|
||||
request_input(0, TXHASH_502e85),
|
||||
@ -202,22 +202,22 @@ def test_send_bch_oldaddr(client):
|
||||
|
||||
|
||||
def test_attack_change_input(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/10'/0/0"),
|
||||
amount=1995344,
|
||||
prev_hash=TXHASH_bc37c2,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/145'/10'/1/0"),
|
||||
amount=1896050,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4",
|
||||
amount=73452,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
attack_count = 2
|
||||
@ -234,20 +234,20 @@ def test_attack_change_input(client):
|
||||
return msg
|
||||
|
||||
with client:
|
||||
client.set_filter(proto.TxAck, attack_processor)
|
||||
client.set_filter(messages.TxAck, attack_processor)
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_bc37c2),
|
||||
request_input(0, TXHASH_bc37c2),
|
||||
request_output(0, TXHASH_bc37c2),
|
||||
request_input(0),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
messages.Failure(code=messages.FailureType.ProcessError),
|
||||
]
|
||||
)
|
||||
with pytest.raises(TrezorFailure):
|
||||
@ -264,11 +264,11 @@ def test_send_bch_multisig_wrongchange(client):
|
||||
]
|
||||
|
||||
def getmultisig(chain, nr, signatures):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
return messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[chain, nr], signatures=signatures, m=2
|
||||
)
|
||||
|
||||
correcthorse = proto.HDNodeType(
|
||||
correcthorse = messages.HDNodeType(
|
||||
depth=1,
|
||||
fingerprint=0,
|
||||
child_num=0,
|
||||
@ -282,27 +282,27 @@ def test_send_bch_multisig_wrongchange(client):
|
||||
sig = bytes.fromhex(
|
||||
"304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae"
|
||||
)
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48'/145'/1'/0'/1/0"),
|
||||
multisig=getmultisig(1, 0, [b"", sig, b""]),
|
||||
# bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a
|
||||
amount=24000,
|
||||
prev_hash=TXHASH_f68caf,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("48'/145'/1'/0'/1/1"),
|
||||
multisig=proto.MultisigRedeemScriptType(
|
||||
multisig=messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=nodes[0], address_n=[1, 1]),
|
||||
proto.HDNodePathType(node=correcthorse, address_n=[]),
|
||||
proto.HDNodePathType(node=correcthorse, address_n=[]),
|
||||
messages.HDNodePathType(node=nodes[0], address_n=[1, 1]),
|
||||
messages.HDNodePathType(node=correcthorse, address_n=[]),
|
||||
messages.HDNodePathType(node=correcthorse, address_n=[]),
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
),
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
amount=23000,
|
||||
)
|
||||
with client:
|
||||
@ -310,8 +310,8 @@ def test_send_bch_multisig_wrongchange(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_f68caf),
|
||||
request_input(0, TXHASH_f68caf),
|
||||
@ -347,27 +347,27 @@ def test_send_bch_multisig_change(client):
|
||||
EMPTY_SIGNATURES = [b"", b"", b""]
|
||||
|
||||
def getmultisig(chain, nr, signatures):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
return messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[chain, nr], signatures=signatures, m=2
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48'/145'/3'/0'/0/0"),
|
||||
multisig=getmultisig(0, 0, EMPTY_SIGNATURES),
|
||||
amount=48490,
|
||||
prev_hash=TXHASH_8b6db9,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="bitcoincash:qqq8gx2j76nw4dfefumxmdwvtf2tpsjznusgsmzex9",
|
||||
amount=24000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("48'/145'/3'/0'/1/0"),
|
||||
multisig=getmultisig(1, 0, EMPTY_SIGNATURES),
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
amount=24000,
|
||||
)
|
||||
with client:
|
||||
@ -375,9 +375,9 @@ def test_send_bch_multisig_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_8b6db9),
|
||||
request_input(0, TXHASH_8b6db9),
|
||||
@ -397,14 +397,14 @@ def test_send_bch_multisig_change(client):
|
||||
== "304402202b75dbb307d2556b9a85851d27ab118b3f06344bccb6e21b0a5dfcf74e0e644f02206611c59396d44741d34fd7bb602be06ef91690b22b47c3f3c271e15e20176ac0"
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48'/145'/1'/0'/0/0"),
|
||||
multisig=getmultisig(0, 0, [b"", b"", signatures1[0]]),
|
||||
# bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw
|
||||
amount=48490,
|
||||
prev_hash=TXHASH_8b6db9,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
out2.address_n[2] = H_(1)
|
||||
|
||||
@ -413,9 +413,9 @@ def test_send_bch_multisig_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_8b6db9),
|
||||
request_input(0, TXHASH_8b6db9),
|
||||
@ -442,13 +442,13 @@ def test_send_bch_multisig_change(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_send_bch_external_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# address_n=parse_path("44'/145'/0'/1/0"),
|
||||
# bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw
|
||||
amount=1896050,
|
||||
prev_hash=TXHASH_502e85,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex(
|
||||
"76a914b1401fce7e8bf123c88a0467e0ed11e3b9fbef5488ac"
|
||||
),
|
||||
@ -456,18 +456,18 @@ def test_send_bch_external_presigned(client):
|
||||
"47304402207a2a955f1cb3dc5f03f2c82934f55654882af4e852e5159639f6349e9386ec4002205fb8419dce4e648eae8f67bc4e369adfb130a87d2ea2d668f8144213b12bb457412103174c61e9c5362507e8061e28d2c0ce3d4df4e73f3535ae0b12f37809e0f92d2d"
|
||||
),
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("44'/145'/0'/0/1"),
|
||||
# bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4
|
||||
amount=73452,
|
||||
prev_hash=TXHASH_502e85,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="bitcoincash:qq6wnnkrz7ykaqvxrx4hmjvayvzjzml54uyk76arx4",
|
||||
amount=1934960,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -475,8 +475,8 @@ def test_send_bch_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_502e85),
|
||||
request_input(0, TXHASH_502e85),
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import H_, btc_hash, parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Bgold")
|
||||
|
||||
TXHASH_25526b = bytes.fromhex(
|
||||
@ -41,22 +41,22 @@ pytestmark = pytest.mark.altcoin
|
||||
|
||||
# All data taken from T1
|
||||
def test_send_bitcoin_gold_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/156'/0'/0/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/156'/0'/1/0"),
|
||||
amount=1896050,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=1252382934 - 1896050 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -64,8 +64,8 @@ def test_send_bitcoin_gold_change(client):
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -88,25 +88,25 @@ def test_send_bitcoin_gold_change(client):
|
||||
|
||||
|
||||
def test_send_bitcoin_gold_nochange(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/156'/0'/1/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("44'/156'/0'/0/1"),
|
||||
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
||||
amount=38448607,
|
||||
prev_hash=TXHASH_db77c2,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=1252382934 + 38448607 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -114,8 +114,8 @@ def test_send_bitcoin_gold_nochange(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -143,22 +143,22 @@ def test_send_bitcoin_gold_nochange(client):
|
||||
|
||||
|
||||
def test_attack_change_input(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/156'/11'/0/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/156'/11'/1/0"),
|
||||
amount=1896050,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=1252382934 - 1896050 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
attack_count = 2
|
||||
@ -175,21 +175,21 @@ def test_attack_change_input(client):
|
||||
return msg
|
||||
|
||||
with client:
|
||||
client.set_filter(proto.TxAck, attack_processor)
|
||||
client.set_filter(messages.TxAck, attack_processor)
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
request_output(0, TXHASH_25526b),
|
||||
request_output(1, TXHASH_25526b),
|
||||
request_input(0),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
messages.Failure(code=messages.FailureType.ProcessError),
|
||||
]
|
||||
)
|
||||
with pytest.raises(TrezorFailure):
|
||||
@ -208,28 +208,28 @@ def test_send_btg_multisig_change(client):
|
||||
EMPTY_SIGS = [b"", b"", b""]
|
||||
|
||||
def getmultisig(chain, nr, signatures):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
return messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[chain, nr], signatures=signatures, m=2
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48'/156'/3'/0'/0/0"),
|
||||
multisig=getmultisig(0, 0, EMPTY_SIGS),
|
||||
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=24000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("48'/156'/3'/0'/1/0"),
|
||||
multisig=getmultisig(1, 0, EMPTY_SIGS),
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
amount=1252382934 - 24000 - 1000,
|
||||
)
|
||||
with client:
|
||||
@ -237,9 +237,9 @@ def test_send_btg_multisig_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -260,13 +260,13 @@ def test_send_btg_multisig_change(client):
|
||||
== "30440220263c427e6e889c161206edee39b9b969350c154ddd8eb76d2ab8ca8e0fc083b702200fb1d0ef430fa2d0293dcbb0b237775d4f9748222a6ed9fc3ff747837b99020a"
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48'/156'/1'/0'/0/0"),
|
||||
multisig=getmultisig(0, 0, [b"", b"", signatures[0]]),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
out2.address_n[2] = H_(1)
|
||||
|
||||
@ -275,9 +275,9 @@ def test_send_btg_multisig_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -304,21 +304,21 @@ def test_send_btg_multisig_change(client):
|
||||
|
||||
|
||||
def test_send_p2sh(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/156'/0'/1/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="GZFLExxrvWFuFT1xRzhfwQWSE2bPDedBfn",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=1252382934 - 11000 - 12300000,
|
||||
)
|
||||
with client:
|
||||
@ -326,10 +326,10 @@ def test_send_p2sh(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -353,21 +353,21 @@ def test_send_p2sh(client):
|
||||
|
||||
|
||||
def test_send_p2sh_witness_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/156'/0'/1/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("49'/156'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
amount=1252382934 - 11000 - 12300000,
|
||||
)
|
||||
with client:
|
||||
@ -375,9 +375,9 @@ def test_send_p2sh_witness_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -408,23 +408,23 @@ def test_send_multisig_1(client):
|
||||
).node
|
||||
for i in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[1, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/156'/1'/1/0"),
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
amount=1252382934,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=1252382934 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -432,8 +432,8 @@ def test_send_multisig_1(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -454,8 +454,8 @@ def test_send_multisig_1(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
@ -480,24 +480,24 @@ def test_send_multisig_1(client):
|
||||
def test_send_mixed_inputs(client):
|
||||
# First is non-segwit, second is segwit.
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/156'/11'/0/0"),
|
||||
amount=38448607,
|
||||
prev_hash=TXHASH_db77c2,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("49'/156'/0'/1/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=38448607 + 1252382934 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -513,30 +513,30 @@ def test_send_mixed_inputs(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_send_btg_external_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/156'/0'/1/0"),
|
||||
amount=1252382934,
|
||||
prev_hash=TXHASH_25526b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# address_n=parse_path("49'/156'/0'/0/0"),
|
||||
# AXibjT5r96ZaVA8Lu4BQZocdTx7p5Ud8ZP
|
||||
amount=58456,
|
||||
prev_hash=TXHASH_f55c5b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex("a914aee37ad448e17438cabfee1756f2a08e33ed3ce887"),
|
||||
script_sig=bytes.fromhex("1600147c5edda9b293db2c8894b9d81efd77764910c445"),
|
||||
witness=bytes.fromhex(
|
||||
"024730440220091eece828409b3a9aa92dd2f9b032f9fb3a12b21b323a3fdea3cb18d08249af022065412107afcf76b0d28b90188c802f8f17b41790ed81c868d0ee23f1dd2ec53441210386789a34fe1a49bfc3e174adc6706c6222b0d80de76b884a0e3d32f8e9c4dc3e"
|
||||
),
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe",
|
||||
amount=1252382934 + 58456 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -544,8 +544,8 @@ def test_send_btg_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_25526b),
|
||||
request_input(0, TXHASH_25526b),
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
@ -28,7 +28,7 @@ from .signtx import (
|
||||
request_output,
|
||||
)
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Dash")
|
||||
|
||||
TXHASH_5579ea = bytes.fromhex(
|
||||
@ -42,26 +42,26 @@ pytestmark = pytest.mark.altcoin
|
||||
|
||||
|
||||
def test_send_dash(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/5'/0'/0/0"),
|
||||
# dash:XdTw4G5AWW4cogGd7ayybyBNDbuB45UpgH
|
||||
amount=1000000000,
|
||||
prev_hash=TXHASH_5579ea,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="XpTc36DPAeWmaueNBA9JqCg2GC8XDLKSYe",
|
||||
amount=999999000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(inp1.prev_hash),
|
||||
request_input(0, inp1.prev_hash),
|
||||
@ -83,23 +83,23 @@ def test_send_dash(client):
|
||||
|
||||
|
||||
def test_send_dash_dip2_input(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/5'/0'/0/0"),
|
||||
# dash:XdTw4G5AWW4cogGd7ayybyBNDbuB45UpgH
|
||||
amount=4095000260,
|
||||
prev_hash=TXHASH_15575a,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/5'/0'/1/0"),
|
||||
amount=4000000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="XrEFMNkxeipYHgEQKiJuqch8XzwrtfH5fm",
|
||||
amount=95000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
@ -107,8 +107,8 @@ def test_send_dash_dip2_input(client):
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(inp1.prev_hash),
|
||||
request_input(0, inp1.prev_hash),
|
||||
|
@ -16,13 +16,13 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Decred Testnet")
|
||||
|
||||
|
||||
@ -55,20 +55,20 @@ pytestmark = [pytest.mark.altcoin, pytest.mark.decred]
|
||||
|
||||
|
||||
def test_send_decred(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
prev_hash=TXHASH_e16248,
|
||||
prev_index=1,
|
||||
amount=200000000,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
decred_tree=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz",
|
||||
amount=190000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -76,9 +76,9 @@ def test_send_decred(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.FeeOverThreshold),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.FeeOverThreshold),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_e16248),
|
||||
request_input(0, TXHASH_e16248),
|
||||
@ -100,29 +100,29 @@ def test_send_decred(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_purchase_ticket_decred(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
prev_hash=TXHASH_e16248,
|
||||
prev_index=1,
|
||||
amount=200000000,
|
||||
decred_tree=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=199900000,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
amount=200000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out3 = proto.TxOutputType(
|
||||
out3 = messages.TxOutputType(
|
||||
address="TsR28UZRprhgQQhzWns2M6cAwchrNVvbYq2",
|
||||
amount=0,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -130,10 +130,10 @@ def test_purchase_ticket_decred(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
request_output(2),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_e16248),
|
||||
request_input(0, TXHASH_e16248),
|
||||
@ -160,30 +160,30 @@ def test_purchase_ticket_decred(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_spend_from_stake_generation_and_revocation_decred(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
prev_hash=TXHASH_8b6890,
|
||||
prev_index=2,
|
||||
amount=200000000,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
decred_staking_spend=proto.DecredStakingSpendType.SSGen,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
decred_staking_spend=messages.DecredStakingSpendType.SSGen,
|
||||
decred_tree=1,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
prev_hash=TXHASH_1f00fc,
|
||||
prev_index=0,
|
||||
amount=200000000,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
decred_staking_spend=proto.DecredStakingSpendType.SSRTX,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
decred_staking_spend=messages.DecredStakingSpendType.SSRTX,
|
||||
decred_tree=1,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz",
|
||||
amount=399900000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -192,8 +192,8 @@ def test_spend_from_stake_generation_and_revocation_decred(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_8b6890),
|
||||
request_input(0, TXHASH_8b6890),
|
||||
@ -221,47 +221,47 @@ def test_spend_from_stake_generation_and_revocation_decred(client):
|
||||
|
||||
|
||||
def test_send_decred_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
amount=190000000,
|
||||
prev_hash=TXHASH_5e6e35,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
decred_tree=0,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
|
||||
address_n=parse_path("m/44'/1'/0'/0/0"),
|
||||
amount=200000000,
|
||||
prev_hash=TXHASH_ccf95b,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
decred_tree=0,
|
||||
)
|
||||
|
||||
inp3 = proto.TxInputType(
|
||||
inp3 = messages.TxInputType(
|
||||
# Tskt39YEvzoJ5KBDH4f1auNzG3jViVjZ2RV
|
||||
address_n=parse_path("m/44'/1'/0'/0/1"),
|
||||
amount=200000000,
|
||||
prev_hash=TXHASH_f395ef,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
decred_tree=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="TsWjioPrP8E1TuTMmTrVMM2BA4iPrjQXBpR",
|
||||
amount=489975000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
# TsaSFRwfN9muW5F6ZX36iSksc9hruiC5F97
|
||||
address_n=parse_path("m/44'/1'/0'/1/0"),
|
||||
amount=100000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -271,9 +271,9 @@ def test_send_decred_change(client):
|
||||
request_input(1),
|
||||
request_input(2),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_5e6e35),
|
||||
request_input(0, TXHASH_5e6e35),
|
||||
@ -320,7 +320,7 @@ def test_decred_multisig_change(client):
|
||||
|
||||
def create_multisig(index, address, signatures=None):
|
||||
address_n = parse_path(address)
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=address_n, signatures=signatures, m=2
|
||||
)
|
||||
|
||||
@ -328,42 +328,42 @@ def test_decred_multisig_change(client):
|
||||
|
||||
def test_multisig(index):
|
||||
address_n, multisig = create_multisig(index, "m/0/0", signatures[0])
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=address_n,
|
||||
# TchpthUkRys1VQWgnQyLJNaA4MLBjVmRL2c
|
||||
multisig=multisig,
|
||||
amount=200000000,
|
||||
prev_hash=TXHASH_3f7c39,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
decred_tree=0,
|
||||
)
|
||||
|
||||
address_n, multisig = create_multisig(index, "m/0/1", signatures[1])
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=address_n,
|
||||
# TcnfDEfMhkM3oLWqiq9v9GmYgLK7qfjitKG
|
||||
multisig=multisig,
|
||||
amount=200000000,
|
||||
prev_hash=TXHASH_16da18,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
decred_tree=0,
|
||||
)
|
||||
|
||||
address_n, multisig = create_multisig(index, "m/1/0")
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=address_n,
|
||||
# TcrrURA3Bzj4isGU48PdSP9SDoU5oCpjEcb
|
||||
multisig=multisig,
|
||||
amount=99900000,
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="TsWjioPrP8E1TuTMmTrVMM2BA4iPrjQXBpR",
|
||||
amount=300000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -373,8 +373,8 @@ def test_decred_multisig_change(client):
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_3f7c39),
|
||||
request_input(0, TXHASH_3f7c39),
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
|
||||
TX_CACHE_TESTNET = TxCache("Testnet")
|
||||
TX_CACHE_MAINNET = TxCache("Bitcoin")
|
||||
@ -62,7 +62,7 @@ TXHASH_df862e = bytes.fromhex(
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2pkh_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q
|
||||
address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
prev_hash=TXHASH_e5040e,
|
||||
@ -70,13 +70,13 @@ def test_p2pkh_presigned(client):
|
||||
amount=31000000,
|
||||
)
|
||||
|
||||
inp1ext = proto.TxInputType(
|
||||
inp1ext = messages.TxInputType(
|
||||
# mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q
|
||||
# address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
prev_hash=TXHASH_e5040e,
|
||||
prev_index=0,
|
||||
amount=31000000,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex(
|
||||
"76a914a579388225827d9f2fe9014add644487808c695d88ac"
|
||||
),
|
||||
@ -85,7 +85,7 @@ def test_p2pkh_presigned(client):
|
||||
),
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# mopZWqZZyQc3F2Sy33cvDtJchSAMsnLi7b
|
||||
address_n=parse_path("m/44h/1h/0h/0/1"),
|
||||
prev_hash=TXHASH_d830b8,
|
||||
@ -93,13 +93,13 @@ def test_p2pkh_presigned(client):
|
||||
amount=600000000,
|
||||
)
|
||||
|
||||
inp2ext = proto.TxInputType(
|
||||
inp2ext = messages.TxInputType(
|
||||
# mopZWqZZyQc3F2Sy33cvDtJchSAMsnLi7b
|
||||
# address_n=parse_path("m/44h/1h/0h/0/1"),
|
||||
prev_hash=TXHASH_d830b8,
|
||||
prev_index=1,
|
||||
amount=600000000,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex(
|
||||
"76a9145b157a678a10021243307e4bb58f36375aa80e1088ac"
|
||||
),
|
||||
@ -108,16 +108,16 @@ def test_p2pkh_presigned(client):
|
||||
),
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qnspxpr2xj9s2jt6qlhuvdnxw6q55jvygcf89r2",
|
||||
amount=620000000,
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("44h/1h/0h/1/0"),
|
||||
amount=31000000 + 600000000 - 620000000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
# Test with first input as pre-signed external.
|
||||
@ -159,40 +159,40 @@ def test_p2pkh_presigned(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2wpkh_in_p2sh_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=111145789,
|
||||
prev_hash=TXHASH_091446,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex("a91458b53ea7f832e8f096e896b8713a8c6df0e892ca87"),
|
||||
script_sig=bytearray.fromhex("160014d16b8c0680c61fc6ed2e407455715055e41052f5"),
|
||||
witness=bytes.fromhex(
|
||||
"02483045022100ead79ee134f25bb585b48aee6284a4bb14e07f03cc130253e83450d095515e5202201e161e9402c8b26b666f2b67e5b668a404ef7e57858ae9a6a68c3837e65fdc69012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b79"
|
||||
),
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/1/0"),
|
||||
amount=7289000,
|
||||
prev_hash=TXHASH_65b811,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
# address_n=parse_path("44'/1'/0'/0/0"),
|
||||
address="2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=45600000,
|
||||
)
|
||||
out3 = proto.TxOutputType(
|
||||
out3 = messages.TxOutputType(
|
||||
address="mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q",
|
||||
amount=111145789 + 7289000 - 11000 - 12300000 - 45600000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -201,12 +201,12 @@ def test_p2wpkh_in_p2sh_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(2),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
@ -248,18 +248,18 @@ def test_p2wpkh_in_p2sh_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(2),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
request_output(0, TXHASH_091446),
|
||||
request_output(1, TXHASH_091446),
|
||||
proto.Failure(code=proto.FailureType.DataError),
|
||||
messages.Failure(code=messages.FailureType.DataError),
|
||||
]
|
||||
)
|
||||
|
||||
@ -275,22 +275,22 @@ def test_p2wpkh_in_p2sh_presigned(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2wpkh_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tb1qkvwu9g3k2pdxewfqr7syz89r3gj557l3uuf9r9
|
||||
address_n=parse_path("m/84h/1h/0h/0/0"),
|
||||
prev_hash=TXHASH_70f987,
|
||||
prev_index=0,
|
||||
amount=100000,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# tb1qldlynaqp0hy4zc2aag3pkenzvxy65saesxw3wd
|
||||
# address_n=parse_path("m/84h/1h/0h/0/1"),
|
||||
prev_hash=TXHASH_65b768,
|
||||
prev_index=0,
|
||||
amount=10000,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex("0014fb7e49f4017dc951615dea221b66626189aa43b9"),
|
||||
script_sig=bytes.fromhex(""),
|
||||
witness=bytearray.fromhex(
|
||||
@ -298,16 +298,16 @@ def test_p2wpkh_presigned(client):
|
||||
),
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qnspxpr2xj9s2jt6qlhuvdnxw6q55jvygcf89r2",
|
||||
amount=50000,
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("84h/1h/0h/1/0"),
|
||||
amount=100000 + 10000 - 50000 - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
)
|
||||
|
||||
# Test with second input as pre-signed external.
|
||||
@ -339,22 +339,22 @@ def test_p2wpkh_presigned(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2wsh_external_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=12300000,
|
||||
prev_hash=TXHASH_091446,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# 1-of-2 multisig
|
||||
# m/84'/1'/0/0/0' for "alcohol woman abuse ..." seed.
|
||||
# m/84'/1'/0/0/0' for "all all ... all" seed.
|
||||
# tb1qpzmgzpcumztvmpu3q27wwdggqav26j9dgks92pvnne2lz9ferxgssmhzlq
|
||||
prev_hash=TXHASH_a345b8,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex(
|
||||
"002008b681071cd896cd879102bce735080758ad48ad45a05505939e55f115391991"
|
||||
),
|
||||
@ -364,10 +364,10 @@ def test_p2wsh_external_presigned(client):
|
||||
),
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp",
|
||||
amount=12300000 + 100 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -376,8 +376,8 @@ def test_p2wsh_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
@ -413,8 +413,8 @@ def test_p2wsh_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
@ -424,7 +424,7 @@ def test_p2wsh_external_presigned(client):
|
||||
request_meta(TXHASH_a345b8),
|
||||
request_input(0, TXHASH_a345b8),
|
||||
request_output(0, TXHASH_a345b8),
|
||||
proto.Failure(code=proto.FailureType.DataError),
|
||||
messages.Failure(code=messages.FailureType.DataError),
|
||||
]
|
||||
)
|
||||
|
||||
@ -436,15 +436,15 @@ def test_p2wsh_external_presigned(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2tr_external_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tb1pswrqtykue8r89t9u4rprjs0gt4qzkdfuursfnvqaa3f2yql07zmq8s8a5u
|
||||
address_n=parse_path("86'/1'/0'/0/0"),
|
||||
amount=6800,
|
||||
prev_hash=TXHASH_df862e,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDTAPROOT,
|
||||
script_type=messages.InputScriptType.SPENDTAPROOT,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# tb1p8tvmvsvhsee73rhym86wt435qrqm92psfsyhy6a3n5gw455znnpqm8wald
|
||||
# m/86'/1'/0'/0/1 for "all all ... all" seed.
|
||||
amount=13000,
|
||||
@ -453,21 +453,21 @@ def test_p2tr_external_presigned(client):
|
||||
script_pubkey=bytes.fromhex(
|
||||
"51203ad9b641978673e88ee4d9f4e5d63400c1b2a8304c09726bb19d10ead2829cc2"
|
||||
),
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
witness=bytearray.fromhex(
|
||||
"01409956e47403278bf76eecbbbc3af0c2731d8347763825248a2e0f39aca5a684a7d5054e7222a1033fb5864a886180f1a8c64adab12433c78298d1f83e4c8f46e1"
|
||||
),
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
# 84'/1'/1'/0/0
|
||||
address="tb1q7r9yvcdgcl6wmtta58yxf29a8kc96jkyxl7y88",
|
||||
amount=15000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
# tb1pn2d0yjeedavnkd8z8lhm566p0f2utm3lgvxrsdehnl94y34txmts5s7t4c
|
||||
address_n=parse_path("86'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOTAPROOT,
|
||||
script_type=messages.OutputScriptType.PAYTOTAPROOT,
|
||||
amount=6800 + 13000 - 200 - 15000,
|
||||
)
|
||||
with client:
|
||||
@ -476,9 +476,9 @@ def test_p2tr_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(1),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
@ -506,11 +506,11 @@ def test_p2tr_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(1),
|
||||
proto.Failure(code=proto.FailureType.DataError),
|
||||
messages.Failure(code=messages.FailureType.DataError),
|
||||
]
|
||||
)
|
||||
|
||||
@ -538,35 +538,35 @@ def test_p2wpkh_in_p2sh_with_proof(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2wpkh_with_proof(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# seed "alcohol woman abuse must during monitor noble actual mixed trade anger aisle"
|
||||
# 84'/1'/0'/0/0
|
||||
# tb1qnspxpr2xj9s2jt6qlhuvdnxw6q55jvygcf89r2
|
||||
amount=100000,
|
||||
prev_hash=TXHASH_e5b7e2,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex("00149c02608d469160a92f40fdf8c6ccced029493088"),
|
||||
ownership_proof=bytearray.fromhex(
|
||||
"534c001900016b2055d8190244b2ed2d46513c40658a574d3bc2deb6969c0535bb818b44d2c40002483045022100d4ad0374c922848c71d913fba59c81b9075e0d33e884d953f0c4b4806b8ffd0c022024740e6717a2b6a5aa03148c3a28b02c713b4e30fc8aeae67fa69eb20e8ddcd9012103505f0d82bbdd251511591b34f36ad5eea37d3220c2b81a1189084431ddb3aa3d"
|
||||
),
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/1/0"),
|
||||
amount=7289000,
|
||||
prev_hash=TXHASH_65b811,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc",
|
||||
amount=1230000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q",
|
||||
amount=100000 + 7289000 - 11000 - 1230000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -575,10 +575,10 @@ def test_p2wpkh_with_proof(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_e5b7e2),
|
||||
request_input(0, TXHASH_e5b7e2),
|
||||
@ -624,32 +624,32 @@ def test_p2wpkh_with_proof(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2wpkh_with_false_proof(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tb1qkvwu9g3k2pdxewfqr7syz89r3gj557l3uuf9r9
|
||||
address_n=parse_path("m/84h/1h/0h/0/0"),
|
||||
prev_hash=TXHASH_70f987,
|
||||
prev_index=0,
|
||||
amount=100000,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# tb1qldlynaqp0hy4zc2aag3pkenzvxy65saesxw3wd
|
||||
# address_n=parse_path("m/84h/1h/0h/0/1"),
|
||||
prev_hash=TXHASH_65b768,
|
||||
prev_index=0,
|
||||
amount=10000,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex("0014fb7e49f4017dc951615dea221b66626189aa43b9"),
|
||||
ownership_proof=bytes.fromhex(
|
||||
"534c00190001b0b66657a824e41c063299fb4435dc70a6fd2e9db4c87e3c26a7ab7c0283547b0002473044022060bf60380142ed54fa907c82cb5ab438bfec22ebf8b5a92971fe104b7e3dd41002206f3fc4ac2f9c1a4a12255b5f678b6e57a088816051faea5a65a66951b394c150012103dcf3bc936ecb2ec57b8f468050abce8c8756e75fd74273c9977744b1a0be7d03"
|
||||
),
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qnspxpr2xj9s2jt6qlhuvdnxw6q55jvygcf89r2",
|
||||
amount=50000,
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -658,8 +658,8 @@ def test_p2wpkh_with_false_proof(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_70f987),
|
||||
request_input(0, TXHASH_70f987),
|
||||
@ -670,7 +670,7 @@ def test_p2wpkh_with_false_proof(client):
|
||||
request_input(0, TXHASH_65b768),
|
||||
request_output(0, TXHASH_65b768),
|
||||
request_output(1, TXHASH_65b768),
|
||||
proto.Failure(code=proto.FailureType.DataError),
|
||||
messages.Failure(code=messages.FailureType.DataError),
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -16,12 +16,12 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Groestlcoin")
|
||||
TX_API_TESTNET = TxCache("Groestlcoin Testnet")
|
||||
|
||||
@ -39,17 +39,17 @@ pytestmark = pytest.mark.altcoin
|
||||
|
||||
|
||||
def test_legacy(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# FXHDsC5ZqWQHkDmShzgRVZ1MatpWhwxTAA
|
||||
address_n=parse_path("44'/17'/0'/0/2"),
|
||||
amount=210016,
|
||||
prev_hash=TXHASH_cb74c8,
|
||||
prev_index=0,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="FtM4zAn9aVYgHgxmamWBgWPyZsb6RhvkA9",
|
||||
amount=210016 - 192,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client, "Groestlcoin", [inp1], [out1], prev_txes=TX_API
|
||||
@ -61,17 +61,17 @@ def test_legacy(client):
|
||||
|
||||
|
||||
def test_legacy_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# FXHDsC5ZqWQHkDmShzgRVZ1MatpWhwxTAA
|
||||
address_n=parse_path("44'/17'/0'/0/2"),
|
||||
amount=210016,
|
||||
prev_hash=TXHASH_cb74c8,
|
||||
prev_index=0,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/17'/0'/0/3"), # FtM4zAn9aVYgHgxmamWBgWPyZsb6RhvkA9
|
||||
amount=210016 - 192,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client, "Groestlcoin", [inp1], [out1], prev_txes=TX_API
|
||||
@ -83,24 +83,24 @@ def test_legacy_change(client):
|
||||
|
||||
|
||||
def test_send_segwit_p2sh(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_09a48b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
sequence=0xFFFFFFFE,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mvbu1Gdy8SUjTenqerxUaZyYjmvedc787y",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7",
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client,
|
||||
@ -117,23 +117,23 @@ def test_send_segwit_p2sh(client):
|
||||
|
||||
|
||||
def test_send_segwit_p2sh_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_09a48b,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
sequence=0xFFFFFFFE,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mvbu1Gdy8SUjTenqerxUaZyYjmvedc787y",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
@ -151,22 +151,22 @@ def test_send_segwit_p2sh_change(client):
|
||||
|
||||
|
||||
def test_send_segwit_native(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=12300000,
|
||||
prev_hash=TXHASH_4f2f85,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
sequence=0xFFFFFFFE,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e",
|
||||
amount=5000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="tgrs1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt9lkd57",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=12300000 - 11000 - 5000000,
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
@ -184,22 +184,22 @@ def test_send_segwit_native(client):
|
||||
|
||||
|
||||
def test_send_segwit_native_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=12300000,
|
||||
prev_hash=TXHASH_4f2f85,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
sequence=0xFFFFFFFE,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e",
|
||||
amount=5000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("84'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
amount=12300000 - 11000 - 5000000,
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, device, messages as proto
|
||||
from trezorlib import btc, device, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
@ -42,7 +42,7 @@ def test_invalid_path_fail(client):
|
||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||
# input 0: 0.0039 BTC
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44h/0h/0h/0/0"),
|
||||
amount=390000,
|
||||
prev_hash=TXHASH_d5f65e,
|
||||
@ -50,16 +50,16 @@ def test_invalid_path_fail(client):
|
||||
)
|
||||
|
||||
# address is converted from 1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1 by changing the version
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="LfWz9wLHmqU9HoDkMg9NqbRosrHvEixeVZ",
|
||||
amount=390000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with pytest.raises(TrezorFailure) as exc:
|
||||
btc.sign_tx(client, "Litecoin", [inp1], [out1], prev_txes=TX_CACHE_MAINNET)
|
||||
|
||||
assert exc.value.code == proto.FailureType.DataError
|
||||
assert exc.value.code == messages.FailureType.DataError
|
||||
assert exc.value.message.endswith("Forbidden key path")
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ def test_invalid_path_prompt(client):
|
||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||
# input 0: 0.0039 BTC
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44h/0h/0h/0/0"),
|
||||
amount=390000,
|
||||
prev_hash=TXHASH_d5f65e,
|
||||
@ -79,14 +79,14 @@ def test_invalid_path_prompt(client):
|
||||
)
|
||||
|
||||
# address is converted from 1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1 by changing the version
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="LfWz9wLHmqU9HoDkMg9NqbRosrHvEixeVZ",
|
||||
amount=390000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
device.apply_settings(
|
||||
client, safety_checks=proto.SafetyCheckLevel.PromptTemporarily
|
||||
client, safety_checks=messages.SafetyCheckLevel.PromptTemporarily
|
||||
)
|
||||
|
||||
btc.sign_tx(client, "Litecoin", [inp1], [out1], prev_txes=TX_CACHE_MAINNET)
|
||||
@ -100,7 +100,7 @@ def test_invalid_path_pass_forkid(client):
|
||||
# tx: 8cc1f4adf7224ce855cf535a5104594a0004cb3b640d6714fdb00b9128832dd5
|
||||
# input 0: 0.0039 BTC
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44h/0h/0h/0/0"),
|
||||
amount=390000,
|
||||
prev_hash=TXHASH_8cc1f4,
|
||||
@ -108,10 +108,10 @@ def test_invalid_path_pass_forkid(client):
|
||||
)
|
||||
|
||||
# address is converted from 1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1 to cashaddr format
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="bitcoincash:qr0fk25d5zygyn50u5w7h6jkvctas52n0qxff9ja6r",
|
||||
amount=390000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
btc.sign_tx(client, "Bcash", [inp1], [out1], prev_txes=TX_CACHE_BCASH)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
@ -28,7 +28,7 @@ from .signtx import (
|
||||
request_output,
|
||||
)
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Komodo")
|
||||
|
||||
TXHASH_2807c = bytes.fromhex(
|
||||
@ -45,7 +45,7 @@ def test_one_one_fee_sapling(client):
|
||||
# prevout: 2807c5b126ec8e2b078cab0f12e4c8b4ce1d7724905f8ebef8dca26b0c8e0f1d:0
|
||||
# input 1: 10.9998 KMD
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# R9HgJZo6JBKmPvhm7whLSR8wiHyZrEDVRi
|
||||
address_n=parse_path("44'/141'/0'/0/0"),
|
||||
amount=1099980000,
|
||||
@ -53,10 +53,10 @@ def test_one_one_fee_sapling(client):
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="R9HgJZo6JBKmPvhm7whLSR8wiHyZrEDVRi",
|
||||
amount=1099980000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -64,9 +64,9 @@ def test_one_one_fee_sapling(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_2807c),
|
||||
request_input(0, TXHASH_2807c),
|
||||
@ -101,7 +101,7 @@ def test_one_one_rewards_claim(client):
|
||||
# prevout: 7b28bd91119e9776f0d4ebd80e570165818a829bbf4477cd1afe5149dbcd34b1:0
|
||||
# input 1: 10.9997 KMD
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# R9HgJZo6JBKmPvhm7whLSR8wiHyZrEDVRi
|
||||
address_n=parse_path("44'/141'/0'/0/0"),
|
||||
amount=1099970000,
|
||||
@ -109,17 +109,17 @@ def test_one_one_rewards_claim(client):
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="R9HgJZo6JBKmPvhm7whLSR8wiHyZrEDVRi",
|
||||
amount=1099970000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
# kmd interest, vout sum > vin sum
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="R9HgJZo6JBKmPvhm7whLSR8wiHyZrEDVRi",
|
||||
amount=79605,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -127,11 +127,11 @@ def test_one_one_rewards_claim(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_7b28bd),
|
||||
request_input(0, TXHASH_7b28bd),
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import H_, parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Testnet")
|
||||
|
||||
TXHASH_20912f = bytes.fromhex(
|
||||
@ -41,22 +41,22 @@ TXHASH_e5040e = bytes.fromhex(
|
||||
|
||||
|
||||
def test_send_p2sh(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_20912f,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
)
|
||||
with client:
|
||||
@ -64,10 +64,10 @@ def test_send_p2sh(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_20912f),
|
||||
request_input(0, TXHASH_20912f),
|
||||
@ -91,22 +91,22 @@ def test_send_p2sh(client):
|
||||
|
||||
|
||||
def test_send_p2sh_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_20912f,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
)
|
||||
with client:
|
||||
@ -114,9 +114,9 @@ def test_send_p2sh_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_20912f),
|
||||
request_input(0, TXHASH_20912f),
|
||||
@ -142,25 +142,25 @@ def test_send_p2sh_change(client):
|
||||
def test_testnet_segwit_big_amount(client):
|
||||
# This test is testing transaction with amount bigger than fits to uint32
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("m/49'/1'/0'/0/0"),
|
||||
amount=2 ** 32 + 1,
|
||||
prev_hash=TXHASH_dee13c,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2Mt7P2BAfE922zmfXrdcYTLyR7GUvbwSEns", # seed allallall, bip32: m/49'/1'/0'/0/1, script type:p2shsegwit
|
||||
amount=2 ** 32 + 1,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_dee13c),
|
||||
request_output(0, TXHASH_dee13c),
|
||||
@ -188,23 +188,23 @@ def test_send_multisig_1(client):
|
||||
for i in range(1, 4)
|
||||
]
|
||||
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[1, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/1'/1/0"),
|
||||
prev_hash=TXHASH_9c3192,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
amount=1610436,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC",
|
||||
amount=1605000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -212,8 +212,8 @@ def test_send_multisig_1(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_9c3192),
|
||||
request_input(0, TXHASH_9c3192),
|
||||
@ -234,8 +234,8 @@ def test_send_multisig_1(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_9c3192),
|
||||
request_input(0, TXHASH_9c3192),
|
||||
@ -258,22 +258,22 @@ def test_send_multisig_1(client):
|
||||
|
||||
|
||||
def test_attack_change_input_address(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_20912f,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("49'/1'/12'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
)
|
||||
|
||||
@ -283,10 +283,10 @@ def test_attack_change_input_address(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_20912f),
|
||||
request_input(0, TXHASH_20912f),
|
||||
@ -321,26 +321,26 @@ def test_attack_change_input_address(client):
|
||||
|
||||
# Now run the attack, must trigger the exception
|
||||
with client:
|
||||
client.set_filter(proto.TxAck, attack_processor)
|
||||
client.set_filter(messages.TxAck, attack_processor)
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_20912f),
|
||||
request_input(0, TXHASH_20912f),
|
||||
request_output(0, TXHASH_20912f),
|
||||
request_output(1, TXHASH_20912f),
|
||||
request_input(0),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
messages.Failure(code=messages.FailureType.ProcessError),
|
||||
]
|
||||
)
|
||||
with pytest.raises(TrezorFailure) as exc:
|
||||
btc.sign_tx(client, "Testnet", [inp1], [out1, out2], prev_txes=TX_API)
|
||||
assert exc.value.code == proto.FailureType.ProcessError
|
||||
assert exc.value.code == messages.FailureType.ProcessError
|
||||
assert exc.value.message.endswith("Transaction has changed during signing")
|
||||
|
||||
|
||||
@ -348,35 +348,35 @@ def test_attack_mixed_inputs(client):
|
||||
TRUE_AMOUNT = 123456789
|
||||
FAKE_AMOUNT = 120000000
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/1'/0'/0/0"),
|
||||
amount=31000000,
|
||||
prev_hash=TXHASH_e5040e,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||
sequence=0xFFFFFFFD,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
amount=TRUE_AMOUNT,
|
||||
prev_hash=TXHASH_20912f,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
sequence=0xFFFFFFFD,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC",
|
||||
amount=31000000 + TRUE_AMOUNT - 3456789,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
expected_responses = [
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.FeeOverThreshold),
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.FeeOverThreshold),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_e5040e),
|
||||
request_input(0, TXHASH_e5040e),
|
||||
@ -418,11 +418,11 @@ def test_attack_mixed_inputs(client):
|
||||
if client.features.model == "1":
|
||||
# T1 fails as soon as it encounters the fake amount.
|
||||
expected_responses = (
|
||||
expected_responses[:4] + expected_responses[5:15] + [proto.Failure()]
|
||||
expected_responses[:4] + expected_responses[5:15] + [messages.Failure()]
|
||||
)
|
||||
else:
|
||||
expected_responses = (
|
||||
expected_responses[:4] + expected_responses[5:16] + [proto.Failure()]
|
||||
expected_responses[:4] + expected_responses[5:16] + [messages.Failure()]
|
||||
)
|
||||
|
||||
with pytest.raises(TrezorFailure) as e, client:
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.tools import H_, parse_path
|
||||
|
||||
from ..bip32 import deserialize
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Testnet")
|
||||
|
||||
TXHASH_20912f = bytes.fromhex(
|
||||
@ -59,22 +59,22 @@ TXHASH_ec16dc = bytes.fromhex(
|
||||
|
||||
|
||||
def test_send_p2sh(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_20912f,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
)
|
||||
with client:
|
||||
@ -82,10 +82,10 @@ def test_send_p2sh(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_20912f),
|
||||
request_input(0, TXHASH_20912f),
|
||||
@ -109,22 +109,22 @@ def test_send_p2sh(client):
|
||||
|
||||
|
||||
def test_send_p2sh_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=TXHASH_20912f,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
amount=123456789 - 11000 - 12300000,
|
||||
)
|
||||
with client:
|
||||
@ -132,9 +132,9 @@ def test_send_p2sh_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_20912f),
|
||||
request_input(0, TXHASH_20912f),
|
||||
@ -158,21 +158,21 @@ def test_send_p2sh_change(client):
|
||||
|
||||
|
||||
def test_send_native(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=12300000,
|
||||
prev_hash=TXHASH_091446,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp",
|
||||
amount=5000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=12300000 - 11000 - 5000000,
|
||||
)
|
||||
with client:
|
||||
@ -180,10 +180,10 @@ def test_send_native(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
@ -207,21 +207,21 @@ def test_send_native(client):
|
||||
|
||||
|
||||
def test_send_to_taproot(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=10000,
|
||||
prev_hash=TXHASH_ec16dc,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1pdvdljpj774356dpk32c2ks0yqv7q7c4f98px2d9e76s73vpudpxs7tl6vp",
|
||||
amount=7000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="tb1qcc4ext5rsa8pzqa2m030jk670wmn5f649pu7sr",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=10000 - 7000 - 200,
|
||||
)
|
||||
with client:
|
||||
@ -236,21 +236,21 @@ def test_send_to_taproot(client):
|
||||
|
||||
|
||||
def test_send_native_change(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=12300000,
|
||||
prev_hash=TXHASH_091446,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp",
|
||||
amount=5000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("84'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
amount=12300000 - 11000 - 5000000,
|
||||
)
|
||||
with client:
|
||||
@ -258,9 +258,9 @@ def test_send_native_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
@ -284,37 +284,37 @@ def test_send_native_change(client):
|
||||
|
||||
|
||||
def test_send_both(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=111145789,
|
||||
prev_hash=TXHASH_091446,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/1/0"),
|
||||
amount=7289000,
|
||||
prev_hash=TXHASH_65b811,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc",
|
||||
amount=12300000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
# address_n=parse_path("44'/1'/0'/0/0"),
|
||||
# script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
# script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
address="2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc",
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
amount=45600000,
|
||||
)
|
||||
out3 = proto.TxOutputType(
|
||||
out3 = messages.TxOutputType(
|
||||
address="mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q",
|
||||
amount=111145789 + 7289000 - 11000 - 12300000 - 45600000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -323,12 +323,12 @@ def test_send_both(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(2),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
@ -365,26 +365,26 @@ def test_send_multisig_1(client):
|
||||
btc.get_public_node(client, parse_path(f"49'/1'/{index}'"), coin_name="Testnet")
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[0, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/1'/0/0"),
|
||||
prev_hash=TXHASH_9c3192,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
amount=1610436,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy",
|
||||
amount=1605000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -392,8 +392,8 @@ def test_send_multisig_1(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_9c3192),
|
||||
request_input(0, TXHASH_9c3192),
|
||||
@ -414,8 +414,8 @@ def test_send_multisig_1(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_9c3192),
|
||||
request_input(0, TXHASH_9c3192),
|
||||
@ -443,26 +443,26 @@ def test_send_multisig_2(client):
|
||||
btc.get_public_node(client, parse_path(f"84'/1'/{index}'"), coin_name="Testnet")
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[0, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/2'/0/1"),
|
||||
prev_hash=TXHASH_f41cbe,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
multisig=multisig,
|
||||
amount=1605000,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z",
|
||||
amount=1604000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -470,8 +470,8 @@ def test_send_multisig_2(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_f41cbe),
|
||||
request_input(0, TXHASH_f41cbe),
|
||||
@ -491,8 +491,8 @@ def test_send_multisig_2(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_f41cbe),
|
||||
request_input(0, TXHASH_f41cbe),
|
||||
@ -519,33 +519,33 @@ def test_send_multisig_3_change(client):
|
||||
btc.get_public_node(client, parse_path(f"84'/1'/{index}'"), coin_name="Testnet")
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/1'/1/0"),
|
||||
prev_hash=TXHASH_c93480,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
multisig=multisig,
|
||||
amount=1604000,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("84'/1'/1'/1/1"),
|
||||
amount=1603000,
|
||||
multisig=multisig2,
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -553,7 +553,7 @@ def test_send_multisig_3_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_c93480),
|
||||
request_input(0, TXHASH_c93480),
|
||||
@ -574,7 +574,7 @@ def test_send_multisig_3_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_c93480),
|
||||
request_input(0, TXHASH_c93480),
|
||||
@ -601,33 +601,33 @@ def test_send_multisig_4_change(client):
|
||||
btc.get_public_node(client, parse_path(f"49'/1'/{index}'"), coin_name="Testnet")
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 2],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("49'/1'/1'/1/1"),
|
||||
prev_hash=TXHASH_31bc1c,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
amount=1603000,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("49'/1'/1'/1/2"),
|
||||
amount=1602000,
|
||||
multisig=multisig2,
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -635,7 +635,7 @@ def test_send_multisig_4_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_31bc1c),
|
||||
request_input(0, TXHASH_31bc1c),
|
||||
@ -656,7 +656,7 @@ def test_send_multisig_4_change(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_31bc1c),
|
||||
request_input(0, TXHASH_31bc1c),
|
||||
@ -691,40 +691,40 @@ def test_multisig_mismatch_inputs_single(client):
|
||||
)
|
||||
|
||||
# tb1qpzmgzpcumztvmpu3q27wwdggqav26j9dgks92pvnne2lz9ferxgssmhzlq
|
||||
multisig_in = proto.MultisigRedeemScriptType(
|
||||
multisig_in = messages.MultisigRedeemScriptType(
|
||||
nodes=[node_int, node_ext], address_n=[0, 0], signatures=[b"", b""], m=1
|
||||
)
|
||||
|
||||
multisig_out = proto.MultisigRedeemScriptType(
|
||||
multisig_out = messages.MultisigRedeemScriptType(
|
||||
nodes=[node_int, node_ext], address_n=[1, 0], signatures=[b"", b""], m=1
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
amount=12300000,
|
||||
prev_hash=TXHASH_091446,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
address_n=parse_path("84'/1'/0'/0/0"),
|
||||
prev_hash=TXHASH_a345b8,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
multisig=multisig_in,
|
||||
amount=100,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp",
|
||||
amount=5000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("84'/1'/0'/1/0"),
|
||||
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
multisig=multisig_out,
|
||||
amount=12300000 + 100 - 5000000 - 10000,
|
||||
)
|
||||
@ -735,11 +735,11 @@ def test_multisig_mismatch_inputs_single(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
# Ensure that the multisig output is not identified as a change output.
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_091446),
|
||||
request_input(0, TXHASH_091446),
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
@ -29,7 +29,7 @@ from .signtx import (
|
||||
request_output,
|
||||
)
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Zcash Testnet")
|
||||
|
||||
TXHASH_aaf51e = bytes.fromhex(
|
||||
@ -59,7 +59,7 @@ def test_v3_not_supported(client):
|
||||
# prevout: aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc:1
|
||||
# input 1: 3.0 TAZ
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||
address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
amount=300000000,
|
||||
@ -67,10 +67,10 @@ def test_v3_not_supported(client):
|
||||
prev_index=1,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z",
|
||||
amount=300000000 - 1940,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client, pytest.raises(TrezorFailure, match="DataError"):
|
||||
@ -90,7 +90,7 @@ def test_one_one_fee_sapling(client):
|
||||
# prevout: e3820602226974b1dd87b7113cc8aea8c63e5ae29293991e7bfa80c126930368:0
|
||||
# input 1: 3.0 TAZ
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||
address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
amount=300000000,
|
||||
@ -98,10 +98,10 @@ def test_one_one_fee_sapling(client):
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z",
|
||||
amount=300000000 - 1940,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -109,8 +109,8 @@ def test_one_one_fee_sapling(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_e38206),
|
||||
request_input(0, TXHASH_e38206),
|
||||
@ -143,17 +143,17 @@ def test_one_one_fee_sapling(client):
|
||||
|
||||
|
||||
def test_version_group_id_missing(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||
address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
amount=300000000,
|
||||
prev_hash=TXHASH_e38206,
|
||||
prev_index=0,
|
||||
)
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z",
|
||||
amount=300000000 - 1940,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with pytest.raises(TrezorFailure, match="Version group ID must be set."):
|
||||
@ -169,25 +169,25 @@ def test_version_group_id_missing(client):
|
||||
|
||||
def test_spend_old_versions(client):
|
||||
# inputs are NOT OWNED by this seed
|
||||
input_v1 = proto.TxInputType(
|
||||
input_v1 = messages.TxInputType(
|
||||
address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
amount=123000000,
|
||||
prev_hash=TXHASH_v1,
|
||||
prev_index=0,
|
||||
)
|
||||
input_v2 = proto.TxInputType(
|
||||
input_v2 = messages.TxInputType(
|
||||
address_n=parse_path("m/44h/1h/0h/0/1"),
|
||||
amount=49990000,
|
||||
prev_hash=TXHASH_v2,
|
||||
prev_index=0,
|
||||
)
|
||||
input_v3 = proto.TxInputType(
|
||||
input_v3 = messages.TxInputType(
|
||||
address_n=parse_path("m/44h/1h/0h/0/2"),
|
||||
amount=300000000,
|
||||
prev_hash=TXHASH_v3,
|
||||
prev_index=1,
|
||||
)
|
||||
input_v4 = proto.TxInputType(
|
||||
input_v4 = messages.TxInputType(
|
||||
address_n=parse_path("m/44h/1h/0h/0/3"),
|
||||
amount=100000,
|
||||
prev_hash=TXHASH_v4,
|
||||
@ -200,10 +200,10 @@ def test_spend_old_versions(client):
|
||||
txdata = TX_API[txi.prev_hash]
|
||||
assert txdata.version == i
|
||||
|
||||
output = proto.TxOutputType(
|
||||
output = messages.TxOutputType(
|
||||
address="tmNvfeKR5PkcQazLEqddTskFr6Ev9tsovfQ",
|
||||
amount=sum(txi.amount for txi in inputs),
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -226,7 +226,7 @@ def test_spend_old_versions(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_external_presigned(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
# tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||
address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
amount=300000000,
|
||||
@ -234,13 +234,13 @@ def test_external_presigned(client):
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
inp2 = messages.TxInputType(
|
||||
# tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||
# address_n=parse_path("m/44h/1h/0h/0/0"),
|
||||
amount=300000000,
|
||||
prev_hash=TXHASH_aaf51e,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.EXTERNAL,
|
||||
script_type=messages.InputScriptType.EXTERNAL,
|
||||
script_pubkey=bytes.fromhex(
|
||||
"76a914a579388225827d9f2fe9014add644487808c695d88ac"
|
||||
),
|
||||
@ -249,10 +249,10 @@ def test_external_presigned(client):
|
||||
),
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z",
|
||||
amount=300000000 + 300000000 - 1940,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -261,8 +261,8 @@ def test_external_presigned(client):
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_e38206),
|
||||
request_input(0, TXHASH_e38206),
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path, tx_hash
|
||||
|
||||
@ -24,7 +24,7 @@ from ..common import MNEMONIC12
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Bitcoin")
|
||||
|
||||
TXHASH_c6091a = bytes.fromhex(
|
||||
@ -46,23 +46,23 @@ def test_2_of_3(client):
|
||||
for index in range(1, 4)
|
||||
]
|
||||
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
# Let's go to sign with key 1
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48'/0'/1'/0'/0/0"),
|
||||
amount=100000,
|
||||
prev_hash=TXHASH_c6091a,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss",
|
||||
amount=100000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -70,8 +70,8 @@ def test_2_of_3(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_c6091a),
|
||||
request_input(0, TXHASH_c6091a),
|
||||
@ -97,7 +97,7 @@ def test_2_of_3(client):
|
||||
# ---------------------------------------
|
||||
# Let's do second signature using 3rd key
|
||||
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes,
|
||||
address_n=[0, 0],
|
||||
signatures=[
|
||||
@ -109,12 +109,12 @@ def test_2_of_3(client):
|
||||
)
|
||||
|
||||
# Let's do a second signature with key 3
|
||||
inp3 = proto.TxInputType(
|
||||
inp3 = messages.TxInputType(
|
||||
address_n=parse_path("48'/0'/3'/0'/0/0"),
|
||||
amount=100000,
|
||||
prev_hash=TXHASH_c6091a,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig,
|
||||
)
|
||||
|
||||
@ -123,8 +123,8 @@ def test_2_of_3(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_c6091a),
|
||||
request_input(0, TXHASH_c6091a),
|
||||
@ -156,27 +156,27 @@ def test_15_of_15(client):
|
||||
node = btc.get_public_node(
|
||||
client, parse_path("48h/0h/1h/0h"), coin_name="Bitcoin"
|
||||
).node
|
||||
pubs = [proto.HDNodePathType(node=node, address_n=[0, x]) for x in range(15)]
|
||||
pubs = [messages.HDNodePathType(node=node, address_n=[0, x]) for x in range(15)]
|
||||
|
||||
signatures = [b""] * 15
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="17kTB7qSk3MupQxWdiv5ZU3zcrZc2Azes1",
|
||||
amount=10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
for x in range(15):
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
pubkeys=pubs, signatures=signatures, m=15
|
||||
)
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path(f"48h/0h/1h/0h/0/{x}"),
|
||||
amount=20000,
|
||||
prev_hash=TXHASH_6189e3,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig,
|
||||
)
|
||||
|
||||
@ -198,30 +198,30 @@ def test_missing_pubkey(client):
|
||||
client, parse_path("48h/0h/1h/0h/0"), coin_name="Bitcoin"
|
||||
).node
|
||||
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node, address_n=[1]),
|
||||
proto.HDNodePathType(node=node, address_n=[2]),
|
||||
proto.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
# Let's go to sign with key 10, which is NOT in pubkeys
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("48h/0h/1h/0h/0/10"),
|
||||
amount=100000,
|
||||
prev_hash=TXHASH_c6091a,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss",
|
||||
amount=100000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with pytest.raises(TrezorFailure) as exc:
|
||||
@ -245,19 +245,19 @@ def test_attack_change_input(client):
|
||||
"03653a148b68584acb97947344a7d4fd6a6f8b8485cad12987ff8edac874268088"
|
||||
)
|
||||
|
||||
input_real = proto.TxInputType(
|
||||
input_real = messages.TxInputType(
|
||||
address_n=address_n,
|
||||
prev_hash=TXHASH_fbbff7,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
amount=1000000,
|
||||
)
|
||||
|
||||
multisig_fake = proto.MultisigRedeemScriptType(
|
||||
multisig_fake = messages.MultisigRedeemScriptType(
|
||||
m=1,
|
||||
nodes=[
|
||||
btc.get_public_node(client, address_n, coin_name="Testnet").node,
|
||||
proto.HDNodeType(
|
||||
messages.HDNodeType(
|
||||
depth=0,
|
||||
fingerprint=0,
|
||||
child_num=0,
|
||||
@ -268,7 +268,7 @@ def test_attack_change_input(client):
|
||||
address_n=[],
|
||||
)
|
||||
|
||||
input_fake = proto.TxInputType(
|
||||
input_fake = messages.TxInputType(
|
||||
address_n=address_n,
|
||||
prev_hash=input_real.prev_hash,
|
||||
prev_index=input_real.prev_index,
|
||||
@ -277,16 +277,16 @@ def test_attack_change_input(client):
|
||||
amount=input_real.amount,
|
||||
)
|
||||
|
||||
output_payee = proto.TxOutputType(
|
||||
output_payee = messages.TxOutputType(
|
||||
address="n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi",
|
||||
amount=1000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
output_change = proto.TxOutputType(
|
||||
output_change = messages.TxOutputType(
|
||||
address_n=address_n,
|
||||
amount=input_real.amount - output_payee.amount - 1000,
|
||||
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
||||
multisig=multisig_fake,
|
||||
)
|
||||
|
||||
@ -301,14 +301,14 @@ def test_attack_change_input(client):
|
||||
return msg
|
||||
|
||||
with client:
|
||||
client.set_filter(proto.TxAck, attack_processor)
|
||||
client.set_filter(messages.TxAck, attack_processor)
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_fbbff7),
|
||||
request_input(0, TXHASH_fbbff7),
|
||||
@ -318,7 +318,7 @@ def test_attack_change_input(client):
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
request_input(0),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
messages.Failure(code=messages.FailureType.ProcessError),
|
||||
]
|
||||
)
|
||||
|
||||
@ -333,5 +333,5 @@ def test_attack_change_input(client):
|
||||
# must not produce this tx:
|
||||
# 01000000000101396e2c107427f9eaece56a37539983adb8efd52b067c3d4567805fc8f3f7bffb01000000171600147a876a07b366f79000b441335f2907f777a0280bffffffff02e8030000000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac703a0f000000000017a914a1261837f1b40e84346b1504ffe294e402965f2687024830450221009ff835e861be4e36ca1f2b6224aee2f253dfb9f456b13e4b1724bb4aaff4c9c802205e10679c2ead85743119f468cba5661f68b7da84dd2d477a7215fef98516f1f9012102af12ddd0d55e4fa2fcd084148eaf5b0b641320d0431d63d1e9a90f3cbd0d540700000000
|
||||
|
||||
assert exc.value.code == proto.FailureType.ProcessError
|
||||
assert exc.value.code == messages.FailureType.ProcessError
|
||||
assert exc.value.message.endswith("Transaction has changed during signing")
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.tools import H_, parse_path
|
||||
|
||||
from .. import bip32
|
||||
@ -24,7 +24,7 @@ from ..common import MNEMONIC12
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Testnet")
|
||||
# NOTE: This test case was migrated from Testnet to Bitcoin, because we
|
||||
# disabled testnet for BIP-45 paths. So we are still using the Testnet TxCache
|
||||
@ -85,21 +85,21 @@ NODE_INT = bip32.deserialize(
|
||||
# tx: b0946dc27ba308a749b11afecc2018980af18f79e89ad6b080b58220d856f739
|
||||
# input 1: 0.555 BTC
|
||||
|
||||
multisig_in1 = proto.MultisigRedeemScriptType(
|
||||
multisig_in1 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT2, NODE_EXT1, NODE_INT],
|
||||
address_n=[0, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
multisig_in2 = proto.MultisigRedeemScriptType(
|
||||
multisig_in2 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT1, NODE_EXT2, NODE_INT],
|
||||
address_n=[0, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
multisig_in3 = proto.MultisigRedeemScriptType(
|
||||
multisig_in3 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT1, NODE_EXT3, NODE_INT],
|
||||
address_n=[0, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
@ -107,32 +107,32 @@ multisig_in3 = proto.MultisigRedeemScriptType(
|
||||
)
|
||||
|
||||
# 2N9W4z9AhAPaHghtqVQPbaTAGHdbrhKeBQw
|
||||
INP1 = proto.TxInputType(
|
||||
INP1 = messages.TxInputType(
|
||||
address_n=[H_(45), 0, 0, 0],
|
||||
amount=50000000,
|
||||
prev_hash=TXHASH_16c6c8,
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig_in1,
|
||||
)
|
||||
|
||||
# 2NDBG6QXQLtnQ3jRGkrqo53BiCeXfQXLdj4
|
||||
INP2 = proto.TxInputType(
|
||||
INP2 = messages.TxInputType(
|
||||
address_n=[H_(45), 0, 0, 1],
|
||||
amount=34500000,
|
||||
prev_hash=TXHASH_d80c34,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig_in2,
|
||||
)
|
||||
|
||||
# 2MvwPWfp2XPU3S1cMwgEMKBPUw38VP5SBE4
|
||||
INP3 = proto.TxInputType(
|
||||
INP3 = messages.TxInputType(
|
||||
address_n=[H_(45), 0, 0, 1],
|
||||
amount=55500000,
|
||||
prev_hash=TXHASH_b0946d,
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig_in3,
|
||||
)
|
||||
|
||||
@ -143,12 +143,12 @@ def _responses(INP1, INP2, change=0):
|
||||
request_output(0),
|
||||
]
|
||||
if change != 1:
|
||||
resp.append(proto.ButtonRequest(code=B.ConfirmOutput))
|
||||
resp.append(messages.ButtonRequest(code=B.ConfirmOutput))
|
||||
resp.append(request_output(1))
|
||||
if change != 2:
|
||||
resp.append(proto.ButtonRequest(code=B.ConfirmOutput))
|
||||
resp.append(messages.ButtonRequest(code=B.ConfirmOutput))
|
||||
resp += [
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(INP1.prev_hash),
|
||||
request_input(0, INP1.prev_hash),
|
||||
@ -176,16 +176,16 @@ def _responses(INP1, INP2, change=0):
|
||||
|
||||
# both outputs are external
|
||||
def test_external_external(client):
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="1F8yBZB2NZhPZvJekhjTwjhQRRvQeTjjXr",
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="1H7uXJQTVwXca2BXF2opTrvuZapk8Cm8zY",
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -206,16 +206,16 @@ def test_external_external(client):
|
||||
|
||||
# first external, second internal
|
||||
def test_external_internal(client):
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="1F8yBZB2NZhPZvJekhjTwjhQRRvQeTjjXr",
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("45'/0/1/1"),
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -238,16 +238,16 @@ def test_external_internal(client):
|
||||
|
||||
# first internal, second external
|
||||
def test_internal_external(client):
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("45'/0/1/0"),
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="1H7uXJQTVwXca2BXF2opTrvuZapk8Cm8zY",
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -270,16 +270,16 @@ def test_internal_external(client):
|
||||
|
||||
# both outputs are external
|
||||
def test_multisig_external_external(client):
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="3B23k4kFBRtu49zvpG3Z9xuFzfpHvxBcwt",
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="3PkXLsY7AUZCrCKGvX8FfP2EawowUBMbcg",
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -300,24 +300,24 @@ def test_multisig_external_external(client):
|
||||
|
||||
# inputs match, change matches (first is change)
|
||||
def test_multisig_change_match_first(client):
|
||||
multisig_out1 = proto.MultisigRedeemScriptType(
|
||||
multisig_out1 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT2, NODE_EXT1, NODE_INT],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=[H_(45), 0, 1, 0],
|
||||
multisig=multisig_out1,
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="3PkXLsY7AUZCrCKGvX8FfP2EawowUBMbcg",
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -340,24 +340,24 @@ def test_multisig_change_match_first(client):
|
||||
|
||||
# inputs match, change matches (second is change)
|
||||
def test_multisig_change_match_second(client):
|
||||
multisig_out2 = proto.MultisigRedeemScriptType(
|
||||
multisig_out2 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT1, NODE_EXT2, NODE_INT],
|
||||
address_n=[1, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="3B23k4kFBRtu49zvpG3Z9xuFzfpHvxBcwt",
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=[H_(45), 0, 1, 1],
|
||||
multisig=multisig_out2,
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -380,24 +380,24 @@ def test_multisig_change_match_second(client):
|
||||
|
||||
# inputs match, change mismatches (second tries to be change but isn't)
|
||||
def test_multisig_mismatch_change(client):
|
||||
multisig_out2 = proto.MultisigRedeemScriptType(
|
||||
multisig_out2 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT1, NODE_INT, NODE_EXT3],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="3B23k4kFBRtu49zvpG3Z9xuFzfpHvxBcwt",
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=[H_(45), 0, 1, 0],
|
||||
multisig=multisig_out2,
|
||||
amount=44000000,
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -418,24 +418,24 @@ def test_multisig_mismatch_change(client):
|
||||
|
||||
# inputs mismatch, change matches with first input
|
||||
def test_multisig_mismatch_inputs(client):
|
||||
multisig_out1 = proto.MultisigRedeemScriptType(
|
||||
multisig_out1 = messages.MultisigRedeemScriptType(
|
||||
nodes=[NODE_EXT2, NODE_EXT1, NODE_INT],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=[H_(45), 0, 1, 0],
|
||||
multisig=multisig_out1,
|
||||
amount=40000000,
|
||||
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||
script_type=messages.OutputScriptType.PAYTOMULTISIG,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
address="3PkXLsY7AUZCrCKGvX8FfP2EawowUBMbcg",
|
||||
amount=65000000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with client:
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages as proto
|
||||
from trezorlib import btc, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from ..tx_cache import TxCache
|
||||
from .signtx import request_finished, request_input, request_meta, request_output
|
||||
|
||||
B = proto.ButtonRequestType
|
||||
B = messages.ButtonRequestType
|
||||
TX_API = TxCache("Bitcoin")
|
||||
|
||||
TXHASH_d5f65e = bytes.fromhex(
|
||||
@ -32,23 +32,23 @@ TXHASH_d5f65e = bytes.fromhex(
|
||||
|
||||
|
||||
def test_opreturn(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/0'/0'/0/2"),
|
||||
amount=390000,
|
||||
prev_hash=TXHASH_d5f65e,
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address="1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",
|
||||
amount=390000 - 10000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
out2 = proto.TxOutputType(
|
||||
out2 = messages.TxOutputType(
|
||||
op_return_data=b"test of the op_return data",
|
||||
amount=0,
|
||||
script_type=proto.OutputScriptType.PAYTOOPRETURN,
|
||||
script_type=messages.OutputScriptType.PAYTOOPRETURN,
|
||||
)
|
||||
|
||||
with client:
|
||||
@ -56,10 +56,10 @@ def test_opreturn(client):
|
||||
[
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_d5f65e),
|
||||
request_input(0, TXHASH_d5f65e),
|
||||
@ -84,22 +84,22 @@ def test_opreturn(client):
|
||||
|
||||
|
||||
def test_nonzero_opreturn(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/0'/10'/0/5"),
|
||||
amount=390000,
|
||||
prev_hash=TXHASH_d5f65e,
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
op_return_data=b"test of the op_return data",
|
||||
amount=10000,
|
||||
script_type=proto.OutputScriptType.PAYTOOPRETURN,
|
||||
script_type=messages.OutputScriptType.PAYTOOPRETURN,
|
||||
)
|
||||
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[request_input(0), request_output(0), proto.Failure()]
|
||||
[request_input(0), request_output(0), messages.Failure()]
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
@ -109,23 +109,23 @@ def test_nonzero_opreturn(client):
|
||||
|
||||
|
||||
def test_opreturn_address(client):
|
||||
inp1 = proto.TxInputType(
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("44'/0'/0'/0/2"),
|
||||
amount=390000,
|
||||
prev_hash=TXHASH_d5f65e,
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
out1 = messages.TxOutputType(
|
||||
address_n=parse_path("44'/0'/0'/1/2"),
|
||||
amount=0,
|
||||
op_return_data=b"OMNI TRANSACTION GOES HERE",
|
||||
script_type=proto.OutputScriptType.PAYTOOPRETURN,
|
||||
script_type=messages.OutputScriptType.PAYTOOPRETURN,
|
||||
)
|
||||
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[request_input(0), request_output(0), proto.Failure()]
|
||||
[request_input(0), request_output(0), messages.Failure()]
|
||||
)
|
||||
with pytest.raises(
|
||||
TrezorFailure, match="Output's address_n provided but not expected."
|
||||
|
Loading…
Reference in New Issue
Block a user