I am trying to retrieve all new confirmed transactions from the tangle and for each transaction the corresponding transactions that have been confirmed in order to be able to create that transaction. Here is the code I am using but I am not sure, if this is correct as I can not find much documentation or examples on it:
First I get all unconfirmed tips and cache them in a variable
var tipsHashCache;
this.Iota.api.getTips(function(error, hashes) {
...
tipsHashCache = hashes;
});
Then later I use these unconfirmed tips I received to see, if there are any new confirmations for any of them
var confirmedHashes = [];
Iota.api.getLatestInclusion(tipsHashCache, (err, states) => {
...
var confirmedHashes = [];
for (let i in states) {
...
if (states[i]) {
confirmedHashes.push( tipsHashCache[i] );
}
}
}
Then after that in a callback I retrieve all the info about the confirmed transactions:
var confirmedTransactions = [];
Iota.api.getTransactionsObjects(confirmedHashes, (err, transactions) => {
...
confirmedTransactions = confirmedTransactions.concat(transactions);
});
Now from these transactionObjects I want to retrieve the two transactions that have been confirmed by that transaction. So can I just use confirmedTransactions[i].trunkTransaction AND confirmedTransaction[i].branchTransaction? Or am I missing something and do I first have to get all the info about the whole bundle of transactions before I can get the correct corresponding confirmed transactions?
Actually I belief I already found a soultion myself. It looks like it is doing what I want but I am not sure, if it is really the correct way to do it - so I did not post an answer to my own question yet. But it perfectly works for what I need it for, though.
– Eric Xyz Mar 29 '18 at 10:53