2

I wrote a small script to play with the bitcoin P2P network.

The script advertises itself as (NODE_NETWORK | NODE_WITNESS), and connects to a full node running on the LAN.

Everything seems to work fine, except that the script only receives block data stripped off witness data. (Connecting to different nodes doesn't make any difference.)

How can the script instruct the peer node to send full blocks, without stripping anything?

Below are a few lines from the log file. Thank you.

2023-01-30 06:36:19.310: Connecting to peer: 10.0.0.123:8333
2023-01-30 06:36:19.312: [SEND]    version      f9beb4d976657273696f6e00000000006c000000e1ba30cf801101000900000000000000e3f4d66300000000010000000000000000000000000000000000ffff7f000001208d010000000000000000000000000000000000ffff7f000001208d00000000000000001648656c6c6f205361746f736869204e616b616d6f746f0000000000
2023-01-30 06:36:19.313: [RECV]    version      header: f9beb4d976657273696f6e0000000000660000006616dd1a payload [102 B] 801101000904000000000000e3f4d6630000000000000000000000000000000000000000000000000000000000000904000000000000000000000000000000000000000000000000ac5cd217ba7685cd102f5361746f7368693a32342e302e312f66d00b0001
2023-01-30 06:36:19.313: [DECODED] version: 70016 services: 1033 NODE_NETWORK NODE_WITNESS NODE_NETWORK_LIMITED height: 774246 relay: 1 User-Agent: /Satoshi:24.0.1/   Peer time: 2023-01-30 06:36:19

2023-01-30 06:36:19.313: [RECV]    wtxidrelay   header: f9beb4d9777478696472656c61790000000000005df6e0e2 payload [0 B] 
2023-01-30 06:36:19.313: [RECV]    sendaddrv2   header: f9beb4d973656e646164647276320000000000005df6e0e2 payload [0 B] 
2023-01-30 06:36:19.313: [RECV]    verack       header: f9beb4d976657261636b000000000000000000005df6e0e2 payload [0 B] 

2023-01-30 06:36:19.313: [SEND]    verack       f9beb4d976657261636b000000000000000000005df6e0e2
2023-01-30 06:36:19.314: [RECV]    sendcmpct    header: f9beb4d973656e64636d70637400000009000000e92f5ef8 payload [9 B] 000200000000000000
2023-01-30 06:36:19.314: [RECV]    ping         header: f9beb4d970696e670000000000000000080000004070f2b4 payload [8 B] 881b7945cd6b0011
2023-01-30 06:36:19.314: [SEND]    pong         f9beb4d9706f6e670000000000000000080000004070f2b4881b7945cd6b0011
2023-01-30 06:36:19.314: [RECV]    getheaders   header: f9beb4d967657468656164657273000005040000a39b4512 payload [1029 B]

2023-01-30 06:37:44.724: [RECV]    inv          header: f9beb4d9696e7600000000000000000025000000f4c99144 payload [37 B] 010200000010223b2dd24b758021e5c75e15b18e5dbfd14c54b80006000000000000000000
2023-01-30 06:37:44.724: [DECODED] inv [#0] 02000000 10223b2dd24b758021e5c75e15b18e5dbfd14c54b80006000000000000000000 BLOCK 0000000000000000000600b8544cd1bf5d8eb1155ec7e52180754bd22d3b2210

2023-01-30 06:37:44.724: [SEND]    getdata      f9beb4d967657464617461000000000025000000f4c99144010200000010223b2dd24b758021e5c75e15b18e5dbfd14c54b80006000000000000000000
2023-01-30 06:37:44.762: [RECV]    block        header: f9beb4d9626c6f636b00000000000000e1610c00e288e832 payload [811489 B]
0

1 Answer 1

3

When requesting the block data with getdata, you should set the inv type to 0x40000002 (MSG_WITNESS_BLOCK), as explained in BIP144.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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