Managing wallet access
Ensuring only the wallet owner has the control over the wallet
Now that we demonstrated how things should not work, let's see how we can improve our clearinghouse Ledger system.
Removing all access
Only clearinghouse signer
that created the ledger
record should have complete control over that entire ledger.
While we were creating the ledger record we were presented with these JSON access rules:
These rules allowed anyone to do anything (and this helped us simplify the tutorial).
But now we will only grant full access to the clearinghouse signer and everyone else will have zero access.
This way we're setting up our system with maximum security and then we'll slowly add permissions to others.
We can edit access rules using the update
command:
Select Access
and update the JSON rules so that only clearinghouse signer
can have total control.
public
is actually signer's public key which you can get using the following command:
Now, aside from clearinghouse signer
no one can do anything.
Testing clearinghouse access
Let's start with any command. For example, listing all wallets:
Since access is no longer open to everyone, the Ledger system needs to verify the identity of the signer before allowing any kind of access or modification.
To do that, we will login using our clearinghouse
signer:
Now when we repeat the previous command we will see the list of all the wallets in the ledger:
Adding access
Having completely restricted rules (below) makes the Ledger useless because no one can access it or use it (except the clearinghouse).
So let's start by editing ledger rules once again and allow each signer
to access its own data:
And also, let's allow owners of the wallet
to change wallet balance:
And finally, let's allow demo-bank
signer to create intents/transactions (using its public key):
Here is how the full ledger access rules look like:
Use minka ledger update
command to set these new access rules.
Testing demo bank access
First we need to logout from our clearinghouse signer using minka ledger logout
command.
Now, let's say we just want to list wallets in the ledger:
As expected we cannot see the wallets without a proper signer.
So let's login with our demo-bank
signer:
Now when we list the wallets, demo-bank
can only see the records that belong to it:
Notice how we were able to see all the wallets when we were logged in as a clearinghouse
.
Testing balance transfer (fail)
We will again try to make a transfer from settlement-wallet
that doesn't belong to demo-bank
and see if it goes through:
As you can see, demo-bank
wallet managed to create intent but that doesn't mean the balance was transferred.
If we list the intents, we can see it's pending
and will eventually timeout without making a transfer.
This means, demo-bank
no longer controls the settlement-wallet
balance and we successfully limited the access that was previously completely unrestricted.
Testing balance transfer (success)
Another case we need to verify is whether the demo-bank
signer can transfer balance from its own demo-bank-wallet
:
If we take a look at intents, we can see that this transfer
was successful:
And we can also see that demo-bank-wallet
balance is now changed: