I'm trying to understand the inner workings of a bundle and its consequences.
From what I’ve read so far, transactions of a bundle are chained by the trunkTransaction
of each transaction in the bundle pointing to the next transaction in the bundle. Why is this needed? There already is a bundle
field in the transaction data structure and an index. Is this required to facilitate efficient traversal of transactions belonging to a bundle?
If trunkTransaction
is used to chain transactions, how exactly does this work with the requirement to approve two transactions returned by getTransactionsToApprove
?
In essence, I'm asking for the pseudo code / steps to craft a bundle and attach its transactions.
I first ask for two transactions to approve. I’ll then add the first as the branchTransaction
of the first transaction of my (new) bundle. But what about the second? I cannot add it as the trunkTransaction
because I’ll need that to build the chain.