mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +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)
|
||||
return stellar.address_from_public_key(response.public_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.argument('message')
|
||||
@ -985,6 +986,7 @@ def stellar_sign_message(connect, address, message):
|
||||
response = client.stellar_sign_message(address_n, message)
|
||||
return base64.b64encode(response.signature)
|
||||
|
||||
|
||||
@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.argument('address')
|
||||
@ -1008,6 +1010,7 @@ def stellar_verify_message(connect, address, message_is_b64, signatureb64, messa
|
||||
print("ERROR: invalid signature, verification failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@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', '--network-passphrase', required=False, help="Network passphrase (blank for public network). Testnet is: 'Test SDF Network ; September 2015'")
|
||||
|
@ -5,29 +5,30 @@ import xdrlib
|
||||
from . import messages as proto
|
||||
|
||||
# Memo types
|
||||
MEMO_TYPE_TEXT = 0
|
||||
MEMO_TYPE_ID = 1
|
||||
MEMO_TYPE_HASH = 2
|
||||
MEMO_TYPE_TEXT = 0
|
||||
MEMO_TYPE_ID = 1
|
||||
MEMO_TYPE_HASH = 2
|
||||
MEMO_TYPE_RETURN = 4
|
||||
|
||||
# Asset types
|
||||
ASSET_TYPE_NATIVE = 0
|
||||
ASSET_TYPE_ALPHA4 = 1
|
||||
ASSET_TYPE_NATIVE = 0
|
||||
ASSET_TYPE_ALPHA4 = 1
|
||||
ASSET_TYPE_ALPHA12 = 2
|
||||
|
||||
# Operations
|
||||
OP_CREATE_ACCOUNT = 0
|
||||
OP_PAYMENT = 1
|
||||
OP_PATH_PAYMENT = 2
|
||||
OP_MANAGE_OFFER = 3
|
||||
OP_CREATE_ACCOUNT = 0
|
||||
OP_PAYMENT = 1
|
||||
OP_PATH_PAYMENT = 2
|
||||
OP_MANAGE_OFFER = 3
|
||||
OP_CREATE_PASSIVE_OFFER = 4
|
||||
OP_SET_OPTIONS = 5
|
||||
OP_CHANGE_TRUST = 6
|
||||
OP_ALLOW_TRUST = 7
|
||||
OP_ACCOUNT_MERGE = 8
|
||||
OP_INFLATION = 9 # Included for documentation purposes, not supported by Trezor
|
||||
OP_MANAGE_DATA = 10
|
||||
OP_BUMP_SEQUENCE = 11
|
||||
OP_SET_OPTIONS = 5
|
||||
OP_CHANGE_TRUST = 6
|
||||
OP_ALLOW_TRUST = 7
|
||||
OP_ACCOUNT_MERGE = 8
|
||||
OP_INFLATION = 9 # Included for documentation purposes, not supported by Trezor
|
||||
OP_MANAGE_DATA = 10
|
||||
OP_BUMP_SEQUENCE = 11
|
||||
|
||||
|
||||
def expand_path_or_default(client, address):
|
||||
"""Uses client to parse address and returns an array of integers
|
||||
@ -53,6 +54,7 @@ def address_from_public_key(pk_bytes):
|
||||
|
||||
return base64.b32encode(final_bytes)
|
||||
|
||||
|
||||
def address_to_public_key(address_str):
|
||||
"""Returns the raw 32 bytes representing a public key by extracting
|
||||
it from the G... string
|
||||
@ -79,7 +81,7 @@ def parse_transaction_bytes(tx_bytes):
|
||||
|
||||
# Timebounds is an optional field
|
||||
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_end = unpacker.unpack_uhyper()
|
||||
|
||||
@ -109,6 +111,7 @@ def parse_transaction_bytes(tx_bytes):
|
||||
|
||||
return tx, operations
|
||||
|
||||
|
||||
def _parse_operation_bytes(unpacker):
|
||||
"""Returns a protobuf message representing the next operation as read from
|
||||
the byte stream in unpacker
|
||||
@ -272,6 +275,7 @@ def _parse_operation_bytes(unpacker):
|
||||
|
||||
raise ValueError("Unknown operation type: " + type)
|
||||
|
||||
|
||||
def _xdr_read_asset(unpacker):
|
||||
"""Reads a stellar Asset from unpacker"""
|
||||
asset = proto.StellarAssetType(
|
||||
@ -300,6 +304,7 @@ def _xdr_read_address(unpacker):
|
||||
|
||||
return unpacker.unpack_fopaque(32)
|
||||
|
||||
|
||||
def _crc16_checksum(bytes):
|
||||
"""Returns the CRC-16 checksum of bytearray bytes
|
||||
|
||||
|
@ -16,7 +16,8 @@
|
||||
from .common import TrezorTest
|
||||
from trezorlib import stellar
|
||||
|
||||
@pytest.mark.xfail # requires trezor-mcu PR #259
|
||||
|
||||
@pytest.mark.xfail # requires trezor-mcu PR #259
|
||||
class TestMsgStellarGetPublicKey(TrezorTest):
|
||||
|
||||
def test_stellar_get_address(self):
|
||||
|
@ -20,7 +20,8 @@
|
||||
from base64 import b64decode, b64encode
|
||||
from .common import TrezorTest
|
||||
|
||||
@pytest.mark.xfail # requires trezor-mcu PR #259
|
||||
|
||||
@pytest.mark.xfail # requires trezor-mcu PR #259
|
||||
class TestMsgStellarSignTransaction(TrezorTest):
|
||||
|
||||
def get_network_passphrase(self):
|
||||
@ -39,7 +40,6 @@ class TestMsgStellarSignTransaction(TrezorTest):
|
||||
response = self.client.stellar_sign_transaction(xdr, self.get_address_n(), self.get_network_passphrase())
|
||||
assert b64encode(response.signature) == b'UAOL4ZPYIOzEgM66kBrhyNjLR66dNXtuNrmvd3m0/pc8qCSoLmYY4TybS0lHiMtb+LFZESTaxrpErMHz1sZ6DQ=='
|
||||
|
||||
|
||||
def test_sign_tx_account_merge_op(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user