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

CC BY-SA 4.0
2019-07-04T14:30:50.273Z
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___
CC BY-SA 4.0
2019-07-04T14:31:28.493Z
That is correct.
Claris
CC BY-SA 4.0
2019-07-04T14:42:56.860Z
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___
CC BY-SA 4.0
2019-07-04T14:44:05.590Z
i added the code in the question
nicholas___
CC BY-SA 4.0
2019-07-04T16:48:57.663Z
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
CC BY-SA 4.0
2019-07-05T09:15:36.533Z
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___
CC BY-SA 4.0
2019-07-05T12:03:13.223Z
@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
CC BY-SA 4.0
2019-07-04T14:22:52.450Z
2019-07-04T14:22:52.450Z
Claris
<p>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?</p>

<p>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.</p>

<p>thanks in advance!</p>

<pre><code>'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 &lt; 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'
</code></pre>

<blockchain><p2p>
requesting transaction information through peer2peer network got notfound
nicholas___
# requesting transaction information through peer2peer network got notfound

(Asked by: username_0 on 2019-07-04)

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'

```

**Tags:** blockchain, p2p


---

## 1 answers

### Answer by username_1 on 2019-07-04. Score: 2

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

> **Comments:**
> **username_0**: 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?  
> **username_1**: That is correct.  
> **username_0**: 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"  
> **username_0**: i added the code in the question  
> **username_2**: 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).  
> **username_0**: 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?  
> **username_2**: @username_0 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.  

---

