4

I want to get the current tip transactions; trying to get the tips addresses using pyota api works fine:

tips = api.get_tips()
addr_tips = tips['hashes']

However trying to find transactions from the above addresses:

hashes = api.find_transactions(addresses=addr_tips)

gives empty answer. What am I doing wrong ?

3

Tips are transactions, not addresses

api.getTips() already returns the tips (= transactions), not addresses.
tips['hashes'] are the transaction hashes of the tips.

So when you do

hashes = api.find_transactions(addresses=addr_tips)

You are giving find_transactions() a bunch of transaction hashes as addresses. The node then looks up all those transaction hashes (thinking they are addresses because they have the same length as addresses).
Since there are no transactions using those "addresses", you get an empty result.


Bug

You were probably confused because of this. I was too but I figured out that the Addresses are actually TransactionHashes because

  1. Tips are transactions, therefore get_tips() should return transactions.
  2. The result addresses all ended with 4 nines. TransactionHashes always end with 4 nines for example:

[Address(b'DGUAYXNWFMZCQOIJBGQGHAUTDZRXOONMIPRHS9KOIGL99OPLAECWGA9MCUAMHFWQJBVJLYGTRRDGA9999'), Address(b'LKNKVDENAJLYPZYEBEEEKGQSGQRHRYZOGZBX9EHGIDLAYPFNXFRPOYXPJKBOMOBPMV9BKDCVKHBPZ9999'), Address(b'VZ9GJYNIYLSNJYFIHCTAFWDCEPYIAOHZPWNUSACVABUDALIJVV9WDEQBFMJEZQHUYCJEFFQNVWKEZ9999'), Address(b'KWAUXSLHYL99HTLOLDXJ9IAMPVEKSJRCTNYUXNIVUZRMEED9PXYKYMICIDTIU9GAUANYMMCHO99MZ9999'), Address(b'TXGGPSGSLEULGFTWEBDNLRBMK9HEXGTVXGSHLXMGSMJGVREYZDFSO9TUDAGOAITAA9NPP9TBELJUA9999'), Address(b'QIUE9NIXHOXWEDZYBKCT9LBPIYVPEJAQIJKYCGPXTICMFIKAXEKRZEJQKSNFEQJZWDLHFDXB9FCJ99999'), Address(b'OGWFDEDC9YQJCJQUSUAGIHUBODOVVCRITJG9RWAFTXHZMTAVJWUPHZWPRWICRIUIKAOMXQWHAKMA99999'), Address(b'MHXVLYBKI9NXVMGASRCSVTGTWPRS9VEN9GAGNFRVOTFHBCXLQUSVDIQHMNHYHZBTZZCSLGHSEDYOA9999'), Address(b'JTG9EEXQFAAI9TGGQ99JA9LMTKWG9FDBOECR9EIAIJEIHGPOEZKSNGDZBPTVEQZKEAPAVVHNMYHBA9999'), ...

Solution

To achieve what you want, this is enough:

tips = api.get_tips()
hashes = tips['hashes']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.