mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-25 17:32:34 +00:00
fix style to match flake8
This commit is contained in:
parent
200b5a71df
commit
5fccc4381b
@ -975,6 +975,7 @@ def stellar_get_address(connect, address):
|
|||||||
response = client.stellar_get_public_key(address_n)
|
response = client.stellar_get_public_key(address_n)
|
||||||
return stellar.address_from_public_key(response.public_key)
|
return stellar.address_from_public_key(response.public_key)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help='Sign a string with a Stellar key')
|
@cli.command(help='Sign a string with a Stellar key')
|
||||||
@click.option('-n', '--address', required=False, help="BIP32 path. Default primary account is m/44'/148'/0'. Always use hardened paths and the m/44'/148'/ prefix")
|
@click.option('-n', '--address', required=False, help="BIP32 path. Default primary account is m/44'/148'/0'. Always use hardened paths and the m/44'/148'/ prefix")
|
||||||
@click.argument('message')
|
@click.argument('message')
|
||||||
@ -985,6 +986,7 @@ def stellar_sign_message(connect, address, message):
|
|||||||
response = client.stellar_sign_message(address_n, message)
|
response = client.stellar_sign_message(address_n, message)
|
||||||
return base64.b64encode(response.signature)
|
return base64.b64encode(response.signature)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help='Verify that a signature is valid')
|
@cli.command(help='Verify that a signature is valid')
|
||||||
@click.option('--message-is-b64/--no-message-is-b64', default=False, required=False, help="If set, the message argument will be interpreted as a base64-encoded string")
|
@click.option('--message-is-b64/--no-message-is-b64', default=False, required=False, help="If set, the message argument will be interpreted as a base64-encoded string")
|
||||||
@click.argument('address')
|
@click.argument('address')
|
||||||
@ -1008,6 +1010,7 @@ def stellar_verify_message(connect, address, message_is_b64, signatureb64, messa
|
|||||||
print("ERROR: invalid signature, verification failed")
|
print("ERROR: invalid signature, verification failed")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help='Sign a base64-encoded transaction envelope')
|
@cli.command(help='Sign a base64-encoded transaction envelope')
|
||||||
@click.option('-n', '--address', required=False, help="BIP32 path. Default primary account is m/44'/148'/0'. Always use hardened paths and the m/44'/148'/ prefix")
|
@click.option('-n', '--address', required=False, help="BIP32 path. Default primary account is m/44'/148'/0'. Always use hardened paths and the m/44'/148'/ prefix")
|
||||||
@click.option('-n', '--network-passphrase', required=False, help="Network passphrase (blank for public network). Testnet is: 'Test SDF Network ; September 2015'")
|
@click.option('-n', '--network-passphrase', required=False, help="Network passphrase (blank for public network). Testnet is: 'Test SDF Network ; September 2015'")
|
||||||
|
@ -29,6 +29,7 @@ OP_INFLATION = 9 # Included for documentation purposes, not supported
|
|||||||
OP_MANAGE_DATA = 10
|
OP_MANAGE_DATA = 10
|
||||||
OP_BUMP_SEQUENCE = 11
|
OP_BUMP_SEQUENCE = 11
|
||||||
|
|
||||||
|
|
||||||
def expand_path_or_default(client, address):
|
def expand_path_or_default(client, address):
|
||||||
"""Uses client to parse address and returns an array of integers
|
"""Uses client to parse address and returns an array of integers
|
||||||
If no address is specified, the default of m/44'/148'/0' is used
|
If no address is specified, the default of m/44'/148'/0' is used
|
||||||
@ -53,6 +54,7 @@ def address_from_public_key(pk_bytes):
|
|||||||
|
|
||||||
return base64.b32encode(final_bytes)
|
return base64.b32encode(final_bytes)
|
||||||
|
|
||||||
|
|
||||||
def address_to_public_key(address_str):
|
def address_to_public_key(address_str):
|
||||||
"""Returns the raw 32 bytes representing a public key by extracting
|
"""Returns the raw 32 bytes representing a public key by extracting
|
||||||
it from the G... string
|
it from the G... string
|
||||||
@ -79,7 +81,7 @@ def parse_transaction_bytes(tx_bytes):
|
|||||||
|
|
||||||
# Timebounds is an optional field
|
# Timebounds is an optional field
|
||||||
if unpacker.unpack_bool():
|
if unpacker.unpack_bool():
|
||||||
max_timebound = 2**32-1 # max unsigned 32-bit int (trezor does not support the full 64-bit time value)
|
max_timebound = 2**32 - 1 # max unsigned 32-bit int (trezor does not support the full 64-bit time value)
|
||||||
tx.timebounds_start = unpacker.unpack_uhyper()
|
tx.timebounds_start = unpacker.unpack_uhyper()
|
||||||
tx.timebounds_end = unpacker.unpack_uhyper()
|
tx.timebounds_end = unpacker.unpack_uhyper()
|
||||||
|
|
||||||
@ -109,6 +111,7 @@ def parse_transaction_bytes(tx_bytes):
|
|||||||
|
|
||||||
return tx, operations
|
return tx, operations
|
||||||
|
|
||||||
|
|
||||||
def _parse_operation_bytes(unpacker):
|
def _parse_operation_bytes(unpacker):
|
||||||
"""Returns a protobuf message representing the next operation as read from
|
"""Returns a protobuf message representing the next operation as read from
|
||||||
the byte stream in unpacker
|
the byte stream in unpacker
|
||||||
@ -272,6 +275,7 @@ def _parse_operation_bytes(unpacker):
|
|||||||
|
|
||||||
raise ValueError("Unknown operation type: " + type)
|
raise ValueError("Unknown operation type: " + type)
|
||||||
|
|
||||||
|
|
||||||
def _xdr_read_asset(unpacker):
|
def _xdr_read_asset(unpacker):
|
||||||
"""Reads a stellar Asset from unpacker"""
|
"""Reads a stellar Asset from unpacker"""
|
||||||
asset = proto.StellarAssetType(
|
asset = proto.StellarAssetType(
|
||||||
@ -300,6 +304,7 @@ def _xdr_read_address(unpacker):
|
|||||||
|
|
||||||
return unpacker.unpack_fopaque(32)
|
return unpacker.unpack_fopaque(32)
|
||||||
|
|
||||||
|
|
||||||
def _crc16_checksum(bytes):
|
def _crc16_checksum(bytes):
|
||||||
"""Returns the CRC-16 checksum of bytearray bytes
|
"""Returns the CRC-16 checksum of bytearray bytes
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
from .common import TrezorTest
|
from .common import TrezorTest
|
||||||
from trezorlib import stellar
|
from trezorlib import stellar
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail # requires trezor-mcu PR #259
|
@pytest.mark.xfail # requires trezor-mcu PR #259
|
||||||
class TestMsgStellarGetPublicKey(TrezorTest):
|
class TestMsgStellarGetPublicKey(TrezorTest):
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
from .common import TrezorTest
|
from .common import TrezorTest
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail # requires trezor-mcu PR #259
|
@pytest.mark.xfail # requires trezor-mcu PR #259
|
||||||
class TestMsgStellarSignTransaction(TrezorTest):
|
class TestMsgStellarSignTransaction(TrezorTest):
|
||||||
|
|
||||||
@ -39,7 +40,6 @@ class TestMsgStellarSignTransaction(TrezorTest):
|
|||||||
response = self.client.stellar_sign_transaction(xdr, self.get_address_n(), self.get_network_passphrase())
|
response = self.client.stellar_sign_transaction(xdr, self.get_address_n(), self.get_network_passphrase())
|
||||||
assert b64encode(response.signature) == b'UAOL4ZPYIOzEgM66kBrhyNjLR66dNXtuNrmvd3m0/pc8qCSoLmYY4TybS0lHiMtb+LFZESTaxrpErMHz1sZ6DQ=='
|
assert b64encode(response.signature) == b'UAOL4ZPYIOzEgM66kBrhyNjLR66dNXtuNrmvd3m0/pc8qCSoLmYY4TybS0lHiMtb+LFZESTaxrpErMHz1sZ6DQ=='
|
||||||
|
|
||||||
|
|
||||||
def test_sign_tx_account_merge_op(self):
|
def test_sign_tx_account_merge_op(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user