core: remove remaning utility code for Bitcoin only firmware

pull/446/head
Pavol Rusnak 5 years ago
parent c815bc410c
commit 908bbfffef
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -117,9 +117,9 @@ STATIC mp_obj_t mod_trezorcrypto_secp256k1_sign(size_t n_args,
mp_get_buffer_raise(args[0], &sk, MP_BUFFER_READ);
mp_get_buffer_raise(args[1], &dig, MP_BUFFER_READ);
bool compressed = (n_args < 3) || (args[2] == mp_const_true);
int (*is_canonical)(uint8_t by, uint8_t sig[64]) = NULL;
#if !BITCOIN_ONLY
mp_int_t canonical = (n_args > 3) ? mp_obj_get_int(args[3]) : 0;
int (*is_canonical)(uint8_t by, uint8_t sig[64]) = NULL;
switch (canonical) {
case CANONICAL_SIG_ETHEREUM:
is_canonical = ethereum_is_canonical;

@ -1,10 +1,14 @@
# Automatically generated by pb2py
# fmt: off
from trezor import utils
Bitcoin = 1
if not utils.BITCOIN_ONLY:
Bitcoin_like = 2
Binance = 3
Cardano = 4
Crypto = 5
if not utils.BITCOIN_ONLY:
EOS = 6
Ethereum = 7
Lisk = 8

@ -1,5 +1,7 @@
# Automatically generated by pb2py
# fmt: off
from trezor import utils
Initialize = 0
Ping = 1
Success = 2
@ -64,6 +66,7 @@ DebugLinkMemoryRead = 110
DebugLinkMemory = 111
DebugLinkMemoryWrite = 112
DebugLinkFlashErase = 113
if not utils.BITCOIN_ONLY:
EthereumGetPublicKey = 450
EthereumPublicKey = 451
EthereumGetAddress = 56

@ -41,4 +41,6 @@ for msg_name in dir(MessageType):
# No Message begins with underscore so it's safe to skip those.
if msg_name[0] == "_":
continue
if msg_name == "utils": # skip imported trezor.utils
continue
type_to_name[getattr(MessageType, msg_name)] = msg_name

@ -57,6 +57,8 @@ do_rebuild() {
shift
local IGNORE="$1"
shift
local APPLY_BITCOIN_ONLY="$1"
shift
mkdir -p "$DESTDIR"
rm -f "$DESTDIR"/[A-Z]*.py
@ -64,6 +66,24 @@ do_rebuild() {
# note $SOURCES is unquoted - we want wildcard expansion and multiple args
$PROTOB/pb2py "$@" -o "$DESTDIR" $SOURCES
# TODO: make this less hackish
# maybe introduce attribute "altcoin" in protobuf?
if [ "$APPLY_BITCOIN_ONLY" == "TRUE" ]; then
sed -i "3ifrom trezor import utils\n" "$DESTDIR"/Feature.py
sed -i "3ifrom trezor import utils\n" "$DESTDIR"/MessageType.py
sed -i "/^EthereumGetPublicKey/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/MessageType.py
for altcoin in Ethereum NEM Lisk Tezos Stellar Cardano Ripple Monero DebugMonero Eos Binance; do
sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/Feature.py
sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/MessageType.py
done
sed -i "/^Bitcoin_like/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Feature.py
sed -i "/^EOS/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Feature.py
for feature in Bitcoin_like EOS U2F; do
sed -i "s:^$feature: $feature:" "$DESTDIR"/Feature.py
done
fi
# ENDTODO
# delete unused messages
for F in $IGNORE; do
rm -f "$DESTDIR"/"$F".py
@ -92,7 +112,7 @@ else
func=do_rebuild
fi
$func core/src/trezor/messages "$CORE_PROTOBUF_SOURCES" "$CORE_MESSAGES_IGNORE" --no-init-py
$func python/src/trezorlib/messages "$PYTHON_PROTOBUF_SOURCES" "$PYTHON_MESSAGES_IGNORE" -P ..protobuf
$func core/src/trezor/messages "$CORE_PROTOBUF_SOURCES" "$CORE_MESSAGES_IGNORE" TRUE --no-init-py
$func python/src/trezorlib/messages "$PYTHON_PROTOBUF_SOURCES" "$PYTHON_MESSAGES_IGNORE" FALSE -P ..protobuf
exit $RETURN

Loading…
Cancel
Save