python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
import base64
|
|
|
|
|
|
|
|
import click
|
|
|
|
|
|
|
|
from .. import stellar, tools
|
2020-03-24 15:02:48 +00:00
|
|
|
from . import with_client
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
|
|
|
|
PATH_HELP = "BIP32 path. Always use hardened paths and the m/44'/148'/ prefix"
|
|
|
|
|
|
|
|
|
|
|
|
@click.group(name="stellar")
|
|
|
|
def cli():
|
|
|
|
"""Stellar commands."""
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@click.option(
|
|
|
|
"-n",
|
|
|
|
"--address",
|
|
|
|
required=False,
|
|
|
|
help=PATH_HELP,
|
|
|
|
default=stellar.DEFAULT_BIP32_PATH,
|
|
|
|
)
|
|
|
|
@click.option("-d", "--show-display", is_flag=True)
|
2020-03-24 15:02:48 +00:00
|
|
|
@with_client
|
|
|
|
def get_address(client, address, show_display):
|
2019-11-15 12:26:24 +00:00
|
|
|
"""Get Stellar public address."""
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
address_n = tools.parse_path(address)
|
|
|
|
return stellar.get_address(client, address_n, show_display)
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@click.option(
|
|
|
|
"-n",
|
|
|
|
"--address",
|
|
|
|
required=False,
|
|
|
|
help=PATH_HELP,
|
|
|
|
default=stellar.DEFAULT_BIP32_PATH,
|
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"-n",
|
|
|
|
"--network-passphrase",
|
|
|
|
default=stellar.DEFAULT_NETWORK_PASSPHRASE,
|
|
|
|
required=False,
|
|
|
|
help="Network passphrase (blank for public network).",
|
|
|
|
)
|
|
|
|
@click.argument("b64envelope")
|
2020-03-24 15:02:48 +00:00
|
|
|
@with_client
|
|
|
|
def sign_transaction(client, b64envelope, address, network_passphrase):
|
2019-11-15 12:26:24 +00:00
|
|
|
"""Sign a base64-encoded transaction envelope.
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
|
|
|
|
For testnet transactions, use the following network passphrase:
|
|
|
|
'Test SDF Network ; September 2015'
|
|
|
|
"""
|
|
|
|
address_n = tools.parse_path(address)
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64envelope))
|
|
|
|
resp = stellar.sign_tx(client, tx, operations, address_n, network_passphrase)
|
|
|
|
|
|
|
|
return base64.b64encode(resp.signature)
|