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

Feat/unstake all at once #2584

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion validations/src/validations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ pub fn validate_unstake_transaction<'a>(
}

// Check if is unstaking more than the total stake
let amount_to_unstake = ut_tx.body.value() + ut_tx.body.fee;
let mut amount_to_unstake = ut_tx.body.value() + ut_tx.body.fee;

let validator = ut_tx.body.operator;
let withdrawer = ut_tx.signature.public_key.pkh();
Expand Down Expand Up @@ -1522,6 +1522,12 @@ pub fn validate_unstake_transaction<'a>(
.into());
}
};

// Apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually
// means "unstake all my stake".
if amount_to_unstake == u64::MAX {
amount_to_unstake = staked_amount;
}

// Allowed unstake actions:
// 1) Unstake the full balance (checked by the first condition)
Expand Down
Loading