I built a private testnet with reference to this guide.
In order to understand how the secret transaction key is generated, I examined how many times the
open_tx function (in device_default.cpp) was executed with a transfer command from the monero-wallet-cli.
open_tx is the function used in
construct_tx_and_get_tx_key function (in cryptonote_tx_utils.cpp) to generate a secret transaction key.
It turned out that
open_tx was executed twice per one transfer command. Why is
open_tx executed twice instead of once?