janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.52k stars 1.13k forks source link

Transaction view is missing clickable links to transaction input / output addresses #355

Closed xanoni closed 3 years ago

xanoni commented 3 years ago

... consolidating discussion from https://github.com/janoside/btc-rpc-explorer/issues/270 here ...

My transaction view doesn't link to the respective UTXOs. See screenshot below.

image

The JSON tab, however, has the output addresses:

image

Since the above, I pulled the latest master of btcrpcexplorer, installed an up-to-date Electrs and Redis and linked them in the .env config file. I don't think it helped. My browser is an up-to-date Tor Browser, which displays the hosted demo instance of the explorer fine.

btcrpcexplorer has its own, dedicated user.

Another transaction: c01859308e8699df6369296f16c4dc0a1f06b11d18040ae98537dd6bd1170374

I saw on the demo instance what it's supposed to look like:

image

However, my screenshot:

image

Relevant settings (.env):

BTCEXP_ADDRESS_API=electrum
BTCEXP_ELECTRUM_SERVERS=tcp://127.0.0.1:50001
BTCEXP_ELECTRUM_TXINDEX=true
BTCEXP_RPC_CONCURRENCY=20 # worker queue is sufficient
BTCEXP_NO_INMEMORY_RPC_CACHE=false
BTCEXP_REDIS_URL=redis://localhost:6379
BTCEXP_SLOW_DEVICE_MODE=false
BTCEXP_PRIVACY_MODE=false
BTCEXP_NO_RATES=false
BTCEXP_BASIC_AUTH_PASSWORD=<xyz>
BTCEXP_RPC_ALLOWALL=false
BTCEXP_OLD_SPACE_MAX_SIZE=2048

Log file looks good to me:

[...]
npm[9739]: 2021-07-23T22:00:54.439Z btcexp:app Connecting to RPC node at 127.0.0.1:8332
npm[9739]: 2021-07-23T22:00:54.457Z btcexp:app Verifying RPC connection...
npm[9739]: 2021-07-23T22:00:54.462Z btcexp:app Loading mining pools config
npm[9739]: 2021-07-23T22:00:54.538Z btcexp:app RPC Connected: version=219900 subversion=/Satoshi:21.99.0/, parsedVersion(used for RPC versioning)=21.99.0, protocolversion=70016, chain=main, services=[NETWORK, WITNESS, NETWORK_LIMITED]
npm[9739]: 2021-07-23T22:00:54.538Z btcexp:app Loading historical data for chain=main
npm[9739]: 2021-07-23T22:00:54.543Z btcexp:app txindex check: trying getindexinfo
npm[9739]: 2021-07-23T22:00:54.588Z btcexp:app Refreshed utxo summary: {"height":692351 [...],"transactions":45397509,"disk_size":[...]}
npm[9739]: 2021-07-23T22:00:54.645Z btcexp:app txindex check: getindexinfo={"txindex":{"synced":true,"best_block_height":692351},"coinstatsindex":{"synced":true,"best_block_height":692351}}
npm[9739]: 2021-07-23T22:00:54.645Z btcexp:app txindex check: available!
[...]

I enabled more logging, this is the output that I'm getting when I open a different transaction (ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e):

npm[8154]: 2021-07-23T22:29:45.861Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",1]}
npm[8154]: 2021-07-23T22:29:45.877Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["46b4df066d43e7668d8cab87ddac3d91419b9726e04274ff24e772f2fca5d9f8",1]}
npm[8154]: 2021-07-23T22:29:45.877Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["3e43685a598e9891e8cd9af9b40bf649111a06e9153a6c7d47eb6636deae13bf",1]}
npm[8154]: 2021-07-23T22:29:45.878Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["2cfd79ebab8743e41e27f0e184bb1a6b3755236f22a449ec451c0abf1970b5c1",1]}
npm[8154]: 2021-07-23T22:29:45.879Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["ae19f3b900489078968aeafb6ce262c38a080153f3a0edb339384376e255b532",1]}
npm[8154]: 2021-07-23T22:29:45.879Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["e7bbc3562ba56e79e31f43e76bfe55c2c116c84597add79c53494e50ac19a62d",1]}
npm[8154]: 2021-07-23T22:29:45.880Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["1dcafed5203c753701b5a1e89d82bb7149ebb7a9299f5e63e52f28176de0827d",1]}
npm[8154]: 2021-07-23T22:29:45.880Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["0eb00144f78964da3d2c560e03a7e9c1be0d4ad1826f70a77ff2ab4d55b2876f",1]}
npm[8154]: 2021-07-23T22:29:45.881Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["4f8cc44ec16739a77c41f3e527531cc74af82946e4faf8cbfb5360bc1c3905a3",1]}
npm[8154]: 2021-07-23T22:29:45.882Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["2fc772ac058d6847689fbd0ad2ddea4b6c6e0ade1910c84c8be2186a1411aa24",1]}
npm[8154]: 2021-07-23T22:29:45.882Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["3711d0ad6c74605bda80d463524431c55f6d4f09cbee0da542e8df45eaaeada9",1]}
npm[8154]: 2021-07-23T22:29:45.883Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["ffbbdfc9738dca862cfd7f50edab9412b434db100f3dd4b21f4a5eddd38f5279",1]}
npm[8154]: 2021-07-23T22:29:45.885Z btcexp:rpc RPC: {"method":"getrawtransaction","parameters":["4ccd9aab42dc8e8714d097df0e6ab554e70e1b1b125bb8242960f200a8ebf76b",1]}
npm[8154]: 2021-07-23T22:29:46.270Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",0]}
npm[8154]: 2021-07-23T22:29:46.270Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",1]}
npm[8154]: 2021-07-23T22:29:46.270Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",2]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",3]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",4]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",5]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",6]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",7]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",8]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",9]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",10]}
npm[8154]: 2021-07-23T22:29:46.271Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",11]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",12]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",13]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",14]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",15]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",16]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",17]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",18]}
npm[8154]: 2021-07-23T22:29:46.272Z btcexp:rpc RPC: {"method":"gettxout","parameters":["ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e",19]}
npm[8154]: 2021-07-23T22:29:46.464Z btcexp:actionPerformace Finished action '/tx/ec8f79f29c84b72582dd79c379da7cd071c98c2b6f7c82be5a990c661209548e' in 605 ms
npm[8154]: 2021-07-23T22:29:47.704Z btcexp:actionPerformace Finished action '/snippet/quote/random' in 3 ms
janoside commented 3 years ago

@xanoni What version of Bitcoin Core are you running? The JSON output format being returned by your Bitcoin Core is different than the mainline releases that I use. Specifically, if you look at the JSON tab for this random transaction, you can see the json content around the addresses has a format like:

"vout": [
    {
        "value": 0.01,
        "n": 0,
        "scriptPubKey": {
            "asm": "OP_HASH160 5141a84a72b24ad956cc0eb1a9e37b0b8ab0abbb OP_EQUAL",
            "hex": "a9145141a84a72b24ad956cc0eb1a9e37b0b8ab0abbb87",
            "reqSigs": 1,
            "type": "scripthash",
            "addresses": [
                "396fK37JUoKYiYP3n7nQecB8f8PYTtRoW6"
            ]
        }
    },

If you notice, the JSON path to access the address here is: vout[0].scriptPubKey.addresses[0]. On the other hand, the JSON output being returned from your Bitcoin Core (as shown above), would use a different JSON path: vout[0].scriptPubKey.address. That difference is the reason the explorer isn't showing the addresses.

I am curious to know what version you're running so I can decide whether or not the explorer should gracefully handle the two different formats.

Thanks.

xanoni commented 3 years ago

I am curious to know what version you're running so I can decide whether or not the explorer should gracefully handle the two different formats.

Ohh, I'm typically pretty close to HEAD (so I can use I2P alongside Tor). So not the stable release. Some change seems to be coming to core ;-)

janoside commented 3 years ago

Ah-ha! Right you are. Looks like the response will be changing soon:

https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L137

I'll work on a fix for you. Thanks for helping with this.

xanoni commented 3 years ago

Thank you :)

janoside commented 3 years ago

@xanoni I just pushed a fix for this issue. If you can test, verify, and report back here it would be much appreciated!

xanoni commented 3 years ago

Looking good to me now! Should have come here earlier, I tried all kinds of stuff but didn't realize that bitcoind output changed. Thank you!

TX: 209617fee1fdae33e87fa381f536737da8e0d68fd24a4cc2e7760a39c57925a1

image