Lock and Love Your Account!

sarmad asghar
Virtual Force Inc.
Published in
3 min readNov 22, 2022

Lock your account and sleep well because it is an idea to avoid misuse in case your credentials are compromised. Never bogged down by reversals not being generated. Also, personal account holders, occasionally need to transfer amounts from account A to B and from B to C, and so on depending upon certain conditions. These accounts may be from two different banks. Our idea provides the power that the account holder is allowed to lock all accounts A, B, C, and D and perform the transfers.

Sometimes companies need complex payment solutions like paying employees bonuses depending upon certain conditions. This idea will give the power of creating workflows tailored to needs. But the banking domain is very demanding because of the sensitive nature of showing account balances! A single transaction can take your breath showing the wrong balance. Due to this reversals are generated but we are proposing another idea where there is hopefully less need for reversal generation and companies can lock accounts at any time to be safe in certain circumstances like the leak of account passwords etc.

According to the theory of the operating systems, Locks must be taken in an increasing order (using IBAN as account identity) to avoid circular waiting.

Every bank merchandiser has to expose an API to lock/unlock an account. We need a centralized server to manage Locks. For every IBAN an in-memory lock will be created.

Consider a deadlock scenario where on Account A side:

  • Request for a lock on Account B
  • If granted lock your Account A

On Account B side:

  • Request for a lock on Account A
  • If granted lock your Account B
  • Transfer money

The above can potentially run into deadlocks

So, accounts must be locked in order like Account A1, A2, A3,… to avoid deadlocks

If you want to transfer the amount from Account A to B, followed by B to C, and so on, lock in increasing order for example:

If account A IBAN is A1

B is A2

C is A3

D is A4

E is A5

Then

Lock A

Lock B

Lock C

Lock D

Lock E

A = A — 1000 //Account A debit 1000

B = B + 1000 //Account B credit 1000

If Account C is low on balance then

C = C + 10000

Else

D = D + 10000

And so on

Unlock E

Unlock D

Unlock C

Unlock B

Unlock A

Nowadays, Every bank account has an associated IBAN.

So we have to transform IBAN into a binary string by converting every character to an 8-bit binary number

Use quick sort to arrange IBAN accounts and lock them in ascending order.

Perform the operations after acquiring locks

Release the locks

This idea has the potential to avoid reversal generations.

It will open up new horizons and possibilities! For example, if you want to safely transfer the amount from account A to B depending upon certain conditions.

Like if your account A balance is 10000 on a specific time and date then you want to transfer 5000 to account B. This can be wired up for as many accounts as you have.

As in the above diagram you can have complex workflows locking multiple accounts and checking certain conditions to act upon.

Also, you can Lock your account when needed so there is no debit or credit possible. This can be a good thing if you know your password may have been compromised.

To revolutionize, we need a central authority to manage to lock and unlock an account. Every bank merchandiser will have to expose an API to lock accounts. Applications like personal wallets will have access to the APIs and must expose their own APIs. This will create an ecosystem of Account locking/unlocking APIs.

Lock your account is an idea that you will love because it will give full control to the account holder. Not only you can lock your account but create complex workflows according to your needs! If your account is locked and you want to unlock your account then you are in control of the ways in which you can manage your account.

Love your Account!

Reference:

https://www.iban.com/structure

https://www.geeksforgeeks.org/deadlock-prevention/

http://web.cs.ucla.edu/classes/spring14/cs111/scribe/10f/

https://www.ibm.com/docs/en/order-management-sw/10.0?topic=caching-sort-order-deadlocks

https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system-2/

https://www.cs.yale.edu/homes/aspnes/pinewiki/Deadlock.html

https://web.mit.edu/6.005/www/fa15/classes/23-locks/

https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/7_Deadlocks.html

--

--