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
1 change: 1 addition & 0 deletions include/btchip_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ unsigned char btchip_output_script_is_op_create(unsigned char *buffer,
size_t size);
unsigned char btchip_output_script_is_op_call(unsigned char *buffer,
size_t size);
unsigned char btchip_output_script_is_empty(unsigned char *buffer);

void btchip_sleep16(unsigned short delay);
void btchip_sleep32(unsigned long int delayEach, unsigned long int delayRepeat);
Expand Down
18 changes: 12 additions & 6 deletions src/btchip_apdu_hash_input_finalize_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static bool check_output_displayable() {
unsigned char amount[8], isOpReturn, isP2sh, isNativeSegwit, j,
nullAmount = 1;
unsigned char isOpCreate, isOpCall;
bool isRecognizedOutputScript = false;

for (j = 0; j < 8; j++) {
if (btchip_context_D.currentOutput[j] != 0) {
Expand All @@ -68,12 +69,17 @@ static bool check_output_displayable() {
isOpCall =
btchip_output_script_is_op_call(btchip_context_D.currentOutput + 8,
sizeof(btchip_context_D.currentOutput) - 8);
if (((G_coin_config->kind == COIN_KIND_QTUM || G_coin_config->kind == COIN_KIND_HYDRA) &&
!btchip_output_script_is_regular(btchip_context_D.currentOutput + 8) &&
!isP2sh && !(nullAmount && isOpReturn) && !isOpCreate && !isOpCall) ||
(!(G_coin_config->kind == COIN_KIND_QTUM || G_coin_config->kind == COIN_KIND_HYDRA) &&
!btchip_output_script_is_regular(btchip_context_D.currentOutput + 8) &&
!isP2sh && !(nullAmount && isOpReturn))) {
if (btchip_output_script_is_regular(btchip_context_D.currentOutput + 8) ||
isP2sh || (nullAmount && isOpReturn)) {
isRecognizedOutputScript = true;
} else if (G_coin_config->kind == COIN_KIND_QTUM || G_coin_config->kind == COIN_KIND_HYDRA) {
if (isOpCreate || isOpCall)
isRecognizedOutputScript = true;
} else if (G_coin_config->kind == COIN_KIND_PEERCOIN) {
if (nullAmount)
isRecognizedOutputScript = true;
}
if (!isRecognizedOutputScript) {
PRINTF("Error : Unrecognized output script");
THROW(EXCEPTION);
}
Expand Down
4 changes: 4 additions & 0 deletions src/btchip_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ unsigned char btchip_output_script_is_op_call(unsigned char *buffer,
return output_script_is_op_create_or_call(buffer, size, 0xC2);
}

unsigned char btchip_output_script_is_empty(unsigned char *buffer) {
return buffer[0] == 0;
}

unsigned char btchip_rng_u8_modulo(unsigned char modulo) {
unsigned int rng_max = 256 % modulo;
unsigned int rng_limit = 256 - rng_max;
Expand Down
6 changes: 5 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ uint8_t prepare_fees() {
borrow = transaction_amount_sub_be(
fees, btchip_context_D.transactionContext.transactionAmount,
btchip_context_D.totalOutputAmount);
if (borrow && G_coin_config->kind == COIN_KIND_KOMODO) {
if (borrow && (G_coin_config->kind == COIN_KIND_KOMODO || G_coin_config->kind == COIN_KIND_PEERCOIN)) {
os_memmove(vars.tmp.feesAmount, "REWARD", 6);
vars.tmp.feesAmount[6] = '\0';
}
Expand Down Expand Up @@ -846,6 +846,10 @@ void get_address_from_output_script(unsigned char* script, int script_size, char
strcpy(out, "OP_RETURN");
return;
}
if (G_coin_config->kind == COIN_KIND_PEERCOIN && btchip_output_script_is_empty(script)) {
strcpy(out, "COINSTAKE");
return;
}
if ((G_coin_config->kind == COIN_KIND_QTUM || G_coin_config->kind == COIN_KIND_HYDRA) &&
btchip_output_script_is_op_create(script, script_size)) {
strcpy(out, "OP_CREATE");
Expand Down