I'm having a problem with bloom filters when using the getdata message.
As I understand BIP 37, setting the bloom filter on a connection using the loadfilter message with flag BLOOM_UPDATE_P2PUBKEY_ONLY set, the responding client automatically inserts all outpoints (TXID and output index) in the bloom filter of transactions matching the filter. However, when I attempt to do exactly this, the node only ever sends transactions containing outputs TO the address I am filtering for, never transaction that contain outputs FROM the address I am filtering for.
My approach is as follows:
- Add the following public key to the bloom filter: 1JbFvyaMyHHmvvjc54h4YARq3uoX2ZZ4Qj (randomly picked)
Send the filterload message containing the filter (as seen in the wireshark snippet below).
Bitcoin protocol Packet magic: 0xf9beb4d9 Command name: filterload Payload Length: 261 Payload checksum: 0x2bb02c45 Filterload message Filter Count: 251 Data: 000000040004010000000100000000000000020000400000... nHashFunc: 13 nTweak: 0x1a689ff4 nFlags: BLOOM_UPDATE_P2PUBKEY_ONLY (0x02)
Send the getdata message with the hash of all blocks containing transactions to and from the wallet (which I have identified on a block explorer for the purpose of testing this). The inventories are typed MSG_FILTERED_BLOCK.
The node responds with the following messages in order:
The 5 transactions in the list are correct, as the contain outputs targeting said wallet. However, block 0000000000000000019f3... contains transactions with inputs from said wallet, but the merkleblock message of this block is not followed by these transactions. Shouldn't the node add the outputs of these 5 transactions to the bloom filter, and thereby match the later transactions containing inputs pointing at them?
I have confirmed that the node is in possession of the relevant transactions. If i load the filter manually, adding the outputs myself, this works as intended.
Am I misunderstanding how BIP 37 is used?