requesting transaction information through peer2peer network got notfound

0

my current understanding is that after i did my "handshake" with a public node succesfully, i should be able to do a getdata mesage about a transaction from a transaction hash and they should respond with an inv message containing my transaction right?

when i do that i instead receive a "notfound" object. does this means i also have to make sure that i connect to enough node that atleast one node have the data of what i wanted.

thanks in advance!

'def main():
    address = ("35.180.184.150", 8333)
    sock = handshake(address)
    send_getheaders(sock) #get 4000 headers and blocks

    #--------------
    #
    global thres
    thres = 0
    while True and thres < 3 : #thres is so that my program doesnt listen to b'inv for eternity
        try:
            packet = Packet.from_socket(sock)
        except EOFError as e:
            print("Peer hung up")
            return
        except Exception as e:
            print(f'encountered "{e}" reading packet')
        handle_packet(packet, sock)
    tx_hash = int("27936a1262df5d27547f8e12549be5301e71d5aa4d8d82a030530336029f77eb",16) 
    #tx_hash from one of the block
    items = [InventoryItem(1, int_to_bytes(tx_hash, 32))]#getting tx
    getdata = GetData(items=items)
    packet = Packet(getdata.command, getdata.to_bytes())
    sock.send(packet.to_bytes())
    return sock'

nicholas___

Posted 2019-07-04T13:59:55.683

Reputation: 61

Answers

1

This only works for unconfirmed transactions. Nodes do not maintian an index of confirmed transactions because this is unnecessary, so you will receive notfound.

Anonymous

Posted 2019-07-04T13:59:55.683

Reputation: 10 054

I see, but if i do a getheader command , then a getblocks command, then for each block i derive the transactions. then i can receive transaction history?nicholas___ 2019-07-04T14:30:50.273

That is correct.Anonymous 2019-07-04T14:31:28.493

but i am still not quite sure the process of asking for the transaction history can you please tell me what is wrong with my procedure?

  1. Handshake
  2. Getheader
  3. Getblocks
  4. getdata(transaction)

when i do this i still receive a "notfound" – nicholas___ 2019-07-04T14:42:56.860

i added the code in the questionnicholas___ 2019-07-04T14:44:05.590

thankyou verymuch in advancenicholas___ 2019-07-04T14:44:17.830

You cannot ask for individual transactions unless they were specifically advertized to you (through inv tx messages). If you want blocks, download blocks (using the getdata block message, not getdata tx).Pieter Wuille 2019-07-04T16:48:57.663

hmm.. I see , thanks! @PieterWuillenicholas___ 2019-07-05T08:54:46.050

so just to make sure, It is not trivial to grab a transaction details from a node because nodes keep their blockchain data in the form of block headers. which means if I would like to get a transaction details i need to specify the block header and only request that block then do the searching of the transaction locally in my device?nicholas___ 2019-07-05T09:15:36.533

@nicholas___ Right, but more accurately, you never do that. There is no reason (apart from debugging) why you'd ever need to do that. Generally you either download every block already and process it locally, or use some filtering approach where you selectively download (like BIP37 or BIP157). When you care about a transaction, you only know after you've seen it.Pieter Wuille 2019-07-05T12:03:13.223