Skip to content

Commit

Permalink
fix sign progress stop, fix get init label
Browse files Browse the repository at this point in the history
  • Loading branch information
ykevin committed May 7, 2015
1 parent 2f101e0 commit a158d2b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
6 changes: 5 additions & 1 deletion firmware/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ void fsm_msgSignIdentity(SignIdentity *msg)
const HDNode *node = fsm_getDerivedNode(address_n, 5);
if (!node) return;

uint8_t message[128];
uint8_t message[256 + 256];
memcpy(message, msg->challenge_hidden.bytes, msg->challenge_hidden.size);
const int len = strlen(msg->challenge_visual);
memcpy(message + msg->challenge_hidden.size, msg->challenge_visual, len);
Expand Down Expand Up @@ -1100,6 +1100,10 @@ void fsm_msgGetAccountLabels(GetAccountLabels *msg)
}


const uint32_t labels_count_init = storage_getAccountCount(coin_index);
if(labels_count_init == 0xffffffff)
storage_labelInit();

const uint32_t find_index = storage_findAccountLabel(msg->index, coin_index);

RESP_INIT(AccountLabels);
Expand Down
41 changes: 29 additions & 12 deletions firmware/signing.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void signing_init(uint32_t _inputs_count, uint32_t _outputs_count, const CoinTyp
memset(&resp, 0, sizeof(TxRequest));

signing = true;
progress = 1;
progress = 0;
// we step by 500/inputs_count per input in phase1 and phase2
// this means 50 % per phase.
progress_step = (500 << PROGRESS_PRECISION) / inputs_count;
Expand Down Expand Up @@ -279,7 +279,7 @@ void signing_txack(TransactionType *tx)
}

static int update_ctr = 0;
if (update_ctr++ == 50) {
if (update_ctr++ == 20) {
switch (storage_getLang()) {
case CHINESE :
layoutProgressSwipe("交易签名#.##.##.#", progress);
Expand Down Expand Up @@ -455,6 +455,14 @@ void signing_txack(TransactionType *tx)
layoutHome();
return;
}
switch (storage_getLang()) {
case CHINESE :
layoutProgressSwipe("交易签名#.##.##.#", progress);
break;
default :
layoutProgressSwipe("Signing transaction", progress);
break;
}
}
// last confirmation
layoutConfirmTx(coin, to_spend - change_spend, fee);
Expand All @@ -481,16 +489,16 @@ void signing_txack(TransactionType *tx)
return;
}
case STAGE_REQUEST_4_INPUT:
progress = 500 + ((idx1 * progress_step + idx2 * progress_meta_step) >> PROGRESS_PRECISION);
if (idx2 == 0) {
tx_init(&ti, inputs_count, outputs_count, version, lock_time, true);
sha256_Init(&tc);
sha256_Update(&tc, (const uint8_t *)&inputs_count, sizeof(inputs_count));
sha256_Update(&tc, (const uint8_t *)&outputs_count, sizeof(outputs_count));
sha256_Update(&tc, (const uint8_t *)&version, sizeof(version));
sha256_Update(&tc, (const uint8_t *)&lock_time, sizeof(lock_time));
memset(privkey, 0, 32);
memset(pubkey, 0, 33);
progress = 500 + ((idx1 * progress_step + idx2 * progress_meta_step) >> PROGRESS_PRECISION);
if (idx2 == 0) {
tx_init(&ti, inputs_count, outputs_count, version, lock_time, true);
sha256_Init(&tc);
sha256_Update(&tc, (const uint8_t *)&inputs_count, sizeof(inputs_count));
sha256_Update(&tc, (const uint8_t *)&outputs_count, sizeof(outputs_count));
sha256_Update(&tc, (const uint8_t *)&version, sizeof(version));
sha256_Update(&tc, (const uint8_t *)&lock_time, sizeof(lock_time));
memset(privkey, 0, 32);
memset(pubkey, 0, 33);
}
sha256_Update(&tc, (const uint8_t *)tx->inputs, sizeof(TxInputType));
if (idx2 == idx1) {
Expand Down Expand Up @@ -596,6 +604,15 @@ void signing_txack(TransactionType *tx)
input.script_sig.size = serialize_script_sig(resp.serialized.signature.bytes, resp.serialized.signature.size, pubkey, 33, input.script_sig.bytes);
}
resp.serialized.serialized_tx.size = tx_serialize_input(&to, &input, resp.serialized.serialized_tx.bytes);
switch (storage_getLang()) {
case CHINESE :
layoutProgressSwipe("交易签名#.##.##.#", progress);
break;
default :
layoutProgressSwipe("Signing transaction", progress);
break;
}
update_ctr = 0;
if (idx1 < inputs_count - 1) {
idx1++;
idx2 = 0;
Expand Down

0 comments on commit a158d2b

Please sign in to comment.