I'm using fn set_lock inside LockableCurrency trait. It's possible to extend or remove lock, but no way to check if funds are in fact locked. Is this by design? and if so what is a good way to check that funds are locked for a given user?

Here is a short code snippet:

// how do I make sure `who` does not have any funds locked without tracking it inside my code?
ensure!(T::Currency::free_balance(&who) >= amount, "Not enough funds to do X");
T::Currency::set_lock(SOME_LOCK_ID, &who, amount, WithdrawReasons::all());

1 Answer 1


IMO, there isn't an elegant way to do this.

I used ensure_can_withdraw in my code.

You can write:

// Why do I say this isn't elegant?
// Because you have to calculate the `new_balance` yourself here.
if T::Currency::ensure_can_withdraw(who, amount, reason, new_balance) {
} else {
  Err("Not enough funds to do X".into())?;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.