Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate must not change from START_NEW_TRANSACTION_COMMAND to UI display #109

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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: 0 additions & 1 deletion src/check_asset_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ int check_asset_in(const command_t *cmd) {
}

G_swap_ctx.state = WAITING_USER_VALIDATION;
G_swap_ctx.rate = cmd->rate;

ui_validate_amounts();

Expand Down
1 change: 0 additions & 1 deletion src/check_refund_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ int check_refund_address(const command_t *cmd) {
PRINTF("Fees: %s\n", G_swap_ctx.printable_fees_amount);

G_swap_ctx.state = WAITING_USER_VALIDATION;
G_swap_ctx.rate = cmd->rate;

ui_validate_amounts();

Expand Down
19 changes: 12 additions & 7 deletions src/command_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,35 @@ int dispatch_command(const command_t *cmd) {
break;
case SET_PARTNER_KEY_COMMAND:
if (G_swap_ctx.state == WAITING_TRANSACTION &&
cmd->subcommand == G_swap_ctx.subcommand) {
cmd->subcommand == G_swap_ctx.subcommand && cmd->rate == G_swap_ctx.rate) {
ret = set_partner_key(cmd);
valid_command_received = true;
}
break;
case CHECK_PARTNER_COMMAND:
if (G_swap_ctx.state == PROVIDER_SET && cmd->subcommand == G_swap_ctx.subcommand) {
if (G_swap_ctx.state == PROVIDER_SET && cmd->subcommand == G_swap_ctx.subcommand &&
cmd->rate == G_swap_ctx.rate) {
ret = check_partner(cmd);
valid_command_received = true;
}
break;
case PROCESS_TRANSACTION_RESPONSE_COMMAND:
if (G_swap_ctx.state == PROVIDER_CHECKED && cmd->subcommand == G_swap_ctx.subcommand) {
if (G_swap_ctx.state == PROVIDER_CHECKED && cmd->subcommand == G_swap_ctx.subcommand &&
cmd->rate == G_swap_ctx.rate) {
ret = process_transaction(cmd);
valid_command_received = true;
}
break;
case CHECK_TRANSACTION_SIGNATURE_COMMAND:
if (G_swap_ctx.state == TRANSACTION_RECEIVED &&
cmd->subcommand == G_swap_ctx.subcommand) {
cmd->subcommand == G_swap_ctx.subcommand && cmd->rate == G_swap_ctx.rate) {
ret = check_tx_signature(cmd);
valid_command_received = true;
}
break;
case CHECK_PAYOUT_ADDRESS:
if (G_swap_ctx.state == SIGNATURE_CHECKED && cmd->subcommand == G_swap_ctx.subcommand) {
if (G_swap_ctx.state == SIGNATURE_CHECKED && cmd->subcommand == G_swap_ctx.subcommand &&
cmd->rate == G_swap_ctx.rate) {
if (cmd->subcommand == SELL || cmd->subcommand == FUND) {
ret = check_asset_in(cmd);
} else {
Expand All @@ -80,13 +83,15 @@ int dispatch_command(const command_t *cmd) {
}
break;
case CHECK_REFUND_ADDRESS:
if (G_swap_ctx.state == TO_ADDR_CHECKED && cmd->subcommand == G_swap_ctx.subcommand) {
if (G_swap_ctx.state == TO_ADDR_CHECKED && cmd->subcommand == G_swap_ctx.subcommand &&
cmd->rate == G_swap_ctx.rate) {
ret = check_refund_address(cmd);
valid_command_received = true;
}
break;
case START_SIGNING_TRANSACTION:
if (G_swap_ctx.state == WAITING_SIGNING && cmd->subcommand == G_swap_ctx.subcommand) {
if (G_swap_ctx.state == WAITING_SIGNING && cmd->subcommand == G_swap_ctx.subcommand &&
cmd->rate == G_swap_ctx.rate) {
ret = start_signing_transaction(cmd);
valid_command_received = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/start_new_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int start_new_transaction(const command_t *cmd) {

G_swap_ctx.state = WAITING_TRANSACTION;
G_swap_ctx.subcommand = cmd->subcommand;
G_swap_ctx.rate = cmd->rate;

return 0;
}