1

I am wondering how does the LockableCurrency work? Or more specifically, what are the WithdrawReasons? Is it just a marker or the value specified here is important for actually releasing the lock? My use case is that I want to lock funds for transfer for a certain time and then either transfer those funds or release the lock. So should I just use WithdrawReasons:all()?

And as a side note - I thought I could use a substring(hash(AccountId)) for the lock identifier, is it a good idea create the lock per each account this way?

Petr Mensik
  • 26,874
  • 17
  • 90
  • 115
  • I think this question is pretty clear for everyone using the `Substrate` framework - I can only improve it by adding a link to the Rust docs. – Petr Mensik Jan 10 '21 at 15:32

1 Answers1

1

If you want to only disallow transfers, then you should use a lock that only prohibits withdraw reasons transfer, aka. WithdrawReason::Transfer. Although, be aware that it is likely that a user can find a way to get around this, as they can tip the block author or pay for transaction fees with the locked funds, so if they happen to collude with a block author, they can effectively trick the system.

It is likely that what you actually want is WithdrawReason::all().


And as a side note - I thought I could use a substring(hash(AccountId)) for the lock identifier, is it a good idea create the lock per each account this way?

I wouldn't do that. Each lock is already linked to an account, and the API for adding and removing locks already asks for an account to operate on. So using the account hash as key is duplicate in my opinion (could also have bad performance impact). You should follow the convention within substrate use a uniquee identifier from the pallet as your lock identifier (simply: name of the pallet will do). This will make sure that the locks created by this pallet will not be accidentally removed by another pallet.

kianenigma
  • 1,365
  • 12
  • 20