walletnotify - empty details section for watch-only addresses #17784

issue indeed-a-genius opened this issue on December 20, 2019
  1. indeed-a-genius commented at 4:18 PM on December 20, 2019: none

    I'm on Bitcoin Core 0.19.0.1, linux I only tested in on testnet, not sure if it affects main as well.

    When monitoring watch only addresses and a transaction appears, the walletnotify information is very limited. The [details] section is missing, receiving address isn't known, amount is 0. Example:

    txninfo: Array
    (
        [amount] => 0
        [confirmations] => 1
        [blockhash] => 00000000000017ba50a356cdaad6f5567e5915c990e3323e794ab04cf2329166
        [blockindex] => 2
        [blocktime] => 1576856608
        [txid] => 16c7fb601855ec13721cca37f3cc76cfc11343756028497b387ef07ed9e96ac3
        [walletconflicts] => Array
            (
            )
    
        [time] => 1576856604
        [timereceived] => 1576856604
        [bip125-replaceable] => no
        [details] => Array
            (
            )
    
        [hex] => 0200000001fbeec5d95e589f23d444c6b2866972f82799fa46090921d4009e6d9fd0c7a98e010000006a47304402206e8ba4494b25a6ee8bcf9679dc7561efe7449d9130d016a8c092db4db4708942022028ceb1d1879f11ea006af4079212a03397203ee55eb35acd089bf76f55d9fa1f0121037261975de0fbb69e462818b77c900447e7f3175b4de968a29d0eccc9530b83cdfdffffff02c0c62d00000000001600148effcc93dda4f7809aa56ce807ba4098d9ec6d9634043401000000001976a914c45be3fbe37460aa7a6ccd6d8e46916088f1d42988acf8e61800
    )
    
    

    This makes wallenotify useless for watch-only addresses.

    Is there a workaround? My idea is to monitor and parse the output of "bitcoin-cli listtransactions "*" 100 0 true", since it provides all the details, even for watch-only addresses.

  2. indeed-a-genius added the label Bug on Dec 20, 2019
  3. jb55 commented at 7:17 PM on December 20, 2019: member

    I call gettransaction and getaddressinfo in the script. here's an example script that sends and encrypted email on new transactions. Although if you use multi-wallet, you'll need #13339

    #!/usr/bin/env bash
    set -e
    
    txid="$1"
    wallet="$2"
    
    from="Bitcoin Wallet <bitcoind@monad>"
    to="William Casarin <jb55@jb55.com>"
    subject="Wallet notification"
    keys="-r 0x8860420C3C135662EABEADF96342E010C44A6337 -r 0x5B2B1E4F62216BC74362AC61D4FBA2FC4535A2A9 -r 0xE02D3FD4EB4585A63531C1D0E1BFCB90A1FF7A1C"
    
    tx="$(bitcoin-cli -rpcwallet=$wallet gettransaction "$txid" true)"
    address="$(jq -r '.details[0].address' <<<"$tx")"
    details="$(jq -r '.details[] | [.address, .category, .amount, .label] | [@csv](/bitcoin-bitcoin/contributor/csv/)' <<<"$tx")"
    keypath="$(bitcoin-cli -rpcwallet=$wallet getaddressinfo "$address" | jq -r .hdkeypath)"
    
    amount="$(jq -r '.amount' <<<"$tx")"
    confs="$(jq -r '.confirmations' <<<"$tx")"
    
    time="$(date -d @$(jq -r '.time' <<<"$tx"))"
    received="$(date -d @$(jq -r '.timereceived' <<<"$tx"))"
    
    export GNUPGHOME=/zbig/bitcoin/gpg
    
    msg="$(printf "txid: %s\n\naddress: %s\n\namount: %s\n\nconfirmations: %d\n\nwallet: %s\n\ntime: %s\n\nreceived: %s\n\nkeypath: %s\n\n%s\n\n\n%s" \
                  "$txid" "$address" "$amount" "$confs" "$wallet" "$time" "$received" "$keypath" "$details" "$tx" )"
    
    enctx="$(printf "Content-Type: text/plain\n\n%s\n" "$msg" | gpg --yes --always-trust --encrypt --armor $keys)"
    
    {
    cat <<EOF
    From: $from
    To: $to
    Subject: $subject
    MIME-Version: 1.0
    Content-Type: multipart/encrypted; boundary="=-=-=";
      protocol="application/pgp-encrypted"
    
    --=-=-=
    Content-Type: application/pgp-encrypted
    
    Version: 1
    
    --=-=-=
    Content-Type: application/octet-stream
    
    $enctx
    --=-=-=--
    EOF
    } | sendmail --file /zbig/bitcoin/gpg/.msmtprc -oi -t
    
    printf "sent walletnotify email for %s\n" "$txid"
    
    
  4. fjahr commented at 4:49 PM on December 27, 2019: member

    @indeed-a-genius is it possible that you are using a custom script with walletnotify that is extracting this information for you and the script is not working correctly? I am not using walletnotify but I think it only sends the txid to the script and the rest is implemented in the individual script. I briefly tested and walletnotify should be working with watchonly addresses. See my test here: https://github.com/fjahr/bitcoin/commit/21cbfebe181ae651b938f5b70dbe8dea56e0bf70

  5. indeed-a-genius commented at 5:44 PM on December 27, 2019: none

    Thanks for the replies! I misunderstood what's being sent as %s in walletnotify. I assumed it's a complete json with transaction details, not just txid. I was indeed using a script, which I didn't fully analyze. So no bug here, sorry!

  6. indeed-a-genius closed this on Dec 27, 2019

  7. DrahtBot locked this on Dec 16, 2021
Labels

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-05-03 15:14 UTC

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