2019-09-05 10:24:21 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
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
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2019-09-05 10:24:21 +00:00
|
|
|
#
|
|
|
|
# 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>.
|
|
|
|
|
2019-11-13 16:47:03 +00:00
|
|
|
from . import messages
|
2019-09-05 10:24:21 +00:00
|
|
|
from .tools import expect
|
|
|
|
|
|
|
|
|
2019-11-13 16:47:03 +00:00
|
|
|
@expect(messages.WebAuthnCredentials, field="credentials")
|
2019-09-05 10:24:21 +00:00
|
|
|
def list_credentials(client):
|
2019-11-13 16:47:03 +00:00
|
|
|
return client.call(messages.WebAuthnListResidentCredentials())
|
2019-09-05 10:24:21 +00:00
|
|
|
|
|
|
|
|
2019-11-13 16:47:03 +00:00
|
|
|
@expect(messages.Success, field="message")
|
2019-09-05 10:24:21 +00:00
|
|
|
def add_credential(client, credential_id):
|
2019-11-13 16:47:03 +00:00
|
|
|
return client.call(messages.WebAuthnAddResidentCredential(credential_id))
|
2019-09-05 10:24:21 +00:00
|
|
|
|
|
|
|
|
2019-11-13 16:47:03 +00:00
|
|
|
@expect(messages.Success, field="message")
|
2019-09-05 10:24:21 +00:00
|
|
|
def remove_credential(client, index):
|
2019-11-13 16:47:03 +00:00
|
|
|
return client.call(messages.WebAuthnRemoveResidentCredential(index))
|
|
|
|
|
|
|
|
|
|
|
|
@expect(messages.Success, field="message")
|
|
|
|
def set_counter(client, u2f_counter):
|
|
|
|
return client.call(messages.SetU2FCounter(u2f_counter=u2f_counter))
|
|
|
|
|
|
|
|
|
|
|
|
@expect(messages.NextU2FCounter, field="u2f_counter")
|
|
|
|
def get_next_counter(client):
|
|
|
|
return client.call(messages.GetNextU2FCounter())
|