Skip to content

Commit 3a60dcc

Browse files
committed
feat(validations): allow unstaking all the stake at once
Namely, apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually means "unstake all my stake"
1 parent 3a68ae4 commit 3a60dcc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

validations/src/validations.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ pub fn validate_unstake_transaction<'a>(
14721472
}
14731473

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

14771477
let validator = ut_tx.body.operator;
14781478
let withdrawer = ut_tx.signature.public_key.pkh();
@@ -1522,6 +1522,12 @@ pub fn validate_unstake_transaction<'a>(
15221522
.into());
15231523
}
15241524
};
1525+
1526+
// Apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually
1527+
// means "unstake all my stake".
1528+
if amount_to_unstake == u64::MAX {
1529+
amount_to_unstake = staked_amount;
1530+
}
15251531

15261532
// Allowed unstake actions:
15271533
// 1) Unstake the full balance (checked by the first condition)

0 commit comments

Comments
 (0)