Zero output not cleared #33265

issue jsarenik opened this issue on August 28, 2025
  1. jsarenik commented at 10:35 AM on August 28, 2025: none

    I think this relates to #27463, fyi @instagibbs

    Working on a clear reproduction script for regtest, but here are some preliminary notes and signet examples:

    The script (network-less) is 51024e73. It decodes to different addresses for mainnet, testnets (including signets) and regtest:

    • bc1pfeessrawgf - mainnet
    • tb1pfees9rn5nz - testnets (incl. signets)
    • bcrt1pfeesnyr2tx - regtest

    This LN Anchor address is important because such transactions were noticed on signet. See examples of leftover outputs which were spent:

    These outputs can be seen as still available on current master (6ca6f3b37b99) on signet network. Just import following read-only descriptor wallet:

    #!/bin/sh
    ### start a fresh signet daemon, moving old signet datadir
    #bitcoin-cli -signet stop
    #test -d ~/.bitcoin/signet-old || mv ~/.bitcoin/signet ~/.bitcoin/signet-old
    #mkdir -p ~/bitcoin/signet/wallets
    bitcoind -signet -daemon 2>/dev/null
    
    ### adjust or enhance lines above and see also your bitcoin.conf
    
    until bitcoin-cli -signet echo hello 2>/dev/null | grep -q .
    do
      sleep 1
    done
    
    cd ~/.bitcoin/signet/wallets
    test -d lnanchor && cd lnanchor || {
      bitcoin-cli -signet createwallet lnanchor true true
      bitcoin-cli -signet -rpcwallet=lnanchor \
       importdescriptors '[{"desc":"addr(tb1pfees9rn5nz)#8njps4hg","timestamp":"now"}]'
    }
    ph=$(bitcoin-cli -signet getblockchaininfo | grep pruneheight | tr -cd '[0-9]')
    bitcoin-cli -signet loadwallet lnanchor
    bitcoin-cli -signet -rpcwallet=lnanchor rescanblockchain $ph
    
    list() {
      bitcoin-cli -signet -rpcwallet=lnanchor \
        listunspent ${1:-0} \
        | grep -w -e txid -e vout -e amount -e confirmations -e safe \
        | tr -d ' ,"' \
        | cut -d: -f2 \
        | paste -d " " - - - - - \
        | sort -nk4
    }
    
    while true; do LC_ALL=C date -u; list; sleep 1; done
    

    The script works both on an already-synced signet and a newly-syncing (uncomment lines in the top) one. Soon something like the following output may be seen and feel free to press ^C then:

    ...
    Thu Aug 28 15:16:09 UTC 2025
    a7b388a8f48350f92f8987d45409723bf329519816eba808de59ad6ebe974628 2 0.00000000 127 true
    571be0fd823de6bd1c3bc9a7349297aacc7ce73bd99638b53e381aa1651f570c 2 0.00000000 128 true
    06df913b8fb0fc39dac875d1b5c4cc948499ed6e3dca6d2867afc59435e66a6f 2 0.00000000 129 true
    e5cf85120935082b14889674d5c4ed66d8bfce3b8e9c0eebc9d4dea079de01d9 1 0.00000000 131 true
    6faa9ecf8b2c0afd657a32f50d5d93d91d33a578bd8fdd2ef4d960dea2a1bfb7 2 0.00000000 221 true
    85518747043d2bf36418f6262b6a8d35593bf8d2419250448f8cb5cbeab0d5d0 2 0.00000000 251 true
    24e532f648b951376f2cef53b8c07d1e0b1fd0652a257a62968988f31c4aca26 2 0.00000000 269 true
    851248a635cb25d00dd39665636a3208c7252f059cfa418d43bf55535c283a5b 1 0.00000000 272 true
    a69bdd445aa6f82798c745792268cad4cbb2c2dd2e7a32809ee94bce51c26de5 2 0.00000000 273 true
    82779ab667f82ec42f4a7c561da5fab7952e32bf7215ba6d19a2e4fe22ab44a6 1 0.00000000 579 true
    e67aebeb09f64b1fec0177bc1b1edf336f8a31df7f264a3d83db2c2b1ebd7bb7 2 0.00000000 602 true
    67da00b7e55c249ed338618bf7caea128365c2a35c77da5abb379e8574e537a5 2 0.00000000 673 true
    6acce19b0418360f9e0c1650d2267fad6761dd0e98a2da23739b62ebfaa5cb00 2 0.00000000 675 true
    ea0522ba8f4ada4d3770f0d81c212bb0f7da25235e2b8b57c04e90c96b5b598c 2 0.00000000 691 true
    d24a3e60de8ccf95fc4dfa1d6efc9c5f77100d058d1fceccba40d6a54d1a02f2 1 0.00000000 738 true
    0378f0bc23d0cdbc7afe01dbfe77e4b925fa2c426a75509590ccd9f970ca288f 2 0.00000000 817 true
    19b091d8653165fda6ac25f231b6afdaba3a35a4199fa39952ae63de16c08f04 2 0.00000000 818 true
    bcb0311b7d3e78f636319ebb483e36cde5162545b7fc94df7cd4185112d7d712 2 0.00000000 832 true
    13e541ef82d52ca1010b09990f28230cfd57ab54cccd7e7fbf427a05d66d515f 1 0.00000000 833 true
    30f1fcc25b066c63f01b3b0588448bc285713d12c320d0505ac38a2aa96aaa8f 1 0.00000000 834 true
    

    Let's take the first transaction (...4628) and its follow-up which spends the zero output. The latter can not be traced from the former on mempool.space other than checking the LN Anchor address.

    I would expect the zero output to be cleared in the descriptor wallet no matter if the spending transaction has anything to do with the first transaction in a package other than the zero output itself.

  2. maflcko added the label Wallet on Aug 28, 2025
  3. instagibbs commented at 1:14 PM on August 28, 2025: member

    thanks, hit me up when you reproduce it; I am having trouble disintangling if the issue is P2A, TRUC, ephemeral dust, or something else.

  4. jsarenik commented at 3:12 PM on August 28, 2025: none

    The linked transactions (...4628 and ...34f5) in annotated raw:

    VERSION: 03000000
    FLAG: 0001
    INPUTS: 01
     0c571f65a11a383eb53896d93be77cccaa979234a7c93b1cbde63d82fde01b57 01000000 00 00000000 #I-0
    OUTPUTS: 03 [#0](/bitcoin-bitcoin/0/)..2
     e803000000000000 22 5120db7b995709b105a12719e1b4d92ab4bb616805fe0e2aee2db4b86efb64041b69 #O-0
     e803000000000000 22 512036a0c6a87cc73eab25ab672af73f4c766c38d3525844c2dca90f57c1308c39f3 #O-1
     0000000000000000 04 51024e73 #O-2
    WITNESS:
     01 40 b0d664a1ab0e68ff57a35b2c23008f1bea28143d0be8caf048e69ff6fda633a16d65e2771c2988a3e2fb3ece118ecde205fea3d9f9d8f37e68da4cead332f348 #W-0
    LOCKTIME: 00000000
    
    VERSION: 03000000
    FLAG: 0001
    INPUTS: 02 [#0](/bitcoin-bitcoin/0/)..1
     284697be6ead59de08a8eb16985129f33b720954d487892ff95083f4a888b3a7 02000000 00 ffffffff #I-0
     f534e2d9bd6da6f42dc541c461ae75dbaaca3420c6afb9e7e7167189216e2492 00000000 00 fdffffff #I-1
    OUTPUTS: 01
     ef04000000000000 22 51202924f1b0e89d6c495cc3334b06d38163e4e6f7fa9a5dc416a92953f6189854fe #O-0
    WITNESS:
     00 #W-0
     01 40 47de320ab28aa6fbf0f3a96ae6b425f6b5f8addeb88dde3cd5e2d6a5d2bb58b9935265b34bd700438b2d1889e0d8b9d411f5898a7b1cdc9577da71f8f69bdcaf #W-1
    LOCKTIME: c0120400
    

    The latter's second input is the LittleEndian_txid of the former transaction.

    There just came a most-recent package on signet LN Anchor: first (zero-fee) and second (fee-paying spend)

    EDIT: the most-recent package (see above) seems to not case the same zero output leftover in the wallet. Let's see the main difference:

    VERSION: 03000000
    FLAG: 0001
    INPUTS: 01
     90c251d4a52f62f248511ab090632c0e017b3dab77462070956c6ca6d9dd3c99 00000000 00 00000000 #I-0
    OUTPUTS: 02 [#0](/bitcoin-bitcoin/0/)..1
     a086010000000000 22 5120f9f8a765e492ce7341d639980a3e31e673cd2dee2166efebc8aa400852e1d923 #O-0
     0000000000000000 04 51024e73 #O-1
    WITNESS:
     01 40 53debe230b68bc2b708f142fd420de1d4135e08b525ab0ca8e228eaafcf32c579d95dbc69721d918b57dcee4255766af8905fc66ca47902659fcf144f50e670d #W-0
    LOCKTIME: 00000000
    
    VERSION: 03000000
    FLAG: 0001
    INPUTS: 02 [#0](/bitcoin-bitcoin/0/)..1
     c6a6cd36f262677405c55302ceeb5a9a36412cb346bd3ffe31d1622e3f8594e1 01000000 00 ffffffff #I-0
     5bfda7cab1d363326218186f2d3e391ee1db14200d1b5564e748c52fe5fe3c99 01000000 00 fdffffff #I-1
    OUTPUTS: 01
     8b85010000000000 22 5120f78d6ea4fd2f5f996867e97ab99c9ca552e3b67caa1e59da328a76f0f5a9bfc1 #O-0
    WITNESS:
     00 #W-0
     01 40 f3f2fd33508fc137602da150a4cecf92f9acbb83d6737754abf1b93d26ecd537e41e1c6437766128be6fb585e6fb785ed1a0b7cf79293576ccd948e360694ef1 #W-1
    LOCKTIME: 5b130400
    
  5. jsarenik commented at 5:03 PM on August 28, 2025: none

    From observation the important thing triggering the leftover (but spent, i.e. unusable) zero output inside a read-only descriptor wallet seem to be the two outputs to two different addresses in the final spend transaction. See https://mempool.space/signet/tx/af914f3f337bc84910d1d2d5d14556e5c2b07372ea99078d15c7a74c77c0b0e7?mode=details

    Also see https://signet257.bublina.eu.org/sffrest.txt which may contain such transactions in the end of its output:

    <img width="1080" height="1674" alt="Image" src="https://github.com/user-attachments/assets/328d753a-5140-4249-beda-44ec9d4977b4" />

    Ant the same snapshot in plain-text:

    + wc -l
    + safecat.sh /dev/shm/sffrest.txt
    + ls -1 /tmp/sffrest/
    + wc -l
    + myrest=2
    + ls -1 /tmp/sff-s3/
    + wc -l
    + myst=19
    + echo rest 2 stage3 19
    rest 2 stage3 19
    + echo finn
    finn
    + rmdir /tmp/locksff
    + exit 0
    Thu Aug 28 16:51:27 UTC 2025
    24K	/dev/shm/wallets-signet/lnanchor
    1.6M	/dev/shm/wallets-signet/newmy5909
    24K	/dev/shm/wallets-signet/optrue
    Bitcoin Core daemon version v29.99.0-56f7433ded8d
    
    All current LN Anchor outputs seen by this node:
    # txid vout amt conf safe
    96599c7733f2ac4464707c43b1a9ec3dfccbfbb34a6bc7ff25cde695de43670c 2 0.00000000 7 true
    af914f3f337bc84910d1d2d5d14556e5c2b07372ea99078d15c7a74c77c0b0e7 2 0.00000000 8 true
    e194853f2e62d131fe3fbd46b32c41369a5aebce0253c505746762f236cda6c6 1 0.00000000 9 true
    
  6. achow101 commented at 8:29 PM on August 28, 2025: member

    This seems like it's because the check for whether a transaction is "from" the wallet is if it a non-zero amount leaves the wallet. Since these outputs are 0 value, they are definitionally do not meet that criteria.

  7. fanquake closed this on Sep 12, 2025

  8. fanquake referenced this in commit d20f10affb on Sep 12, 2025
  9. bitcoin locked this on Sep 12, 2026

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-09-20 22:52 UTC

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