Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,26 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Install clang-format
run: sudo apt-get install -y clang-format-14

- name: Check code formatting
run: |
# Use pre-installed clang-format (ubuntu-latest ships with it)
CF=$(command -v clang-format-14 || command -v clang-format || true)
if [ -z "$CF" ]; then
echo "::warning::clang-format not found, skipping lint"
exit 0
fi
echo "Using: $CF ($($CF --version | head -1))"
FAILED=0
for f in $(find include/keepkey lib/firmware lib/board lib/transport/src \
-name '*.c' -o -name '*.h' 2>/dev/null | grep -v generated | grep -v '.pb.'); do
if ! clang-format-14 --style=file --dry-run --Werror "$f" 2>/dev/null; then
if ! $CF --style=file --dry-run --Werror "$f" 2>/dev/null; then
echo "::warning file=$f::Formatting differs from .clang-format"
FAILED=1
fi
done
if [ "$FAILED" = "1" ]; then
echo ""
echo "Run: clang-format -i <file> to fix formatting"
echo "Run: $CF -i <file> to fix formatting"
echo "Note: treating as warning until codebase is reformatted"
fi
# Warn-only until existing code is reformatted
Expand Down
17 changes: 17 additions & 0 deletions include/keepkey/transport/messages-solana.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SolanaGetAddress.address_n max_count:8
SolanaGetAddress.coin_name max_size:21

SolanaAddress.address max_size:64

SolanaSignTx.address_n max_count:8
SolanaSignTx.coin_name max_size:21
SolanaSignTx.raw_tx max_size:2048

SolanaSignedTx.signature max_size:64

SolanaSignMessage.address_n max_count:8
SolanaSignMessage.coin_name max_size:21
SolanaSignMessage.message max_size:1024

SolanaMessageSignature.public_key max_size:32
SolanaMessageSignature.signature max_size:64
12 changes: 12 additions & 0 deletions include/keepkey/transport/messages-ton.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TonGetAddress.address_n max_count:8
TonGetAddress.coin_name max_size:21

TonAddress.address max_size:50
TonAddress.raw_address max_size:70

TonSignTx.address_n max_count:8
TonSignTx.coin_name max_size:21
TonSignTx.raw_tx max_size:1024
TonSignTx.to_address max_size:50

TonSignedTx.signature max_size:64
14 changes: 14 additions & 0 deletions include/keepkey/transport/messages-tron.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TronGetAddress.address_n max_count:8
TronGetAddress.coin_name max_size:21

TronAddress.address max_size:35

TronSignTx.address_n max_count:8
TronSignTx.coin_name max_size:21
TronSignTx.raw_data max_size:2048
TronSignTx.ref_block_bytes max_size:4
TronSignTx.ref_block_hash max_size:32
TronSignTx.contract_type max_size:64
TronSignTx.to_address max_size:35

TronSignedTx.signature max_size:65
2 changes: 2 additions & 0 deletions include/keepkey/transport/messages.options
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ FlashHash.challenge max_size:32
FlashWrite.data max_size:1024

FlashHashResponse.data max_size:32

Bip85Mnemonic.mnemonic max_size:241
2 changes: 1 addition & 1 deletion lib/firmware/signing.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void signing_init(const SignTx *msg, const CoinType *_coin,
branch_id = 0x5BA81B19; // Overwinter
break;
case 4:
branch_id = 0x76B809BB; // Sapling
branch_id = 0xC8E71055; // NU6
break;
}
}
Expand Down
27 changes: 27 additions & 0 deletions lib/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ set(protoc_pb_sources
${DEVICE_PROTOCOL}/messages-tendermint.proto
${DEVICE_PROTOCOL}/messages-thorchain.proto
${DEVICE_PROTOCOL}/messages-mayachain.proto
${DEVICE_PROTOCOL}/messages-solana.proto
${DEVICE_PROTOCOL}/messages-tron.proto
${DEVICE_PROTOCOL}/messages-ton.proto
${DEVICE_PROTOCOL}/messages.proto)

set(protoc_pb_options
Expand All @@ -29,6 +32,9 @@ set(protoc_pb_options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages-tendermint.options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages-thorchain.options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages-mayachain.options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages-solana.options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages-tron.options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages-ton.options
${CMAKE_SOURCE_DIR}/include/keepkey/transport/messages.options)

set(protoc_c_sources
Expand All @@ -43,6 +49,9 @@ set(protoc_c_sources
${CMAKE_BINARY_DIR}/lib/transport/messages-tendermint.pb.c
${CMAKE_BINARY_DIR}/lib/transport/messages-thorchain.pb.c
${CMAKE_BINARY_DIR}/lib/transport/messages-mayachain.pb.c
${CMAKE_BINARY_DIR}/lib/transport/messages-solana.pb.c
${CMAKE_BINARY_DIR}/lib/transport/messages-tron.pb.c
${CMAKE_BINARY_DIR}/lib/transport/messages-ton.pb.c
${CMAKE_BINARY_DIR}/lib/transport/messages.pb.c)

set(protoc_c_headers
Expand All @@ -57,6 +66,9 @@ set(protoc_c_headers
${CMAKE_BINARY_DIR}/include/messages-tendermint.pb.h
${CMAKE_BINARY_DIR}/include/messages-thorchain.pb.h
${CMAKE_BINARY_DIR}/include/messages-mayachain.pb.h
${CMAKE_BINARY_DIR}/include/messages-solana.pb.h
${CMAKE_BINARY_DIR}/include/messages-tron.pb.h
${CMAKE_BINARY_DIR}/include/messages-ton.pb.h
${CMAKE_BINARY_DIR}/include/messages.pb.h)

set(protoc_pb_sources_moved
Expand All @@ -71,6 +83,9 @@ set(protoc_pb_sources_moved
${CMAKE_BINARY_DIR}/lib/transport/messages-tendermint.proto
${CMAKE_BINARY_DIR}/lib/transport/messages-thorchain.proto
${CMAKE_BINARY_DIR}/lib/transport/messages-mayachain.proto
${CMAKE_BINARY_DIR}/lib/transport/messages-solana.proto
${CMAKE_BINARY_DIR}/lib/transport/messages-tron.proto
${CMAKE_BINARY_DIR}/lib/transport/messages-ton.proto
${CMAKE_BINARY_DIR}/lib/transport/messages.proto)

add_custom_command(
Expand Down Expand Up @@ -136,6 +151,18 @@ add_custom_command(
${PROTOC_BINARY} -I. -I/usr/include
--plugin=nanopb=${NANOPB_DIR}/generator/protoc-gen-nanopb
"--nanopb_out=-f messages-mayachain.options:." messages-mayachain.proto
COMMAND
${PROTOC_BINARY} -I. -I/usr/include
--plugin=nanopb=${NANOPB_DIR}/generator/protoc-gen-nanopb
"--nanopb_out=-f messages-solana.options:." messages-solana.proto
COMMAND
${PROTOC_BINARY} -I. -I/usr/include
--plugin=nanopb=${NANOPB_DIR}/generator/protoc-gen-nanopb
"--nanopb_out=-f messages-tron.options:." messages-tron.proto
COMMAND
${PROTOC_BINARY} -I. -I/usr/include
--plugin=nanopb=${NANOPB_DIR}/generator/protoc-gen-nanopb
"--nanopb_out=-f messages-ton.options:." messages-ton.proto
COMMAND
${PROTOC_BINARY} -I. -I/usr/include
--plugin=nanopb=${NANOPB_DIR}/generator/protoc-gen-nanopb
Expand Down
Loading