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 = ("", 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
            packet = Packet.from_socket(sock)
        except EOFError as e:
            print("Peer hung up")
        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())
    return sock'

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

|improve this answer|||||
  • 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___ Jul 4 '19 at 14:30
  • That is correct. – Anonymous Jul 4 '19 at 14:31
  • 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___ Jul 4 '19 at 14:42
  • i added the code in the question – nicholas___ Jul 4 '19 at 14:44
  • thankyou verymuch in advance – nicholas___ Jul 4 '19 at 14:44

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.