Making transactions between wallets


  • Transaction from tesla-wallet to minka-wallet
  • Transaction from tesla-wallet to minka-wallet, using accounts in them, e.g. account:1001001234@tesla-wallet to account:1001009876@minka-wallet
  • Introducing outside bank core and a wallet for it, and making transaction. Here, introduce the concept of 2 phase commit and everything else that is needed.

Making first transaction between wallets

Transaction between wallets

Before we make the transaction, we will check the balances of the wallets to see what is their initial state.

Due to our default-policy policy that allows records (in this case wallets) to be read only by their owner, we have to login as tesla-signer signer first. Remember to use tesla for password as well, as it is defined in signers.json layout file. To login, use the following command:

minka ledger login

To check the balance of the tesla-wallet wallet, we will use the following CLI command:

minka wallet balances tesla-wallet

We can do the same for the minka-wallet wallet, using the minka-signer signer.

We see that the inital balances for these wallets are:

WalletUSD BalanceDOP Balance
tesla-wallet1,000,000.005,000,000.00
minka-wallet1,000,000.005,000,000.00

Now, we will make a transaction between tesla-wallet and minka-wallet wallets. To do that, make sure you log in as tesla-signer signer again. The transfer intent will be initiated using layout file p2p-transaction.json. Apply this layout file using the following command:

minka ledger apply --local

When running the balance commands again (with separate signers for each wallet), we will see that the balance of the tesla-wallet wallet has decreased by 5000 and the balance of the minka-wallet wallet has increased by 5000, and the new balances are:

WalletUSD BalanceDOP Balance
tesla-wallet995,000.005,000,000.00
minka-wallet1,005,000.005,000,000.00

Making transaction between wallets using complex addressing

In the previous example, we used the tesla-wallet and minka-wallet wallets directly. In this example, we will show how complex addressing can be used to make a transaction between wallets.

Introduction to wallet addressing

Wallet handle is read as a pattern <schema>:<handle>@<parent>. While schema and parent are optional, handle is required.

Here are some examples of wallet handles and how their components are interpreted:

Wallet HandleSchemaHandleParent
account:1001001234@tesla-walletaccount1001001234tesla-wallet
1001009876@minka-wallet-1001009876minka-wallet
tel:15261234578tel15261234578-
tel@zaba-telzaba
zaba-zaba-

Once wallet components are identified, ledger engine is using the following hierarchy to find the wallet handle in the ledger:

  1. <schema>:<handle>@<parent>
  2. <schema>@<parent>
  3. <parent>
  4. <schema>

When wallet is found in the hierarchy, it is used as the source or target of the transaction. Otherwise, the wallet is not found, the transaction is not possible and the error is returned.

For more detailed information about wallet addressing, refer to the Wallets chapter of the About Wallets documentation.

Transaction between tesla-wallet and minka-wallet using complex addressing

In this example, we will make a transaction between tesla-wallet and minka-wallet wallets, using complex addressing.

Source wallet will be account:1001001234@tesla-wallet and target wallet will be account:1001009876@minka-wallet. Once these wallets handles are passed through the hierarchy, they will be resolved in the following way:

  • account:1001001234@tesla-wallet
    • account:1001001234@tesla-wallet -> wallet found
    • account@tesla-wallet -> wallet found
    • tesla-wallet -> wallet found
  • account:1001009876@minka-wallet
    • account:1001009876@minka-wallet -> wallet found
    • account@minka-wallet -> wallet found
    • minka-wallet -> wallet found

This means that the transaction will be made between tesla-wallet and minka-wallet wallets.

Download the p2p-transaction-complex.json layout file and apply it.

When running the balance commands again (with separate signers for each wallet), we will see that the balance of the tesla-wallet wallet has decreased by 20000 and the balance of the minka-wallet wallet has increased by 20000, and the new balances are:

WalletUSD BalanceDOP Balance
tesla-wallet975,000.005,000,000.00
minka-wallet1,025,000.005,000,000.00