Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sgliner-ledger committed Mar 20, 2024
1 parent ff1b946 commit e796a1a
Show file tree
Hide file tree
Showing 53 changed files with 173 additions and 51 deletions.
78 changes: 27 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# You may obtain a copy of the License at #
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Expand All @@ -15,57 +14,17 @@
# limitations under the License.
# ****************************************************************************

ifeq ($(BOLOS_SDK),)
$(error Environment variable BOLOS_SDK is not set)
endif
include $(BOLOS_SDK)/Makefile.defines

########################################
# Mandatory configuration #
########################################
# Name is defined later

# Application version
APPVERSION_M = 2
APPVERSION_N = 1
APPVERSION_P = 7
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# Application source files
APP_SOURCE_PATH += src
APP_SOURCE_PATH += bitcoin_common

ICON_NANOS = icons/nanos_app_$(COIN).gif
ICON_NANOX = icons/nanox_app_$(COIN).gif
ICON_NANOSP = icons/nanox_app_$(COIN).gif
ICON_STAX = icons/stax_app_$(COIN).gif

# Application allowed derivation curves.
CURVE_APP_LOAD_PARAMS = secp256k1

# Application allowed derivation paths.
ifeq ($(COIN),$(filter $(COIN), hydra_testnet hydra))
PATH_APP_LOAD_PARAMS = "44'/609'"
else
PATH_APP_LOAD_PARAMS = ""
endif

HAVE_APPLICATION_FLAG_DERIVE_MASTER = 1
HAVE_APPLICATION_FLAG_LIBRARY = 1

VARIANT_PARAM = COIN

VARIANT_VALUES = bitcoin_testnet_legacy bitcoin_legacy

ENABLE_BLUETOOTH = 1
ENABLE_NBGL_QRCODE = 1
ENABLE_SWAP = 1

ifeq ($(TARGET_NAME),TARGET_STAX)
DEFINES += COIN_ICON=C_$(COIN)_64px
DEFINES += COIN_ICON_BITMAP=C_$(COIN)_64px_bitmap
endif

# simplify for tests
ifndef COIN
COIN=bitcoin_legacy
Expand All @@ -75,17 +34,34 @@ endif
#DEBUG = 1

ifeq ($(COIN),bitcoin_testnet_legacy)
# Bitcoin testnet
DEFINES += BIP44_COIN_TYPE=1 BIP44_COIN_TYPE_2=1 COIN_P2PKH_VERSION=111 COIN_P2SH_VERSION=196 COIN_FAMILY=1 COIN_COINID=\"Bitcoin\" COIN_COINID_HEADER=\"BITCOIN\" COIN_COINID_NAME=\"Bitcoin\" COIN_COINID_SHORT=\"TEST\" COIN_NATIVE_SEGWIT_PREFIX=\"tb\" COIN_KIND=COIN_KIND_BITCOIN_TESTNET COIN_FLAGS=FLAG_SEGWIT_CHANGE_SUPPORT
BIP44_COIN_TYPE=1
BIP44_COIN_TYPE_2=1
COIN_P2PKH_VERSION=111
COIN_P2SH_VERSION=196
COIN_FAMILY=1
COIN_COINID=\"Bitcoin\"
COIN_COINID_HEADER=\"BITCOIN\"
COIN_COINID_NAME=\"Bitcoin\"
COIN_COINID_SHORT=\"TEST\"
COIN_NATIVE_SEGWIT_PREFIX=\"tb\"
COIN_KIND=COIN_KIND_BITCOIN_TESTNET
COIN_FLAGS=FLAG_SEGWIT_CHANGE_SUPPORT
APPNAME ="Bitcoin Test Legacy"

else ifeq ($(COIN),bitcoin_legacy)
# Bitcoin mainnet
DEFINES += BIP44_COIN_TYPE=0 BIP44_COIN_TYPE_2=0 COIN_P2PKH_VERSION=0 COIN_P2SH_VERSION=5 COIN_FAMILY=1 COIN_COINID=\"Bitcoin\" COIN_COINID_HEADER=\"BITCOIN\" COIN_COINID_NAME=\"Bitcoin\" COIN_COINID_SHORT=\"BTC\" COIN_NATIVE_SEGWIT_PREFIX=\"bc\" COIN_KIND=COIN_KIND_BITCOIN COIN_FLAGS=FLAG_SEGWIT_CHANGE_SUPPORT
BIP44_COIN_TYPE=0
BIP44_COIN_TYPE_2=0
COIN_P2PKH_VERSION=0
COIN_P2SH_VERSION=5
COIN_FAMILY=1
COIN_COINID=\"Bitcoin\"
COIN_COINID_HEADER=\"BITCOIN\"
COIN_COINID_NAME=\"Bitcoin\"
COIN_COINID_SHORT=\"BTC\"
COIN_NATIVE_SEGWIT_PREFIX=\"bc\"
COIN_KIND=COIN_KIND_BITCOIN
COIN_FLAGS=FLAG_SEGWIT_CHANGE_SUPPORT
APPNAME ="Bitcoin Legacy"
else
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error Unsupported COIN - use bitcoin_testnet, bitcoin)
endif
endif

include $(BOLOS_SDK)/Makefile.standard_app
include core/Makefile
146 changes: 146 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# ****************************************************************************
# Ledger App Bitcoin
# (c) 2023 Ledger SAS.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ****************************************************************************

ifeq ($(BOLOS_SDK),)
$(error Environment variable BOLOS_SDK is not set)
endif
include $(BOLOS_SDK)/Makefile.defines

########################################
# Mandatory configuration #
########################################
# Name is defined later

ifeq ($(APPVERSION_M),)
$(error APPVERSION_M must be defined)
endif
ifeq ($(APPVERSION_N),)
$(error APPVERSION_N must be defined)
endif
ifeq ($(APPVERSION_P),)
$(error APPVERSION_P must be defined)
endif

APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# Application source files
APP_SOURCE_PATH += core/src/
APP_SOURCE_PATH += core/include/
APP_SOURCE_PATH += core/bitcoin_common/

ICON_NANOS = icons/nanos_app_$(COIN).gif
ICON_NANOX = icons/nanox_app_$(COIN).gif
ICON_NANOSP = icons/nanox_app_$(COIN).gif
ICON_STAX = icons/stax_app_$(COIN).gif

ifeq ($(TARGET_NAME),TARGET_STAX)
DEFINES += COIN_ICON=C_$(COIN)_64px
DEFINES += COIN_ICON_BITMAP=C_$(COIN)_64px_bitmap
endif

# Application allowed derivation curves.
CURVE_APP_LOAD_PARAMS = secp256k1

# Application allowed derivation paths.
PATH_APP_LOAD_PARAMS = ""

HAVE_APPLICATION_FLAG_DERIVE_MASTER = 1
HAVE_APPLICATION_FLAG_LIBRARY = 1

VARIANT_PARAM = COIN

ENABLE_BLUETOOTH = 1
ENABLE_NBGL_QRCODE = 1
ENABLE_SWAP = 1

ifeq ($(TARGET_NAME),TARGET_STAX)
DEFINES += COIN_ICON=C_$(COIN)_64px
DEFINES += COIN_ICON_BITMAP=C_$(COIN)_64px_bitmap
endif

ifndef BIP44_COIN_TYPE
$(error BIP44_COIN_TYPE must be defined)
endif

ifndef BIP44_COIN_TYPE_2
$(error BIP44_COIN_TYPE_2 must be defined)
endif

ifndef COIN_P2PKH_VERSION
$(error COIN_P2PKH_VERSION must be defined)
endif

ifndef COIN_P2SH_VERSION
$(error COIN_P2SH_VERSION must be defined)
endif

ifndef COIN_FAMILY
$(error COIN_FAMILY must be defined)
endif

ifndef COIN_COINID
$(error COIN_COINID must be defined)
endif

ifndef COIN_COINID_HEADER
$(error COIN_COINID_HEADER must be defined)
endif

ifndef COIN_COINID_NAME
$(error COIN_COINID_NAME must be defined)
endif

ifndef COIN_COINID_SHORT
$(error COIN_COINID_SHORT must be defined)
endif

ifndef COIN_NATIVE_SEGWIT_PREFIX
$(error COIN_NATIVE_SEGWIT_PREFIX must be defined)
endif

ifndef COIN_KIND
$(error COIN_KIND must be defined)
endif

ifndef COIN_FLAGS
$(error COIN_FLAGS must be defined)
endif

ifndef COIN_FORKID
$(info COIN_FORKID set to 0)
COIN_FORKID=0
endif

ifeq ($(APPNAME),)
$(error APPNAME must be defined)
endif

DEFINES +=BIP44_COIN_TYPE=$(BIP44_COIN_TYPE)
DEFINES +=BIP44_COIN_TYPE_2=$(BIP44_COIN_TYPE_2)
DEFINES +=COIN_P2PKH_VERSION=$(COIN_P2PKH_VERSION)
DEFINES +=COIN_P2SH_VERSION=$(COIN_P2SH_VERSION)
DEFINES +=COIN_FAMILY=$(COIN_FAMILY)
DEFINES +=COIN_COINID=$(COIN_COINID)
DEFINES +=COIN_COINID_HEADER=$(COIN_COINID_HEADER)
DEFINES +=COIN_COINID_NAME=$(COIN_COINID_NAME)
DEFINES +=COIN_COINID_SHORT=$(COIN_COINID_SHORT)
DEFINES +=COIN_NATIVE_SEGWIT_PREFIX=$(COIN_NATIVE_SEGWIT_PREFIX)
DEFINES +=COIN_KIND=$(COIN_KIND)
DEFINES +=COIN_FLAGS=$(COIN_FLAGS)
DEFINES +=COIN_FORKID=$(COIN_FORKID)

include $(BOLOS_SDK)/Makefile.standard_app
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e796a1a

Please sign in to comment.