Add Bitcoin Gold support

This commit is contained in:
BTChip github 2017-11-21 19:30:17 +01:00
parent 5b6c6d78c3
commit 30458e7a13
No known key found for this signature in database
GPG Key ID: 48BCF826EBFA4D17
8 changed files with 18 additions and 7 deletions

View File

@ -24,7 +24,7 @@ APP_LOAD_PARAMS=--appFlags 0x50 --path "" --curve secp256k1 $(COMMON_LOAD_PARAMS
APPVERSION_M=1
APPVERSION_N=1
APPVERSION_P=13
APPVERSION_P=14
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
# ifndef COIN
@ -41,8 +41,12 @@ DEFINES += BTCHIP_P2PKH_VERSION=0 BTCHIP_P2SH_VERSION=5 BTCHIP_COIN_FAMILY=1 B
APPNAME ="Bitcoin"
else ifeq ($(COIN),bitcoin_cash)
# Bitcoin cash
DEFINES += BTCHIP_P2PKH_VERSION=0 BTCHIP_P2SH_VERSION=5 BTCHIP_COIN_FAMILY=1 BTCHIP_COINID=\"Bitcoin\" COINID_UPCASE=\"BITCOINCASH\" COLOR_HDR=0x85bb65 COLOR_DB=0xc2ddb2 COINID_NAME=\"BitcoinCash\" COINID=$(COIN) BTCHIP_COINID_SHORT=\"BCH\" COIN_BITCOIN_CASH
DEFINES += BTCHIP_P2PKH_VERSION=0 BTCHIP_P2SH_VERSION=5 BTCHIP_COIN_FAMILY=1 BTCHIP_COINID=\"Bitcoin\" COINID_UPCASE=\"BITCOINCASH\" COLOR_HDR=0x85bb65 COLOR_DB=0xc2ddb2 COINID_NAME=\"BitcoinCash\" COINID=$(COIN) BTCHIP_COINID_SHORT=\"BCH\" COIN_BITCOIN_CASH COIN_FORKID=0
APPNAME ="Bitcoin Cash"
else ifeq ($(COIN),bitcoin_gold)
# Bitcoin Gold
DEFINES += BTCHIP_P2PKH_VERSION=38 BTCHIP_P2SH_VERSION=23 BTCHIP_COIN_FAMILY=1 BTCHIP_COINID="\"Bitcoin Gold\"" COINID_UPCASE=\"BITCOINGOLD\" COLOR_HDR=0x85bb65 COLOR_DB=0xc2ddb2 COINID_NAME=\"BitcoinGold\" COINID=$(COIN) BTCHIP_COINID_SHORT=\"BTG\" COIN_BITCOIN_GOLD COIN_FORKID=79
APPNAME ="Bitcoin Gold"
else ifeq ($(COIN),litecoin)
# Litecoin
DEFINES += BTCHIP_P2PKH_VERSION=48 BTCHIP_P2SH_VERSION=50 BTCHIP_COIN_FAMILY=1 BTCHIP_COINID=\"Litecoin\" COINID_UPCASE=\"LITECOIN\" COLOR_HDR=0xCCCCCC COLOR_DB=0xE6E6E6 COINID_NAME=\"Litecoin\" COINID=$(COIN) BTCHIP_COINID_SHORT=\"LTC\" COIN_LITECOIN HAVE_SEGWIT_CHANGE_SUPPORT
@ -92,7 +96,7 @@ DEFINES += BTCHIP_P2PKH_VERSION=71 BTCHIP_P2SH_VERSION=5 BTCHIP_COIN_FAMILY=1
APPNAME ="Vertcoin"
else
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error Unsupported COIN - use bitcoin_testnet, bitcoin, bitcoin_cash, litecoin, dogecoin, dash, zcash, komodo, stratis, peercoin, posw, pivx, viacoin, vertcoin, stealthcoin)
$(error Unsupported COIN - use bitcoin_testnet, bitcoin, bitcoin_cash, bitcoin_gold, litecoin, dogecoin, dash, zcash, komodo, stratis, peercoin, posw, pivx, viacoin, vertcoin, stealthcoin)
endif
endif

BIN
blue_app_bitcoin_gold.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@ -24,7 +24,7 @@
#include "btchip_filesystem_tx.h"
#define MAX_OUTPUT_TO_CHECK 200
#define MAX_COIN_ID 12
#define MAX_COIN_ID 13
#define MAX_SHORT_COIN_ID 5
#define MAGIC_TRUSTED_INPUT 0x32

BIN
nanos_app_bitcoin_gold.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -19,13 +19,13 @@
#include "btchip_apdu_constants.h"
#define SIGHASH_ALL 0x01
#ifdef COIN_BITCOIN_CASH
#if defined(COIN_BITCOIN_CASH) || defined(COIN_BITCOIN_GOLD)
#define SIGHASH_FORKID 0x40
#endif
unsigned short btchip_apdu_hash_sign() {
unsigned long int lockTime;
unsigned char sighashType;
uint32_t sighashType;
unsigned char dataBuffer[8];
unsigned char hash1[32];
unsigned char hash2[32];
@ -87,11 +87,13 @@ unsigned short btchip_apdu_hash_sign() {
if (((N_btchip.bkp.config.options &
BTCHIP_OPTION_FREE_SIGHASHTYPE) == 0)) {
#ifdef COIN_BITCOIN_CASH
#if defined(COIN_BITCOIN_CASH) || defined(COIN_BITCOIN_GOLD)
if (sighashType != (SIGHASH_ALL | SIGHASH_FORKID)) {
sw = BTCHIP_SW_INCORRECT_DATA;
goto discardTransaction;
}
sighashType |= (COIN_FORKID << 8);
#else
if (sighashType != SIGHASH_ALL) {
sw = BTCHIP_SW_INCORRECT_DATA;

View File

@ -102,6 +102,7 @@ unsigned short btchip_apdu_sign_message_internal() {
if (G_io_apdu_buffer[offset] > MAX_BIP32_PATH) {
L_DEBUG_APP(("Invalid path\n"));
sw = BTCHIP_SW_INCORRECT_DATA;
CLOSE_TRY;
goto discard;
}
btchip_context_D.transactionSummary.payToAddressVersion =
@ -126,6 +127,7 @@ unsigned short btchip_apdu_sign_message_internal() {
0) {
L_DEBUG_APP(("Null message length\n"));
sw = BTCHIP_SW_INCORRECT_DATA;
CLOSE_TRY;
goto discard;
}
btchip_context_D.hashedMessageLength = 0;
@ -164,6 +166,7 @@ unsigned short btchip_apdu_sign_message_internal() {
btchip_context_D.transactionSummary.messageLength) {
L_DEBUG_APP(("Invalid data length\n"));
sw = BTCHIP_SW_INCORRECT_DATA;
CLOSE_TRY;
goto discard;
}
cx_hash(&btchip_context_D.transactionHashFull.header, 0,
@ -185,6 +188,7 @@ unsigned short btchip_apdu_sign_message_internal() {
btchip_context_D.transactionSummary.messageLength) {
L_DEBUG_APP(("Invalid data length\n"));
sw = BTCHIP_SW_INCORRECT_DATA;
CLOSE_TRY;
goto discard;
}
cx_hash(&btchip_context_D.transactionHashFull.header, 0,
@ -208,6 +212,7 @@ unsigned short btchip_apdu_sign_message_internal() {
btchip_context_D.transactionSummary.messageLength)) {
L_DEBUG_APP(("Invalid length to sign\n"));
sw = BTCHIP_SW_INCORRECT_DATA;
CLOSE_TRY;
goto discard;
}
if (checkBitId(btchip_context_D.transactionSummary.summarydata