Skip to content

Commit

Permalink
Merge pull request 'Remove Legacy UI when only one output' (LedgerHQ#18
Browse files Browse the repository at this point in the history
…) from fix-legacy-ui into master
  • Loading branch information
nba committed Mar 31, 2020
2 parents 79a12d0 + fdb1944 commit 056908b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
3 changes: 1 addition & 2 deletions include/btchip_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ enum btchip_output_parsing_state_e {
BTCHIP_OUTPUT_PARSING_NUMBER_OUTPUTS = 0x01,
BTCHIP_OUTPUT_PARSING_OUTPUT = 0x02,
BTCHIP_OUTPUT_FINALIZE_TX = 0x03,
BTCHIP_BIP44_CHANGE_PATH_VALIDATION = 0x04,
BTCHIP_OUTPUT_HANDLE_LEGACY = 0xFF
BTCHIP_BIP44_CHANGE_PATH_VALIDATION = 0x04
};
typedef enum btchip_output_parsing_state_e btchip_output_parsing_state_t;

Expand Down
39 changes: 11 additions & 28 deletions src/btchip_apdu_hash_input_finalize_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,28 +346,17 @@ unsigned short btchip_apdu_hash_input_finalize_full_internal(
G_io_apdu_buffer + ISO_OFFSET_CDATA, apduLength);
btchip_context_D.currentOutputOffset += apduLength;

// Check if the legacy UI can be applied
if (!(G_coin_config->kind == COIN_KIND_QTUM) &&
(G_io_apdu_buffer[ISO_OFFSET_P1] == FINALIZE_P1_LAST) &&
!btchip_context_D.tmpCtx.output.multipleOutput &&
prepare_full_output(1)) {
btchip_context_D.io_flags |= IO_ASYNCH_REPLY;
btchip_context_D.outputParsingState =
BTCHIP_OUTPUT_HANDLE_LEGACY;
btchip_context_D.remainingOutputs = 0;
} else {
while (handle_output_state() &&
(!(btchip_context_D.io_flags & IO_ASYNCH_REPLY)))
;
while (handle_output_state() &&
(!(btchip_context_D.io_flags & IO_ASYNCH_REPLY)))
;

// Finalize the TX if necessary
// Finalize the TX if necessary

if ((btchip_context_D.remainingOutputs == 0) &&
(!(btchip_context_D.io_flags & IO_ASYNCH_REPLY))) {
btchip_context_D.io_flags |= IO_ASYNCH_REPLY;
btchip_context_D.outputParsingState =
BTCHIP_OUTPUT_FINALIZE_TX;
}
if ((btchip_context_D.remainingOutputs == 0) &&
(!(btchip_context_D.io_flags & IO_ASYNCH_REPLY))) {
btchip_context_D.io_flags |= IO_ASYNCH_REPLY;
btchip_context_D.outputParsingState =
BTCHIP_OUTPUT_FINALIZE_TX;
}
}

Expand Down Expand Up @@ -517,9 +506,6 @@ unsigned short btchip_apdu_hash_input_finalize_full() {
}
else if (btchip_context_D.outputParsingState == BTCHIP_OUTPUT_FINALIZE_TX) {
status = btchip_bagl_finalize_tx();
} else if (btchip_context_D.outputParsingState ==
BTCHIP_OUTPUT_HANDLE_LEGACY) {
status = btchip_bagl_confirm_full_output();
}
else {
status = btchip_bagl_confirm_single_output();
Expand Down Expand Up @@ -591,10 +577,8 @@ unsigned char btchip_bagl_user_action(unsigned char confirming) {
}
}

if ((btchip_context_D.outputParsingState ==
BTCHIP_OUTPUT_FINALIZE_TX) ||
(btchip_context_D.outputParsingState ==
BTCHIP_OUTPUT_HANDLE_LEGACY)) {
if (btchip_context_D.outputParsingState ==
BTCHIP_OUTPUT_FINALIZE_TX) {
btchip_context_D.transactionContext.firstSigned = 0;

if (btchip_context_D.usingSegwit &&
Expand Down Expand Up @@ -622,7 +606,6 @@ unsigned char btchip_bagl_user_action(unsigned char confirming) {
G_io_apdu_buffer[btchip_context_D.outLength++] = sw;

if ((btchip_context_D.outputParsingState == BTCHIP_OUTPUT_FINALIZE_TX) ||
(btchip_context_D.outputParsingState == BTCHIP_OUTPUT_HANDLE_LEGACY) ||
(sw != BTCHIP_SW_OK)) {
// we've finished the processing of the input
btchip_apdu_hash_input_finalize_full_reset();
Expand Down

0 comments on commit 056908b

Please sign in to comment.