Confusing filtering by block hash behaviour in `listsinceblock` #25509

issue darosior opened this issue on June 30, 2022
  1. darosior commented at 1:07 PM on June 30, 2022: member

    The reproduction speaks for itself:

    diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py
    index fc06565983..e06fbf120a 100755
    --- a/test/functional/wallet_listsinceblock.py
    +++ b/test/functional/wallet_listsinceblock.py
    @@ -32,13 +32,14 @@ class ListSinceBlockTest(BitcoinTestFramework):
             self.connect_nodes(1, 2)
             self.generate(self.nodes[2], COINBASE_MATURITY + 1)
     
    -        self.test_no_blockhash()
    -        self.test_invalid_blockhash()
    -        self.test_reorg()
    -        self.test_double_spend()
    -        self.test_double_send()
    -        self.double_spends_filtered()
    -        self.test_targetconfirmations()
    +        # self.test_no_blockhash()
    +        # self.test_invalid_blockhash()
    +        # self.test_reorg()
    +        # self.test_double_spend()
    +        # self.test_double_send()
    +        # self.double_spends_filtered()
    +        # self.test_targetconfirmations()
    +        self.test_consistent_with_gettransaction()
     
         def test_no_blockhash(self):
             self.log.info("Test no blockhash")
    @@ -383,5 +384,19 @@ class ListSinceBlockTest(BitcoinTestFramework):
             assert_equal(original_found, False)
             assert_equal(double_found, False)
     
    +    def test_consistent_with_gettransaction(self):
    +        """Test the filtering in listtransactions is consistent with gettransaction's
    +        output.
    +
    +        The block hash parameter gives, according to the documentation, "the block hash
    +        to list transactions since". Test that if we have a transaction confirmed at a
    +        certain block, listing the coins since this block will output this transaction.
    +        """
    +        txid = self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), 1)
    +        self.generate(self.nodes[2], 1)
    +        tx = self.nodes[2].gettransaction(txid)
    +        coins = self.nodes[2].listsinceblock(tx["blockhash"])["transactions"]
    +        assert txid in (c["txid"] for c in coins)
    +
     if __name__ == '__main__':
         ListSinceBlockTest().main()
    

    Is it intended that filtering transaction "since" block N only output transactions confirmed from block N+1?

  2. darosior added the label Bug on Jun 30, 2022
  3. darosior commented at 1:09 PM on June 30, 2022: member

    (I don't really want the bug label, it might just be an issue with the documentation)

    Note that this behaviour is tested, as including the passed block in the range for the depth check at https://github.com/bitcoin/bitcoin/blob/bae8a66d42d6c5b351879e15e1ab229a1324b18a/src/wallet/rpc/transactions.cpp#L650-L656 breaks other tests.

  4. sipa commented at 1:11 PM on June 30, 2022: member

    I think the idea is that you call listsinceblock with the hash of the last block you've seen before. And then you get all transactions that happened after that block.

    If the behavior is changed to also include the block itself, to replicate the above, you'd need to pass in the hash of the successor block of the last one you've seen... which would require extra work.

  5. darosior referenced this in commit a696d4f972 on Jun 30, 2022
  6. fanquake deleted a comment on Jul 2, 2022
  7. darosior closed this on Jul 6, 2022

  8. DrahtBot locked this on Jul 6, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me