Skip to content

Commit f3b0717

Browse files
authored
fix(legacy): fix the display issue in conflux transactions where data… (#575)
* fix(legacy): fix the display issue in conflux transactions where data is nonempty and transfer value is nonzero * ci: pin the nix version to avoid some issue
1 parent 9f411d0 commit f3b0717

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

.github/workflows/prebuild.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
- uses: cachix/install-nix-action@v13
1212
with:
1313
nix_path: nixpkgs=channel:nixos-unstable
14+
install_url: 'https://releases.nixos.org/nix/nix-2.23.3/install'
1415
name: "Run style check"
1516
- run: nix-shell --run "poetry install"
1617
- run: nix-shell --run "poetry run make style_check"
@@ -26,6 +27,7 @@ jobs:
2627
- uses: cachix/install-nix-action@v13
2728
with:
2829
nix_path: nixpkgs=channel:nixos-unstable
30+
install_url: 'https://releases.nixos.org/nix/nix-2.23.3/install'
2931
name: "Run defs check"
3032
- run: nix-shell --run "poetry install"
3133
- run: nix-shell --run "poetry run make defs_check"
@@ -41,6 +43,7 @@ jobs:
4143
- uses: cachix/install-nix-action@v13
4244
with:
4345
nix_path: nixpkgs=channel:nixos-unstable
46+
install_url: 'https://releases.nixos.org/nix/nix-2.23.3/install'
4447
name: "Run gen check"
4548
- run: nix-shell --run "poetry install"
4649
- run: nix-shell --run "poetry run make gen_check"

legacy/firmware/conflux.c

+18-35
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static bool layoutConfluxConfirmTx(
387387
uint8_t *to, uint32_t to_len, const char *signer, const uint8_t *value,
388388
uint32_t value_len, const ConfluxTokenType *token, uint32_t chain_ids,
389389
const uint8_t *gas_price, uint32_t gas_price_len, const uint8_t *gas_limit,
390-
uint32_t gas_limit_len, bool has_data) {
390+
uint32_t gas_limit_len, const uint8_t *data, uint32_t data_len) {
391391
bignum256 val = {0}, gas = {0};
392392
uint8_t pad_val[32] = {0};
393393
char gas_value[32] = {0};
@@ -414,17 +414,12 @@ static bool layoutConfluxConfirmTx(
414414
} else {
415415
strlcpy(to_str, _("to new contract?"), sizeof(to_str));
416416
}
417+
confluxFormatAmount(&val, token, amount, sizeof(amount));
417418
if (token == NULL) {
418-
if (bn_is_zero(&val) && has_data) {
419-
strcpy(amount, _("message")); // contract
420-
} else {
421-
confluxFormatAmount(&val, NULL, amount, sizeof(amount));
422-
return layoutTransactionSign(
423-
"Conflux", 0, false, amount, to_str, signer, NULL, NULL, NULL, 0,
424-
_("Maximum Fee:"), gas_value, NULL, NULL, NULL, NULL, NULL, NULL);
425-
}
419+
return layoutTransactionSign("Conflux", 0, false, amount, to_str, signer,
420+
NULL, NULL, data, data_len, _("Maximum Fee:"),
421+
gas_value, NULL, NULL, NULL, NULL, NULL, NULL);
426422
} else {
427-
confluxFormatAmount(&val, token, amount, sizeof(amount));
428423
return layoutTransactionSign("Conflux", 0, true, amount, to_str, signer,
429424
NULL, NULL, NULL, 0, _("Maximum Fee"),
430425
gas_value, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -565,36 +560,24 @@ void conflux_signing_init(ConfluxSignTx *msg, const HDNode *node) {
565560
}
566561

567562
if (token != NULL) {
568-
if (!layoutConfluxConfirmTx(
569-
msg->data_initial_chunk.bytes + 16, 20, signer,
570-
msg->data_initial_chunk.bytes + 36, 32, token, msg->chain_id,
571-
msg->gas_price.bytes, msg->gas_price.size, msg->gas_limit.bytes,
572-
msg->gas_limit.size, data_total > 0 ? true : false)) {
563+
if (!layoutConfluxConfirmTx(msg->data_initial_chunk.bytes + 16, 20, signer,
564+
msg->data_initial_chunk.bytes + 36, 32, token,
565+
msg->chain_id, msg->gas_price.bytes,
566+
msg->gas_price.size, msg->gas_limit.bytes,
567+
msg->gas_limit.size, NULL, 0)) {
573568
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
574569
conflux_signing_abort();
575570
return;
576571
}
577572
} else {
578-
if (toset) {
579-
if (!layoutConfluxConfirmTx(pubkeyhash, 20, signer, msg->value.bytes,
580-
msg->value.size, NULL, msg->chain_id,
581-
msg->gas_price.bytes, msg->gas_price.size,
582-
msg->gas_limit.bytes, msg->gas_limit.size,
583-
data_total > 0 ? true : false)) {
584-
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
585-
conflux_signing_abort();
586-
return;
587-
}
588-
} else {
589-
if (!layoutConfluxConfirmTx(pubkeyhash, 0, signer, msg->value.bytes,
590-
msg->value.size, NULL, msg->chain_id,
591-
msg->gas_price.bytes, msg->gas_price.size,
592-
msg->gas_limit.bytes, msg->gas_limit.size,
593-
data_total > 0 ? true : false)) {
594-
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
595-
conflux_signing_abort();
596-
return;
597-
}
573+
if (!layoutConfluxConfirmTx(
574+
pubkeyhash, toset ? 20 : 0, signer, msg->value.bytes,
575+
msg->value.size, NULL, msg->chain_id, msg->gas_price.bytes,
576+
msg->gas_price.size, msg->gas_limit.bytes, msg->gas_limit.size,
577+
msg->data_initial_chunk.bytes, msg->data_initial_chunk.size)) {
578+
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
579+
conflux_signing_abort();
580+
return;
598581
}
599582
}
600583

0 commit comments

Comments
 (0)