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.

  • @ben75 Thanks for the cross link. I am aware of the cheat sheet but it does not answer my question. getTransactionsToApprove returns two transactions, however, trunkTransaction will always be used / blocked / occupied to build the bundle chain. So I can only use branchTransaction and hence only approve one of the two transactions returned by getTransactionsToApprove. Am I correct? – ralf Dec 27 '17 at 0:10
  • I'm not sure to understand your question precisely. What do you mean by "blocked". The "2 transactions to approve" will be the branch and trunk (or trunk and branch) of the first transaction in your bundle. The trunk of the second transaction of your bunble must be the first transaction in your bundle. The branch transaction of the second tx in the bundle should be latest milestone. I don't see why one is "blocked". Maybe share some code ? – ben75 Dec 27 '17 at 0:25
  • I assumed, that I need to getTransactionsToApprove for every Single transaction in my bundle. So you are saying that I request two transactions to approve per bundle, include their hashes as branch and trunk of the first transaction in my bundle and have the trunk of all subsequent transactions in my bundle point to their respective previous ones. And the branch of every transaction in the bundle except the first one should point to the latest milestone. Is this correct so far? The cheat sheet shows a different branch for the last transaction in the bundle, though. – ralf Dec 27 '17 at 0:28
  • please refer to this question where a future change in the bundle construct (with respect to its trunk and branch) is announced by CfB which is in line with the "1 confirms 2" convention. – GJEEE Feb 13 '18 at 2:04

I checked the code (in the Java library) and here is how it creates a bundle.

Let's say that tip0 and tip1 are the 2 tips to approve.

The last transaction in the bundle (transaction with highest bundle index) will use

  • tip0 as trunk-transaction
  • tip1 as branch-transaction

All other transactions in bundle will use

  • the next transaction in bundle as trunk-transaction (i.e. transaction at index i will use transaction at index i+1)
  • tip0 as branch-transaction
| improve this answer | |
  • But then the cheat sheet is wrong, or? – ralf Dec 27 '17 at 13:46
  • 1
    The cheat sheet represent the particular case where tip0 is the last milestone that leads to some confusion – ben75 Dec 27 '17 at 14:00
  • @ben75 Your answer here is enlightening. When you write "First transaction in bundle" you mean the transaction with highest index in the bundle, don't you? – Roberto Giorgetti Jan 2 '18 at 8:46
  • @drclink yes. I change my post accordingly to reflect bundle index. – ben75 Jan 2 '18 at 9:10

A visual representation and more in-depth-explanation can be found in this blog post:


visual graph

| improve this answer | |

Your Answer

